Skip to content

Commit

Permalink
adding missing await, removing comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Pikora authored and marcos-iov committed Sep 27, 2023
1 parent 0e0650f commit 968ecf2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
6 changes: 2 additions & 4 deletions lib/2wp-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,17 @@ const donateToBridge = async (rskTxHelper, btcTxHelper, donatingBtcAddressInform

const disableWhitelisting = async (rskTxHelper) => {
const latestActiveForkName = await getLatestActiveForkName();
console.log(`latestActiveForkName - disableWhitelisting: ${latestActiveForkName}`)
const bridge = getBridge(rskTxHelper.getClient(), latestActiveForkName);

const addr = await rskTxHelper.importAccount(WHITELIST_CHANGE_PK)
expect(addr.slice(2)).to.equal(WHITELIST_CHANGE_ADDR);
const unlock = await rskTxHelper.unlockAccount(addr);
console.log(`unlock: ${unlock}`)
await rskTxHelper.unlockAccount(addr);

await sendTxWithCheck(
rskTxHelper,
bridge.methods.setLockWhitelistDisableBlockDelay(1),
WHITELIST_CHANGE_ADDR,
(disableResult) => expect(Number(disableResult)).to.equal(1)()
(disableResult) => expect(Number(disableResult)).to.equal(1)
);
rskTxHelper.mine(1);
}
Expand Down
22 changes: 1 addition & 21 deletions tests/02_00_02-2wp_segwit_compatible.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ let btcTxHelper;

const fulfillRequirementsToRunAsSingleTestFile = async (rskTxHelper) => {
const latestForkName = rskUtils.getLatestForkName()
console.log(`latestForkName: ${JSON.stringify(latestForkName)}`)
await rskUtils.activateFork(latestForkName);
disableWhitelisting(rskTxHelper)
await disableWhitelisting(rskTxHelper)
};

describe('Lock using p2sh-p2wpkh address', () => {
Expand All @@ -26,36 +25,18 @@ describe('Lock using p2sh-p2wpkh address', () => {

if(process.env.RUNNING_SINGLE_TEST_FILE) {
await fulfillRequirementsToRunAsSingleTestFile(rskTxHelper);
// const latestActiveForkName = await getLatestActiveForkName();
// console.log(`latestActiveForkName: ${latestActiveForkName}`)
// bridge = getBridge(rskTxHelper.getClient(), latestActiveForkName);

// const addr = await rskTxHelper.importAccount(WHITELIST_CHANGE_PK)
// console.log(`addr: ${addr}`)
// expect(addr.slice(2)).to.equal(WHITELIST_CHANGE_ADDR);
// await rskTxHelper.unlockAccount(addr);

// await rskUtils.sendTxWithCheck(
// rskTxHelper,
// bridge.methods.setLockWhitelistDisableBlockDelay(1),
// WHITELIST_CHANGE_ADDR),
// (disableResult) => expect(Number(disableResult)).to.equal(1)();

// rskTxHelper.mine(1);
}
});

it('should do a legacy pegin using p2sh-p2wpkh address', async () => {
const latestActiveForkName = await getLatestActiveForkName();
console.log(`latestActiveForkName: ${latestActiveForkName}`)
const bridge = getBridge(rskTxHelper.getClient(), latestActiveForkName);

const minimumPeginValueInSatoshis = await bridge.methods.getMinimumLockTxValue().call();
const minimumPeginValueInBtc = btcEthUnitConverter.satoshisToBtc(minimumPeginValueInSatoshis);

const federationAddress = await bridge.methods.getFederationAddress().call();
const federationAddressBalanceInitial = Number(await btcTxHelper.getAddressBalance(federationAddress));
console.log(`federationAddressBalanceInitial: ${federationAddressBalanceInitial}`)

const senderAddressInfo = await btcTxHelper.generateBtcAddress('p2sh-segwit');
const recipientRskAddressInfo = getDerivedRSKAddressInformation(senderAddressInfo.privateKey, btcTxHelper.btcConfig.network);
Expand All @@ -69,7 +50,6 @@ describe('Lock using p2sh-p2wpkh address', () => {
await ensurePeginIsRegistered(rskTxHelper, btcPeginTxHash);

const federationAddressBalanceAfterPegin = Number(await btcTxHelper.getAddressBalance(federationAddress));
console.log(`federationAddressBalanceAfterPegin: ${federationAddressBalanceAfterPegin}`)
expect(federationAddressBalanceAfterPegin).to.be.equal(Number(federationAddressBalanceInitial + minimumPeginValueInBtc));

const senderAddressBalanceAfterPegin = Number(await btcTxHelper.getAddressBalance(senderAddressInfo.address));
Expand Down

0 comments on commit 968ecf2

Please sign in to comment.