diff --git a/lib/tests/2wp.js b/lib/tests/2wp.js index e7943819..95335071 100644 --- a/lib/tests/2wp.js +++ b/lib/tests/2wp.js @@ -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 @@ -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; }); @@ -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 @@ -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; }); @@ -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 @@ -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; }); @@ -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 @@ -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; }); @@ -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 @@ -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; }); @@ -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 @@ -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; });