diff --git a/lib/tests/2wp.js b/lib/tests/2wp.js index 253f7e64..38fc1c46 100644 --- a/lib/tests/2wp.js +++ b/lib/tests/2wp.js @@ -121,11 +121,11 @@ const execute = (description, getRskHost) => { const sender2PeginValueInSatoshis = minimumPeginValueInSatoshis; const peginValueInSatoshis = sender1PeginValueInSatoshis + sender2PeginValueInSatoshis; - const sender1UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo1.btcSenderAddressInfo.address, satoshisToBtc(sender1PeginValueInSatoshis)); - const sender2UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo2.btcSenderAddressInfo.address, satoshisToBtc(sender2PeginValueInSatoshis)); + const sender1UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo1.btcSenderAddressInfo.address, Number(satoshisToBtc(sender1PeginValueInSatoshis))); + const sender2UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo2.btcSenderAddressInfo.address, Number(satoshisToBtc(sender2PeginValueInSatoshis))); - const sender1ChangeInSatoshis = btcToSatoshis(sender1UtxosInfo.change); - const sender2ChangeInSatoshis = btcToSatoshis(sender2UtxosInfo.change); + const sender1ChangeInSatoshis = Number(btcToSatoshis(sender1UtxosInfo.change)); + const sender2ChangeInSatoshis = Number(btcToSatoshis(sender2UtxosInfo.change)); const tx = new bitcoinJsLib.Transaction(); @@ -189,25 +189,25 @@ const execute = (description, getRskHost) => { const sender2PeginValueInSatoshis = minimumPeginValueInSatoshis; const peginValueInSatoshis = sender1PeginValueInSatoshis + sender2PeginValueInSatoshis; - const sender1UtxosInfo = await getAddressUtxosInfo(btcTxHelper, senderRecipientInfo1.btcSenderAddressInfo.address, satoshisToBtc(sender1PeginValueInSatoshis)); - const sender2UtxosInfo = await getAddressUtxosInfo(btcTxHelper, senderRecipientInfo2.btcSenderAddressInfo.address, satoshisToBtc(sender2PeginValueInSatoshis)); + const sender1UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo1.btcSenderAddressInfo.address, Number(satoshisToBtc(sender1PeginValueInSatoshis))); + const sender2UtxosInfo = await btcTxHelper.selectSpendableUTXOsFromAddress(senderRecipientInfo2.btcSenderAddressInfo.address, Number(satoshisToBtc(sender2PeginValueInSatoshis))); - const sender1ChangeInSatoshis = btcToSatoshis(sender1UtxosInfo.change); - const sender2ChangeInSatoshis = btcToSatoshis(sender2UtxosInfo.change); + const sender1ChangeInSatoshis = Number(btcToSatoshis(sender1UtxosInfo.change)); + const sender2ChangeInSatoshis = Number(btcToSatoshis(sender2UtxosInfo.change)); const tx = new bitcoinJsLib.Transaction(); // Adding inputs - addInputs(tx, sender1UtxosInfo); - addInputs(tx, sender2UtxosInfo); + addInputs(tx, sender1UtxosInfo.utxos); + addInputs(tx, sender2UtxosInfo.utxos); // Adding 2 outputs to the federation - addOutputToFed(tx, sender1PeginValueInSatoshis); - addOutputToFed(tx, sender2PeginValueInSatoshis); + addOutput(tx, federationAddress, sender1PeginValueInSatoshis); + addOutput(tx, federationAddress, sender2PeginValueInSatoshis); // Adding change outputs - addChangeOutput(tx, senderRecipientInfo1.btcSenderAddressInfo.address, sender1ChangeInSatoshis); - addChangeOutput(tx, senderRecipientInfo2.btcSenderAddressInfo.address, sender2ChangeInSatoshis); + addOutput(tx, senderRecipientInfo1.btcSenderAddressInfo.address, sender1ChangeInSatoshis - btcFeeInSatoshis); + addOutput(tx, senderRecipientInfo2.btcSenderAddressInfo.address, sender2ChangeInSatoshis - btcFeeInSatoshis); const sendersPrivateKeys = [senderRecipientInfo1.btcSenderAddressInfo.privateKey, senderRecipientInfo2.btcSenderAddressInfo.privateKey];