Added tests for forced sign
This commit is contained in:
parent
74089e9f5c
commit
6665e0e0a5
|
@ -1,23 +1,31 @@
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
|
|
||||||
const { waitPromise, delay } = require('./utils/wait')
|
const { waitPromise, delay } = require('./utils/wait')
|
||||||
const { getBepBalance, getBncFlags } = require('./utils/bncController')
|
const { getBepBalance, getBncFlags, getBncSequence } = require('./utils/bncController')
|
||||||
|
|
||||||
const { controller1, controller3 } = require('./utils/proxyController')
|
const { controller1, controller3 } = require('./utils/proxyController')
|
||||||
|
|
||||||
module.exports = (newValidator) => {
|
module.exports = (getUsers, newValidator) => {
|
||||||
describe('add validator', function () {
|
describe('add validator', function () {
|
||||||
let info
|
let info
|
||||||
let initialInfo
|
let initialInfo
|
||||||
let nextValidators
|
let nextValidators
|
||||||
|
let user
|
||||||
|
let bncBridgeSequence
|
||||||
|
let bncBalance
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
initialInfo = await controller1.getInfo()
|
initialInfo = await controller1.getInfo()
|
||||||
|
// eslint-disable-next-line prefer-destructuring
|
||||||
|
user = getUsers()[0]
|
||||||
|
bncBridgeSequence = await getBncSequence(info.foreignBridgeAddress)
|
||||||
|
bncBalance = await user.getBepBalance()
|
||||||
info = initialInfo
|
info = initialInfo
|
||||||
nextValidators = [...initialInfo.validators, newValidator]
|
nextValidators = [...initialInfo.validators, newValidator]
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should start closing epoch process', async function () {
|
it('should start closing epoch process', async function () {
|
||||||
|
await user.exchangeErc(5)
|
||||||
await controller1.voteStartVoting()
|
await controller1.voteStartVoting()
|
||||||
await delay(5000)
|
await delay(5000)
|
||||||
info = await controller1.getInfo()
|
info = await controller1.getInfo()
|
||||||
|
@ -38,6 +46,16 @@ module.exports = (newValidator) => {
|
||||||
assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Incorrect set of next validators after third vote')
|
assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Incorrect set of next validators after third vote')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should make forced sign', async function () {
|
||||||
|
this.timeout(300000)
|
||||||
|
await waitPromise(
|
||||||
|
() => getBncSequence(info.foreignBridgeAddress),
|
||||||
|
(sequence) => sequence === bncBridgeSequence + 1
|
||||||
|
)
|
||||||
|
const newBncBalance = await user.getBepBalance()
|
||||||
|
assert.strictEqual(newBncBalance, bncBalance + 5, `Balance of ${user.bncAddress} did not updated as expected`)
|
||||||
|
})
|
||||||
|
|
||||||
it('should finish close epoch process and start voting process', async function () {
|
it('should finish close epoch process and start voting process', async function () {
|
||||||
this.timeout(120000)
|
this.timeout(120000)
|
||||||
info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'voting')
|
info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'voting')
|
||||||
|
|
|
@ -88,7 +88,7 @@ describe('bridge tests', function () {
|
||||||
testBncToEth(() => users)
|
testBncToEth(() => users)
|
||||||
testEthToBnc(() => users)
|
testEthToBnc(() => users)
|
||||||
|
|
||||||
testAddValidator(validatorsConfig[1])
|
testAddValidator(() => users, validatorsConfig[1])
|
||||||
|
|
||||||
testEthToBnc(() => users)
|
testEthToBnc(() => users)
|
||||||
testBncToEth(() => users)
|
testBncToEth(() => users)
|
||||||
|
|
Loading…
Reference in New Issue