Skip to content

Commit

Permalink
Adds bridge own balance and bridge utxos balance checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-then committed Sep 26, 2024
1 parent b26125f commit 72f2e37
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/tests/2wp.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ const execute = (description, getRskHost) => {

// Arrange

const initialBridgeBalance = Number(await rskTxHelper.getBalance(BRIDGE_ADDRESS));
const initialBridgeUtxosBalance = await getBridgeUtxosBalance(rskTxHelper);
const initialFederationAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, federationAddress);
const senderRecipientInfo = await createSenderRecipientInfo(rskTxHelper, btcTxHelper);
const initialSenderAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, senderRecipientInfo.btcSenderAddressInfo.address);
Expand Down Expand Up @@ -153,6 +155,14 @@ const execute = (description, getRskHost) => {
const finalRskRecipientBalance = Number(await rskTxHelper.getBalance(senderRecipientInfo.rskRecipientRskAddressInfo.address));
expect(finalRskRecipientBalance).to.be.equal(Number(satoshisToWeis(peginValueInSatoshis)));

// After the successful pegin, the Bridge balance should be reduced by the pegin value
const finalBridgeBalance = Number(await rskTxHelper.getBalance(BRIDGE_ADDRESS));
expect(finalBridgeBalance).to.be.equal(initialBridgeBalance - satoshisToWeis(peginValueInSatoshis));

// After the successful pegin, the Bridge utxos sum should be incremented by the pegin value
const finalBridgeUtxosBalance = await getBridgeUtxosBalance(rskTxHelper);
expect(finalBridgeUtxosBalance).to.be.equal(initialBridgeUtxosBalance + peginValueInSatoshis);

});

});
Expand Down

0 comments on commit 72f2e37

Please sign in to comment.