2019-10-28 05:47:07 -07:00
|
|
|
const { delay } = require('./utils/wait')
|
|
|
|
|
|
|
|
module.exports = (usersFunc, foreignBridgeAddressFunc) => {
|
|
|
|
describe('exchange of tokens in bnc => eth direction', function () {
|
|
|
|
let users
|
|
|
|
let foreignBridgeAddress
|
|
|
|
let ethBalances
|
|
|
|
|
|
|
|
before(async function () {
|
|
|
|
users = usersFunc()
|
|
|
|
foreignBridgeAddress = foreignBridgeAddressFunc()
|
|
|
|
ethBalances = await Promise.all(users.map(user => user.getEthBalance()))
|
|
|
|
|
|
|
|
await Promise.all(users.map((user, i) => user.exchangeBnc(foreignBridgeAddress, 3 + i)))
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should make coorect exchange transactions on eth side', async function () {
|
|
|
|
for (let i = 0; i < 3; i++) {
|
|
|
|
do {
|
|
|
|
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-10-28 05:47:07 -07:00
|
|
|
} while (true)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|