From 6665e0e0a537c111d44bf13a48c10e415faf94ef Mon Sep 17 00:00:00 2001 From: Kirill Fedoseev Date: Thu, 14 Nov 2019 17:18:56 +0300 Subject: [PATCH] Added tests for forced sign --- tests/test/addValidator.js | 22 ++++++++++++++++++++-- tests/test/index.js | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/test/addValidator.js b/tests/test/addValidator.js index e0423dc..61d89ea 100644 --- a/tests/test/addValidator.js +++ b/tests/test/addValidator.js @@ -1,23 +1,31 @@ const assert = require('assert') 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') -module.exports = (newValidator) => { +module.exports = (getUsers, newValidator) => { describe('add validator', function () { let info let initialInfo let nextValidators + let user + let bncBridgeSequence + let bncBalance before(async function () { initialInfo = await controller1.getInfo() + // eslint-disable-next-line prefer-destructuring + user = getUsers()[0] + bncBridgeSequence = await getBncSequence(info.foreignBridgeAddress) + bncBalance = await user.getBepBalance() info = initialInfo nextValidators = [...initialInfo.validators, newValidator] }) it('should start closing epoch process', async function () { + await user.exchangeErc(5) await controller1.voteStartVoting() await delay(5000) 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') }) + 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 () { this.timeout(120000) info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'voting') diff --git a/tests/test/index.js b/tests/test/index.js index aa85b05..3acb9bb 100644 --- a/tests/test/index.js +++ b/tests/test/index.js @@ -88,7 +88,7 @@ describe('bridge tests', function () { testBncToEth(() => users) testEthToBnc(() => users) - testAddValidator(validatorsConfig[1]) + testAddValidator(() => users, validatorsConfig[1]) testEthToBnc(() => users) testBncToEth(() => users)