diff --git a/lib/tests/2wp.js b/lib/tests/2wp.js index 6a1e85d7..eeadd433 100644 --- a/lib/tests/2wp.js +++ b/lib/tests/2wp.js @@ -6,7 +6,6 @@ const { getBtcClient } = require('../btc-client-provider'); const { getRskTransactionHelper, getRskTransactionHelpers } = require('../rsk-tx-helper-provider'); const { satoshisToBtc, btcToSatoshis, satoshisToWeis } = require('@rsksmart/btc-eth-unit-converter'); const { findEventInBlock, triggerRelease, getPegoutEventsInBlockRange, setFeePerKb, sendTransaction } = require('../rsk-utils'); -const { satoshisToBtc, btcToSatoshis, satoshisToWeis, btcToWeis } = require('@rsksmart/btc-eth-unit-converter'); const BridgeTransactionParser = require('@rsksmart/bridge-transaction-parser'); const { PEGIN_REJECTION_REASONS, @@ -827,7 +826,7 @@ const execute = (description, getRskHost) => { // Arrange const initial2wpBalances = await get2wpBalances(rskTxHelper, btcTxHelper); - const pegoutValueInRbtc = MINIMUM_PEGOUT_AMOUNT_IN_RBTC; + const pegoutValueInSatoshis = MINIMUM_PEGOUT_AMOUNT_IN_SATOSHIS; const { callReleaseBtcContract, creatorAddress } = await deployCallReleaseBtcContract(rskTxHelper); const initialRskSenderBalanceInWeisBN = await rskTxHelper.getBalance(creatorAddress); @@ -835,19 +834,19 @@ const execute = (description, getRskHost) => { // Act const callBridgeReleaseBtcMethod = callReleaseBtcContract.methods.callBridgeReleaseBtc(); - const contractCallTxReceipt = await sendTransaction(rskTxHelper, callBridgeReleaseBtcMethod, creatorAddress, btcToWeis(pegoutValueInRbtc)); + const contractCallTxReceipt = await sendTransaction(rskTxHelper, callBridgeReleaseBtcMethod, creatorAddress, satoshisToWeis(pegoutValueInSatoshis)); // Assert const rskSenderAddressChecksummed = rskTxHelper.getClient().utils.toChecksumAddress(ensure0x(callReleaseBtcContract.options.address)); - const expectedEvent = createExpectedReleaseRequestRejectedEvent(rskSenderAddressChecksummed, btcToSatoshis(pegoutValueInRbtc), PEGOUT_REJECTION_REASONS.CALLER_CONTRACT); + const expectedEvent = createExpectedReleaseRequestRejectedEvent(rskSenderAddressChecksummed, pegoutValueInSatoshis, PEGOUT_REJECTION_REASONS.CALLER_CONTRACT); const actualReleaseRequestRejectedEvent = getReleaseRequestRejectedEventFromContractCallTxReceipt(contractCallTxReceipt); expect(actualReleaseRequestRejectedEvent).to.be.deep.equal(expectedEvent); - await assert2wpBalancesAfterPegoutFromContract(initial2wpBalances, pegoutValueInRbtc); + await assert2wpBalancesAfterPegoutFromContract(initial2wpBalances, pegoutValueInSatoshis); // The rsk sender should lose the funds since there's no refund when a smart contract is trying to do a pegout - const expectedRskSenderBalanceInWeisBN = initialRskSenderBalanceInWeisBN.sub(new BN(`${btcToWeis(pegoutValueInRbtc)}`)); + const expectedRskSenderBalanceInWeisBN = initialRskSenderBalanceInWeisBN.sub(new BN(`${satoshisToWeis(pegoutValueInSatoshis)}`)); const finalRskSenderBalanceInWeisBN = await rskTxHelper.getBalance(creatorAddress); expect(finalRskSenderBalanceInWeisBN.eq(expectedRskSenderBalanceInWeisBN)).to.be.true; @@ -941,7 +940,7 @@ const assert2wpBalanceIsUnchanged = async (initial2wpBalances) => { expect(final2wpBalances).to.be.deep.equal(initial2wpBalances); }; -const assert2wpBalancesAfterPegoutFromContract = async (initial2wpBalances, pegoutValueInRbtc) => { +const assert2wpBalancesAfterPegoutFromContract = async (initial2wpBalances, pegoutValueInSatoshis) => { const final2wpBalances = await get2wpBalances(rskTxHelper, btcTxHelper); expect(final2wpBalances.federationAddressBalanceInSatoshis).to.be.equal(initial2wpBalances.federationAddressBalanceInSatoshis); @@ -949,7 +948,7 @@ const assert2wpBalancesAfterPegoutFromContract = async (initial2wpBalances, pego expect(final2wpBalances.bridgeUtxosBalanceInSatoshis).to.be.equal(initial2wpBalances.bridgeUtxosBalanceInSatoshis); // When a contract sends funds to the Bridge to try to do a pegout, the pegout is rejected and the Bridge rsk balance is increased by the pegout value // because there's no refund when a contract is trying to do a pegout. - const expectedBridgeBalanceInWeisBN = initial2wpBalances.bridgeBalanceInWeisBN.add(new BN(btcToWeis(pegoutValueInRbtc))); + const expectedBridgeBalanceInWeisBN = initial2wpBalances.bridgeBalanceInWeisBN.add(new BN(satoshisToWeis(pegoutValueInSatoshis))); expect(final2wpBalances.bridgeBalanceInWeisBN.eq(expectedBridgeBalanceInWeisBN)).to.be.true; };