2019-11-03 10:00:15 -08:00
|
|
|
const { waitPromise } = require('./utils/wait')
|
2019-10-28 05:47:07 -07:00
|
|
|
|
2019-10-30 06:53:43 -07:00
|
|
|
const { controller1 } = require('./utils/proxyController')
|
|
|
|
|
2019-11-03 10:00:15 -08:00
|
|
|
module.exports = (getUsers) => {
|
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 () {
|
2019-11-03 10:00:15 -08:00
|
|
|
users = getUsers()
|
2019-10-30 06:53:43 -07:00
|
|
|
info = await controller1.getInfo()
|
2019-11-03 10:00:15 -08:00
|
|
|
ethBalances = await Promise.all(users.map((user) => user.getErcBalance()))
|
2019-10-28 05:47:07 -07:00
|
|
|
|
2019-11-03 10:00:15 -08:00
|
|
|
await Promise.all(users.map((user, i) => user.exchangeBep(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 () {
|
2019-11-18 08:57:16 -08:00
|
|
|
this.timeout(120000)
|
2019-11-01 11:43:25 -07:00
|
|
|
for (let i = 0; i < 3; i += 1) {
|
2019-11-03 10:00:15 -08:00
|
|
|
const user = users[i]
|
|
|
|
await waitPromise(
|
|
|
|
user.getErcBalance,
|
|
|
|
// eslint-disable-next-line no-loop-func
|
|
|
|
(newEthBalance) => newEthBalance === ethBalances[i] + 3 + i
|
|
|
|
)
|
2019-10-28 05:47:07 -07:00
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|