Skip to content

Commit

Permalink
fix by comments PR and tests repair (ask Travis)
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavShevchenko committed Sep 4, 2019
1 parent 8de280f commit 1d02ca1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .env.example
Expand Up @@ -41,4 +41,4 @@ ROLLBAR_TOKEN=
MONGO_DB_URI=
WEB3_SITE_URL=
DISABLE_FACE_VERIFICATION=
ENABLE_MONGO_LOCK=false
ENABLE_MONGO_LOCK=
27 changes: 13 additions & 14 deletions src/server/blockchain/__tests__/adminWallet.test.js
@@ -1,6 +1,6 @@
import AdminWallet from '../AdminWallet'

jest.setTimeout(3000000)
jest.setTimeout(100000)
beforeAll(async () => {
await AdminWallet.ready
})
Expand Down Expand Up @@ -44,29 +44,28 @@ test('adminWallet receive queue nonce', async () => {
})

test('adminWallet bad transaction in queue', async () => {

const unverifiedAddress = '0xC8282816Bbbb5A417762feE6e736479D4809D129';
const from = AdminWallet.address;
const testValue = 10;
const badGas = 10;
let tx;

const unverifiedAddress = '0xC8282816Bbbb5A417762feE6e736479D4809D129'
const from = AdminWallet.address
const testValue = 10
const badGas = 10
let tx

//good tx
tx = await AdminWallet.topWallet(unverifiedAddress, null, true)
expect(tx).toBeTruthy()

//bad tx
await expect(AdminWallet.sendNative(
{
await expect(
AdminWallet.sendNative({
from,
to: unverifiedAddress,
value: testValue,
gas: badGas,
gasPrice: badGas
})).rejects.toThrow()

})
).rejects.toThrow()

//good tx
tx = await AdminWallet.topWallet(unverifiedAddress, null, true)
expect(tx).toBeTruthy()

})
8 changes: 4 additions & 4 deletions src/server/utils/tx-manager/queueMongo.js
@@ -1,5 +1,5 @@
import WalletNonce from '../../db/mongo/models/wallet-nonce'

import logger from '../../../imports/pino-logger'
export default class queueMongo {
constructor() {
this.model = WalletNonce
Expand Down Expand Up @@ -39,7 +39,7 @@ export default class queueMongo {

return wallet
} catch (e) {
console.log(e)
logger.error('TX queueMongo (getWalletNonce)', e)
return false
}
}
Expand All @@ -63,7 +63,7 @@ export default class queueMongo {
})
}
} catch (e) {
console.log(e)
logger.error('TX queueMongo (createIfNotExist)', e)
}
}

Expand Down Expand Up @@ -141,7 +141,7 @@ export default class queueMongo {
}
}
} catch (e) {
console.log(e)
log.error('TX queueMongo (run)', e)
}
}
}
15 changes: 12 additions & 3 deletions src/server/verification/__tests__/verificationAPI.js
Expand Up @@ -7,6 +7,8 @@ import { getToken } from '../../__util__/'
import UserDBPrivate from '../../db/mongo/user-privat-provider'
import Config from '../../server.config'

const storage = UserDBPrivate

Config.skipEmailVerification = false
describe('verificationAPI', () => {
let server
Expand All @@ -17,8 +19,11 @@ describe('verificationAPI', () => {
console.log({ server })
})

afterAll(done => {
afterAll(async done => {
console.log('afterAll')

await storage.model.deleteMany({ fullName: new RegExp('test_user_sendemail', 'i') })

server.close(err => {
done()
})
Expand All @@ -42,7 +47,7 @@ describe('verificationAPI', () => {
profilePublickey: 'kxudRZes6qS44fus50kd0knUVftOeyDTQnmsnMmiaWA.uzJ1fJM0evhtave7yZ5OWBa2O91MBU7DNAHau8xUXYw'
}
const token = await getToken(server, userCredentials)
await UserDBPrivate.updateUser({ identifier: token, smsValidated: false })
await UserDBPrivate.updateUser({ identifier: token, smsValidated: false, fullName: 'test_user_sendemail' })

await request(server)
.post('/verify/sendotp')
Expand All @@ -61,9 +66,11 @@ describe('verificationAPI', () => {
test('/verify/sendemail with creds', async () => {
const token = await getToken(server)

await storage.model.deleteMany({ fullName: new RegExp('test_user_sendemail', 'i') })

const user = await UserDBPrivate.updateUser({
identifier: '0x7ac080f6607405705aed79675789701a48c76f55',
fullName: 'full name'
fullName: 'test_user_sendemail'
})

expect(user).toBeTruthy()
Expand All @@ -79,7 +86,9 @@ describe('verificationAPI', () => {
.set('Authorization', `Bearer ${token}`)
.expect(200, { ok: 1 })
await delay(500)

const dbUser = await UserDBPrivate.getUser('0x7ac080f6607405705aed79675789701a48c76f55')

expect(dbUser.mauticId).toBeTruthy()
expect(dbUser.emailVerificationCode).toBeTruthy()
})
Expand Down

0 comments on commit 1d02ca1

Please sign in to comment.