Skip to content

Commit

Permalink
Checking rsk initial balance.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-then committed Jan 13, 2025
1 parent 381cf13 commit 16a9f45
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/tests/2wp.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const execute = (description, getRskHost) => {
const initialSenderAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, senderRecipientInfo.btcSenderAddressInfo.address);
const peginValueInSatoshis = minimumPeginValueInSatoshis;
const peginV1RskRecipientAddress = await rskTxHelper.newAccountWithSeed('successfulPeginV1');
const peginV1RskRecipientAddressInitialBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);

// Act

Expand All @@ -166,7 +167,7 @@ const execute = (description, getRskHost) => {

// The pegin v1 rsk recipient address has the funds
const finalRskRecipientBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);
const expectedFinalRskRecipientBalanceInWeisBN = new BN(satoshisToWeis(peginValueInSatoshis));
const expectedFinalRskRecipientBalanceInWeisBN = new BN(satoshisToWeis(peginValueInSatoshis)).add(peginV1RskRecipientAddressInitialBalanceInWeisBN);
expect(finalRskRecipientBalanceInWeisBN.eq(expectedFinalRskRecipientBalanceInWeisBN)).to.be.true;

});
Expand Down Expand Up @@ -225,6 +226,7 @@ const execute = (description, getRskHost) => {
const peginValueInSatoshis = minimumPeginValueInSatoshis - 1;

const peginV1RskRecipientAddress = await rskTxHelper.newAccountWithSeed('rejectedPeginV1');
const peginV1RskRecipientAddressInitialBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);

// Act

Expand Down Expand Up @@ -254,9 +256,8 @@ const execute = (description, getRskHost) => {
const finalSenderDerivedRskAddressBalance = Number(await rskTxHelper.getBalance(senderRecipientInfo.rskRecipientRskAddressInfo.address));
expect(finalSenderDerivedRskAddressBalance).to.be.equal(0);

// The pegin v1 rsk recipient address is also zero
const finalRskRecipientBalance = Number(await rskTxHelper.getBalance(peginV1RskRecipientAddress));
expect(finalRskRecipientBalance).to.be.equal(0);
const finalRskRecipientBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);
expect(finalRskRecipientBalanceInWeisBN.eq(peginV1RskRecipientAddressInitialBalanceInWeisBN)).to.be.true;

});

Expand Down Expand Up @@ -344,6 +345,7 @@ const execute = (description, getRskHost) => {
const initialSenderAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, multisigSenderAddressInfo.address);
const peginValueInSatoshis = minimumPeginValueInSatoshis;
const peginV1RskRecipientAddress = await rskTxHelper.newAccountWithSeed('successfulPeginV1FromMultisig');
const peginV1RskRecipientAddressInitialBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);

// Act

Expand All @@ -367,7 +369,7 @@ const execute = (description, getRskHost) => {
// The pegin v1 rsk recipient address has the funds
const finalRskRecipientBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);
const expectedFinalRskRecipientBalanceInWeisBN = new BN(satoshisToWeis(peginValueInSatoshis));
expect(finalRskRecipientBalanceInWeisBN.eq(expectedFinalRskRecipientBalanceInWeisBN)).to.be.true;
expect(finalRskRecipientBalanceInWeisBN.eq(expectedFinalRskRecipientBalanceInWeisBN.add(peginV1RskRecipientAddressInitialBalanceInWeisBN))).to.be.true;

});

Expand All @@ -382,6 +384,7 @@ const execute = (description, getRskHost) => {
const initialSenderAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, bech32SenderAddressInfo.address);
const peginValueInSatoshis = minimumPeginValueInSatoshis;
const peginV1RskRecipientAddress = await rskTxHelper.newAccountWithSeed('successfulPeginV1FromBech32');
const peginV1RskRecipientAddressInitialBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);

// Act

Expand All @@ -405,7 +408,7 @@ const execute = (description, getRskHost) => {
// The pegin v1 rsk recipient address has the funds
const finalRskRecipientBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);
const expectedFinalRskRecipientBalanceInWeisBN = new BN(satoshisToWeis(peginValueInSatoshis));
expect(finalRskRecipientBalanceInWeisBN.eq(expectedFinalRskRecipientBalanceInWeisBN)).to.be.true;
expect(finalRskRecipientBalanceInWeisBN.eq(expectedFinalRskRecipientBalanceInWeisBN.add(peginV1RskRecipientAddressInitialBalanceInWeisBN))).to.be.true;

});

Expand All @@ -418,6 +421,7 @@ const execute = (description, getRskHost) => {
const initialSenderAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, senderRecipientInfo.btcSenderAddressInfo.address);
const peginValueInSatoshis = minimumPeginValueInSatoshis;
const peginV1RskRecipientAddress = await rskTxHelper.newAccountWithSeed('successfulPeginV1WithBtcRefundAddress');
const peginV1RskRecipientAddressInitialBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);

// Act

Expand Down Expand Up @@ -445,7 +449,7 @@ const execute = (description, getRskHost) => {
// The pegin v1 rsk recipient address has the funds
const finalRskRecipientBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);
const expectedFinalRskRecipientBalanceInWeisBN = new BN(satoshisToWeis(peginValueInSatoshis));
expect(finalRskRecipientBalanceInWeisBN.eq(expectedFinalRskRecipientBalanceInWeisBN)).to.be.true;
expect(finalRskRecipientBalanceInWeisBN.eq(expectedFinalRskRecipientBalanceInWeisBN.add(peginV1RskRecipientAddressInitialBalanceInWeisBN))).to.be.true;

});

Expand Down Expand Up @@ -543,6 +547,7 @@ const execute = (description, getRskHost) => {
const initialSenderAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, senderRecipientInfo.btcSenderAddressInfo.address);
const peginValueInSatoshis = minimumPeginValueInSatoshis;
const peginV1RskRecipientAddress = await rskTxHelper.newAccountWithSeed('successfulPeginV1Multiple_OP_RETURN');
const peginV1RskRecipientAddressInitialBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);

// Act

Expand Down Expand Up @@ -573,7 +578,7 @@ const execute = (description, getRskHost) => {
// The pegin v1 rsk recipient address has the funds
const finalRskRecipientBalanceInWeisBN = await rskTxHelper.getBalance(peginV1RskRecipientAddress);
const expectedFinalRskRecipientBalanceInWeisBN = new BN(satoshisToWeis(peginValueInSatoshis));
expect(finalRskRecipientBalanceInWeisBN.eq(expectedFinalRskRecipientBalanceInWeisBN)).to.be.true;
expect(finalRskRecipientBalanceInWeisBN.eq(expectedFinalRskRecipientBalanceInWeisBN.add(peginV1RskRecipientAddressInitialBalanceInWeisBN))).to.be.true;

});

Expand Down

0 comments on commit 16a9f45

Please sign in to comment.