2019-10-28 05:47:07 -07:00
|
|
|
const { delay } = require('./utils/wait')
|
|
|
|
|
2019-10-30 06:53:43 -07:00
|
|
|
const { controller1 } = require('./utils/proxyController')
|
|
|
|
|
2019-11-01 11:43:25 -07:00
|
|
|
module.exports = (usersFunc) => {
|
2019-10-28 05:47:07 -07:00
|
|
|
describe('exchange of tokens in bnc => eth direction', function () {
|
|
|
|
let users
|
2019-10-30 06:53:43 -07:00
|
|
|
let info
|
2019-10-28 05:47:07 -07:00
|
|
|
let ethBalances
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
users = usersFunc()
|
2019-10-30 06:53:43 -07:00
|
|
|
info = await controller1.getInfo()
|
2019-11-01 11:43:25 -07:00
|
|
|
ethBalances = await Promise.all(users.map((user) => user.getEthBalance()))
|
2019-10-28 05:47:07 -07:00
|
|
|
|
2019-10-30 06:53:43 -07:00
|
|
|
await Promise.all(users.map((user, i) => user.exchangeBnc(info.foreignBridgeAddress, 3 + i)))
|
2019-10-28 05:47:07 -07:00
|
|
|
})
|
|
|
|
|
2019-11-01 11:43:25 -07:00
|
|
|
it('should make correct exchange transactions on eth side', async function () {
|
|
|
|
for (let i = 0; i < 3; i += 1) {
|
|
|
|
while (true) {
|
2019-10-28 05:47:07 -07:00
|
|
|
const user = users[i]
|
|
|
|
const newEthBalance = await user.getEthBalance()
|
|
|
|
if (newEthBalance === ethBalances[i] + 3 + i) {
|
|
|
|
break
|
|
|
|
}
|
2019-10-29 13:46:18 -07:00
|
|
|
await delay(500)
|
2019-11-01 11:43:25 -07:00
|
|
|
}
|
2019-10-28 05:47:07 -07:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|