Skip to content

Commit

Permalink
review comments updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Pikora authored and Jan Pikora committed Sep 29, 2023
1 parent 825ecad commit 58e0569
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 14 additions & 6 deletions lib/2wp-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 = {
Expand Down
6 changes: 3 additions & 3 deletions tests/02_00_02-2wp_segwit_compatible.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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);
}
});

Expand Down

0 comments on commit 58e0569

Please sign in to comment.