Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking rsk initial balance. #199

Open
wants to merge 1 commit into
base: rits-refactors-9-2024-integration
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading