diff --git a/lib/2wp-utils.js b/lib/2wp-utils.js index 806bb885..76a88880 100644 --- a/lib/2wp-utils.js +++ b/lib/2wp-utils.js @@ -6,6 +6,7 @@ const { getBridgeState } = require('@rsksmart/bridge-state-data-parser'); const btcEthUnitConverter = require('btc-eth-unit-converter'); const peginVerifier = require('pegin-address-verificator'); const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); +const { WHITELIST_CHANGE_PK, WHITELIST_CHANGE_ADDR} = require('../lib/assertions/whitelisting') const ADDRESS_TYPES_CODES = { p2pkh: '01', @@ -239,21 +240,28 @@ const donateToBridge = async (rskTxHelper, btcTxHelper, donatingBtcAddressInform return peginBtcTxHash; }; -const disableWhitelisting = async (rskTxHelper) => { +/** + * Disabling whitelisting + * @param {RskTransactionHelper} rskTxHelper + * @param {BtcTransactionHelper} btcTxHelper + */ +const disableWhitelisting = async (rskTxHelper, btcTxHelper) => { + btcBlocksToMine = 1; const latestActiveForkName = await getLatestActiveForkName(); const bridge = getBridge(rskTxHelper.getClient(), latestActiveForkName); - const addr = await rskTxHelper.importAccount(WHITELIST_CHANGE_PK) - expect(addr.slice(2)).to.equal(WHITELIST_CHANGE_ADDR); - await rskTxHelper.unlockAccount(addr); + const whitelistChangeAddress = await rskTxHelper.importAccount(WHITELIST_CHANGE_PK) + expect(whitelistChangeAddress.slice(2)).to.equal(WHITELIST_CHANGE_ADDR); + await rskTxHelper.unlockAccount(whitelistChangeAddress); await sendTxWithCheck( rskTxHelper, - bridge.methods.setLockWhitelistDisableBlockDelay(1), + bridge.methods.setLockWhitelistDisableBlockDelay(btcBlocksToMine), WHITELIST_CHANGE_ADDR, (disableResult) => expect(Number(disableResult)).to.equal(1) ); - rskTxHelper.mine(1); + + btcTxHelper.mine(btcBlocksToMine); } module.exports = { diff --git a/tests/02_00_02-2wp_segwit_compatible.js b/tests/02_00_02-2wp_segwit_compatible.js index 0be4dc37..ff2d9690 100644 --- a/tests/02_00_02-2wp_segwit_compatible.js +++ b/tests/02_00_02-2wp_segwit_compatible.js @@ -11,10 +11,10 @@ let rskTxHelpers; let rskTxHelper; let btcTxHelper; -const fulfillRequirementsToRunAsSingleTestFile = async (rskTxHelper) => { +const fulfillRequirementsToRunAsSingleTestFile = async (rskTxHelper, btcTxHelper) => { const latestForkName = rskUtils.getLatestForkName() await rskUtils.activateFork(latestForkName); - await disableWhitelisting(rskTxHelper) + await disableWhitelisting(rskTxHelper, btcTxHelper) }; describe('Lock using p2sh-p2wpkh address', () => { @@ -24,7 +24,7 @@ describe('Lock using p2sh-p2wpkh address', () => { btcTxHelper = getBtcClient(); if(process.env.RUNNING_SINGLE_TEST_FILE) { - await fulfillRequirementsToRunAsSingleTestFile(rskTxHelper); + await fulfillRequirementsToRunAsSingleTestFile(rskTxHelper, btcTxHelper); } });