From 9fb9520527ea7ab85303a4cfca4125fa5c61c8a6 Mon Sep 17 00:00:00 2001 From: jeremy-then Date: Fri, 29 Nov 2024 14:37:05 -0400 Subject: [PATCH 1/2] Removes 'surpassing locking cap' tests since they are not needed anymore. --- tests/01_03_53-post_papyrus_locking_cap.js | 84 ----------- ...ast_btc_transaction_surpass_locking_cap.js | 100 -------------- ..._cap_sending_same_tx_with_witness_twice.js | 130 ------------------ ...p_sending_same_tx_without_witness_twice.js | 113 --------------- ..._05-fastbridge_operation_with_rejection.js | 102 -------------- 5 files changed, 529 deletions(-) delete mode 100644 tests/01_03_53-post_papyrus_locking_cap.js delete mode 100644 tests/01_04_53-post_iris_register_fast_btc_transaction_surpass_locking_cap.js delete mode 100644 tests/01_04_58-post_iris_flyover_surpassing_locking_cap_sending_same_tx_with_witness_twice.js delete mode 100644 tests/01_04_59-post_iris_flyover_surpassing_locking_cap_sending_same_tx_without_witness_twice.js delete mode 100644 tests/04_00_05-fastbridge_operation_with_rejection.js diff --git a/tests/01_03_53-post_papyrus_locking_cap.js b/tests/01_03_53-post_papyrus_locking_cap.js deleted file mode 100644 index bdad708f..00000000 --- a/tests/01_03_53-post_papyrus_locking_cap.js +++ /dev/null @@ -1,84 +0,0 @@ -const expect = require('chai').expect -const peglib = require('peglib'); -const bitcoin = peglib.bitcoin; -const rsk = peglib.rsk; -const pegUtils = peglib.pegUtils; -const rskUtilsLegacy = require('../lib/rsk-utils-legacy'); -const pegAssertions = require('../lib/assertions/2wp'); -const CustomError = require('../lib/CustomError'); -var { sequentialPromise, wait } = require('../lib/utils'); -const rskUtils = require('../lib/rsk-utils'); -const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); - -const NETWORK = bitcoin.networks.testnet; - -describe('Calling locking cap methods after papyrus200 fork', function() { - - var federationAddress; - var btcClient; - var rskClient; - var pegClient; - var test; - var utils; - let rskTxHelpers; - - before(async () => { - btcClient = bitcoin.getClient( - Runners.hosts.bitcoin.rpcHost, - Runners.hosts.bitcoin.rpcUser, - Runners.hosts.bitcoin.rpcPassword, - NETWORK - ); - rskClient = rsk.getClient(Runners.hosts.federate.host); - pegClient = pegUtils.using(btcClient, rskClient); - utils = rskUtilsLegacy.with(btcClient, rskClient, pegClient); - test = pegAssertions.with(btcClient, rskClient, pegClient); - federationAddress = await rskClient.rsk.bridge.methods.getFederationAddress().call(); - rskTxHelpers = getRskTransactionHelpers(); - - // Mine a few rsk blocks to prevent being at the beginning of the chain, - // which could trigger border cases we're not interested in - await sequentialPromise(10, () => rskUtils.mineAndSync(rskTxHelpers)); - - // // Update the bridge to sync btc blockchains - await rskClient.fed.updateBridge(); - await rskUtils.mineAndSync(rskTxHelpers); - - return federationAddress; - }); - - it('should return 1000 when calling getLockingCap method', async () => { - try{ - var callResult = await rskClient.rsk.bridge.methods.getLockingCap().call(); - expect(Number(callResult)).to.equal(bitcoin.btcToSatoshis(1000)); - } - catch (err) { - throw new CustomError('getLockingCap call failure', err); - } - }) - - it('should return true when calling increaseLockingCap method', async () => { - try{ - var authAddress = await rskClient.eth.personal.importRawKey("da6a5451bfd74829307ec6d4a8c55174d4859169f162a8ed8fcba8f7636e77cc", ''); - expect(authAddress.slice(2)).to.equal("6913bd4715eff3b25501f3212f15df38296d1f21"); - - await utils.sendFromCow(authAddress, rskClient.utils.toWei('100')); - - var increaseLockingCap = bitcoin.btcToSatoshis(1500); - var callResult = await rskClient.rsk.bridge.methods.increaseLockingCap(increaseLockingCap).call({ from: authAddress }); - expect(callResult).to.be.true; - - var sendTxPromise = rskClient.rsk.bridge.methods.increaseLockingCap(increaseLockingCap).send({ from: authAddress }); - await wait(1000); - await rskUtils.mineAndSync(rskTxHelpers); - var sendTxResult = await sendTxPromise; - expect(sendTxResult).not.null; - - var callResult = await rskClient.rsk.bridge.methods.getLockingCap().call(); - expect(Number(callResult)).to.equal(increaseLockingCap); - } - catch (err) { - throw new CustomError('increaseLockingCap call failure', err); - } - }) -}); diff --git a/tests/01_04_53-post_iris_register_fast_btc_transaction_surpass_locking_cap.js b/tests/01_04_53-post_iris_register_fast_btc_transaction_surpass_locking_cap.js deleted file mode 100644 index 2911f94d..00000000 --- a/tests/01_04_53-post_iris_register_fast_btc_transaction_surpass_locking_cap.js +++ /dev/null @@ -1,100 +0,0 @@ -const expect = require('chai').expect -const redeemScriptParser = require('@rsksmart/powpeg-redeemscript-parser'); -const CustomError = require('../lib/CustomError'); -const lbc = require('../lib/liquidity-bridge-contract'); -const { REFUNDED_USER_ERROR } = require("../lib/flyover-pegin-response-codes"); -const { sendTxWithCheck, triggerRelease, getFedsPubKeys } = require('../lib/rsk-utils'); -const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); -const { getBtcClient } = require('../lib/btc-client-provider'); -const btcEthUnitConverter = require('@rsksmart/btc-eth-unit-converter'); -const { ensure0x, wait } = require('../lib/utils'); -const { fundAddressAndGetData } = require('../lib/btc-utils'); -const { getBridge } = require('../lib/bridge-provider'); -const { mineForPeginRegistration } = require('../lib/2wp-utils'); - -describe('Executing registerFastBtcTransaction after iris - with release', () => { - - let rskTxHelpers; - let rskTxHelper; - let btcTxHelper; - let bridge; - - before(async () => { - rskTxHelpers = getRskTransactionHelpers(); - rskTxHelper = rskTxHelpers[0]; - btcTxHelper = getBtcClient(); - bridge = getBridge(rskTxHelper.getClient()); - }); - - it('should return funds when calling registerFastBtcTransaction method surpassing locking cap', async () => { - try { - - const liquidityBridgeContract = await lbc.getLiquidityBridgeContract(Runners.hosts.federate.host); - const initialLbcBalance = Number(await rskTxHelper.getBalance(liquidityBridgeContract._address)); - const FEDS_PUBKEYS_LIST = await getFedsPubKeys(bridge); - const userBtcRefundAddress = (await btcTxHelper.generateBtcAddress('legacy')).address; - const userBtcRefundAddressBytes = ensure0x(btcTxHelper.decodeBase58Address(userBtcRefundAddress)); - const liquidityProviderBtcAddress = (await btcTxHelper.generateBtcAddress('legacy')).address; - const liquidityProviderBtcAddressBytes = ensure0x(btcTxHelper.decodeBase58Address(liquidityProviderBtcAddress)); - const preHash = rskTxHelper.getClient().utils.randomHex(32); - - const AMOUNT_TO_SEND_IN_BTC = 2500; - - const derivationHash = await liquidityBridgeContract.methods.getDerivationHash( - preHash, - userBtcRefundAddressBytes, - liquidityProviderBtcAddressBytes - ).call(); - - const amountForFlyoverInSatoshis = Number(btcEthUnitConverter.btcToSatoshis(AMOUNT_TO_SEND_IN_BTC)); - - const fundingAmountInBtc = AMOUNT_TO_SEND_IN_BTC + 1; - - const redeemScript = redeemScriptParser.getPowpegRedeemScript(FEDS_PUBKEYS_LIST); - - const flyoverRedeemScript = redeemScriptParser.getFlyoverRedeemScript(redeemScript, derivationHash.substring(2)); - const flyoverFedAddress = redeemScriptParser.getAddressFromRedeemScript('REGTEST', flyoverRedeemScript); - const data = await fundAddressAndGetData(btcTxHelper, flyoverFedAddress, AMOUNT_TO_SEND_IN_BTC, fundingAmountInBtc); - - const cowAddress = await rskTxHelper.newAccountWithSeed('cow'); - - await mineForPeginRegistration(rskTxHelper, btcTxHelper); - - const registerFastBridgeBtcTransactionMethod = liquidityBridgeContract.methods.registerFastBridgeBtcTransaction( - ensure0x(data.rawTx), - ensure0x(data.pmt), - data.height, - userBtcRefundAddressBytes, - liquidityProviderBtcAddressBytes, - preHash - ); - - const checkFunction = (result) => { - const resultValue = Number(result); - expect(REFUNDED_USER_ERROR).to.be.equals(resultValue); - }; - - await sendTxWithCheck( - rskTxHelper, - registerFastBridgeBtcTransactionMethod, - cowAddress, - checkFunction - ); - - const currentLbcBalance = Number(await rskTxHelper.getBalance(liquidityBridgeContract._address)); - expect(currentLbcBalance).to.equal(initialLbcBalance); - - await triggerRelease(rskTxHelpers, btcTxHelper); - await wait(500); - - const finalBalanceInSatoshis = Number(btcEthUnitConverter.btcToSatoshis(await btcTxHelper.getAddressBalance(userBtcRefundAddress))); - const difference = amountForFlyoverInSatoshis - finalBalanceInSatoshis; - const FEE_IN_SATOSHIS = Number(btcEthUnitConverter.btcToSatoshis(0.001)); - - expect(difference).to.be.at.most(FEE_IN_SATOSHIS * 2); - - } catch(e) { - throw new CustomError('registerFastBridgeBtcTransaction call failure', e); - } - }); -}); diff --git a/tests/01_04_58-post_iris_flyover_surpassing_locking_cap_sending_same_tx_with_witness_twice.js b/tests/01_04_58-post_iris_flyover_surpassing_locking_cap_sending_same_tx_with_witness_twice.js deleted file mode 100644 index fd7074e7..00000000 --- a/tests/01_04_58-post_iris_flyover_surpassing_locking_cap_sending_same_tx_with_witness_twice.js +++ /dev/null @@ -1,130 +0,0 @@ -const expect = require('chai').expect -const redeemScriptParser = require('@rsksmart/powpeg-redeemscript-parser'); -const { UNPROCESSABLE_TX_ALREADY_PROCESSED_ERROR, REFUNDED_USER_ERROR } = require("../lib/flyover-pegin-response-codes"); -const CustomError = require('../lib/CustomError'); -const lbc = require('../lib/liquidity-bridge-contract'); -const { sendTxWithCheck, getFedsPubKeys } = require('../lib/rsk-utils'); -const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); -const { getBtcClient } = require('../lib/btc-client-provider'); -const { ensure0x } = require('../lib/utils'); -const { fundAddressAndGetData } = require('../lib/btc-utils'); -const { getBridge } = require('../lib/bridge-provider'); -const { mineForPeginRegistration } = require('../lib/2wp-utils'); - -describe('Executing registerFastBtcTransaction post hop - surpassing locking cap sending same tx with witness twice', () => { - - let rskTxHelpers; - let rskTxHelper; - let btcTxHelper; - let bridge; - - before(async () => { - rskTxHelpers = getRskTransactionHelpers(); - rskTxHelper = rskTxHelpers[0]; - btcTxHelper = getBtcClient(); - bridge = getBridge(rskTxHelper.getClient()); - }); - - it(`The first tx should fail due to surpassing the locking cap, and the second tx should fail due to hash already been used`, async () => { - try { - - const liquidityBridgeContract = await lbc.getLiquidityBridgeContract(Runners.hosts.federate.host); - const initialLbcBalance = Number(await rskTxHelper.getBalance(liquidityBridgeContract._address)); - const FEDS_PUBKEYS_LIST = await getFedsPubKeys(bridge); - const userBtcRefundAddress = (await btcTxHelper.generateBtcAddress('legacy')).address; - const userBtcRefundAddressBytes = ensure0x(btcTxHelper.decodeBase58Address(userBtcRefundAddress)); - const liquidityProviderBtcAddress = (await btcTxHelper.generateBtcAddress('legacy')).address; - const liquidityProviderBtcAddressBytes = ensure0x(btcTxHelper.decodeBase58Address(liquidityProviderBtcAddress)); - const preHash = rskTxHelper.getClient().utils.randomHex(32); - - const AMOUNT_TO_SEND_IN_BTC = 2500; - - const derivationHash = await liquidityBridgeContract.methods.getDerivationHash( - preHash, - userBtcRefundAddressBytes, - liquidityProviderBtcAddressBytes - ).call(); - - const fundingAmountInBtc = AMOUNT_TO_SEND_IN_BTC + 1; - const powpegRedeemScript = redeemScriptParser.getPowpegRedeemScript(FEDS_PUBKEYS_LIST); - const flyoverRedeemScript = redeemScriptParser.getFlyoverRedeemScript(powpegRedeemScript, derivationHash.substring(2)); - const flyoverFedAddress = redeemScriptParser.getAddressFromRedeemScript('REGTEST', flyoverRedeemScript); - - const data = await fundAddressAndGetData(btcTxHelper, flyoverFedAddress, AMOUNT_TO_SEND_IN_BTC, fundingAmountInBtc, 'p2sh-segwit'); - const cowAddress = await rskTxHelper.newAccountWithSeed('cow'); - - await mineForPeginRegistration(rskTxHelper, btcTxHelper); - - const coinbaseParams = data.coinbaseParams; - - const registerBtcCoinbaseTransactionMethod = bridge.methods - .registerBtcCoinbaseTransaction( - ensure0x(coinbaseParams.coinbaseTxWithoutWitness.toHex()), - ensure0x(coinbaseParams.blockHash), - ensure0x(coinbaseParams.pmt.hex), - ensure0x(coinbaseParams.witnessMerkleRoot.toString('hex')), - ensure0x(coinbaseParams.witnessReservedValue) - ); - - await sendTxWithCheck( - rskTxHelper, - registerBtcCoinbaseTransactionMethod, - cowAddress, - null - ); - - const registerFastBridgeBtcTransactionMethod = liquidityBridgeContract.methods.registerFastBridgeBtcTransaction( - ensure0x(data.rawTx), - ensure0x(data.pmt), - data.height, - userBtcRefundAddressBytes, - liquidityProviderBtcAddressBytes, - preHash - ); - - const checkFunction = (result) => { - const resultValueFromFirstTx = Number(result); - expect(REFUNDED_USER_ERROR).to.be.equals(resultValueFromFirstTx) - }; - - await sendTxWithCheck( - rskTxHelper, - registerFastBridgeBtcTransactionMethod, - cowAddress, - checkFunction, - ); - - const currentLbcBalance = Number(await rskTxHelper.getBalance(liquidityBridgeContract._address)); - - expect(currentLbcBalance).to.equal(initialLbcBalance); - - const registerFastBridgeBtcTransactionMethod2 = liquidityBridgeContract.methods.registerFastBridgeBtcTransaction( - ensure0x(data.rawTx), - ensure0x(data.pmt), - data.height, - userBtcRefundAddressBytes, - liquidityProviderBtcAddressBytes, - preHash - ); - - const checkFunction2 = result => { - const resultValueFromSecondTx = Number(result); - expect(UNPROCESSABLE_TX_ALREADY_PROCESSED_ERROR).to.be.equals(resultValueFromSecondTx) - }; - - await sendTxWithCheck( - rskTxHelper, - registerFastBridgeBtcTransactionMethod2, - cowAddress, - checkFunction2, - ); - - const finalLbcBalance = Number(await rskTxHelper.getBalance(liquidityBridgeContract._address)); - - expect(finalLbcBalance).to.equal(initialLbcBalance); - - } catch (err) { - throw new CustomError('registerFastBtcTransaction call failure', err); - } - }); -}); diff --git a/tests/01_04_59-post_iris_flyover_surpassing_locking_cap_sending_same_tx_without_witness_twice.js b/tests/01_04_59-post_iris_flyover_surpassing_locking_cap_sending_same_tx_without_witness_twice.js deleted file mode 100644 index d9731d5e..00000000 --- a/tests/01_04_59-post_iris_flyover_surpassing_locking_cap_sending_same_tx_without_witness_twice.js +++ /dev/null @@ -1,113 +0,0 @@ -const expect = require('chai').expect -const redeemScriptParser = require('@rsksmart/powpeg-redeemscript-parser'); -const { UNPROCESSABLE_TX_ALREADY_PROCESSED_ERROR, REFUNDED_USER_ERROR } = require("../lib/flyover-pegin-response-codes"); -const CustomError = require('../lib/CustomError'); -const lbc = require('../lib/liquidity-bridge-contract'); -const { sendTxWithCheck, getFedsPubKeys } = require('../lib/rsk-utils'); -const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); -const { getBtcClient } = require('../lib/btc-client-provider'); -const { ensure0x } = require('../lib/utils'); -const { fundAddressAndGetData } = require('../lib/btc-utils'); -const { getBridge } = require('../lib/bridge-provider'); -const { mineForPeginRegistration } = require('../lib/2wp-utils'); - -describe('Executing registerFastBtcTransaction post hop - surpassing locking cap sending same tx without witness twice', () => { - - let rskTxHelpers; - let rskTxHelper; - let btcTxHelper; - let bridge; - - before(async () => { - rskTxHelpers = getRskTransactionHelpers(); - rskTxHelper = rskTxHelpers[0]; - btcTxHelper = getBtcClient(); - bridge = getBridge(rskTxHelper.getClient()); - - }); - - it(`The first tx should fail due to surpassing the locking cap, and the second tx should fail due to hash already been used`, async () => { - try { - - const liquidityBridgeContract = await lbc.getLiquidityBridgeContract(Runners.hosts.federate.host); - const initialLbcBalance = Number(await rskTxHelper.getBalance(liquidityBridgeContract._address)); - const FEDS_PUBKEYS_LIST = await getFedsPubKeys(bridge); - const userBtcRefundAddress = (await btcTxHelper.generateBtcAddress('legacy')).address; - const userBtcRefundAddressBytes = ensure0x(btcTxHelper.decodeBase58Address(userBtcRefundAddress)); - const liquidityProviderBtcAddress = (await btcTxHelper.generateBtcAddress('legacy')).address; - const liquidityProviderBtcAddressBytes = ensure0x(btcTxHelper.decodeBase58Address(liquidityProviderBtcAddress)); - const preHash = rskTxHelper.getClient().utils.randomHex(32); - - const AMOUNT_TO_SEND_IN_BTC = 2500; - - const derivationHash = await liquidityBridgeContract.methods.getDerivationHash( - preHash, - userBtcRefundAddressBytes, - liquidityProviderBtcAddressBytes - ).call(); - - const fundingAmountInBtc = AMOUNT_TO_SEND_IN_BTC + 1; - const powpegRedeemScript = redeemScriptParser.getPowpegRedeemScript(FEDS_PUBKEYS_LIST); - const flyoverRedeemScript = redeemScriptParser.getFlyoverRedeemScript(powpegRedeemScript, derivationHash.substring(2)); - const flyoverFedAddress = redeemScriptParser.getAddressFromRedeemScript('REGTEST', flyoverRedeemScript); - - const data = await fundAddressAndGetData(btcTxHelper, flyoverFedAddress, AMOUNT_TO_SEND_IN_BTC, fundingAmountInBtc, 'legacy'); - const cowAddress = await rskTxHelper.newAccountWithSeed('cow'); - - await mineForPeginRegistration(rskTxHelper, btcTxHelper); - - const registerFastBridgeBtcTransactionMethod = liquidityBridgeContract.methods.registerFastBridgeBtcTransaction( - ensure0x(data.rawTx), - ensure0x(data.pmt), - data.height, - userBtcRefundAddressBytes, - liquidityProviderBtcAddressBytes, - preHash - ); - - const checkFunction = result => { - const resultValueFromFirstTx = Number(result); - expect(REFUNDED_USER_ERROR).to.be.equals(resultValueFromFirstTx) - }; - - await sendTxWithCheck( - rskTxHelper, - registerFastBridgeBtcTransactionMethod, - cowAddress, - checkFunction, - ); - - const currentLbcBalance = Number(await rskTxHelper.getBalance(liquidityBridgeContract._address)); - - expect(currentLbcBalance).to.equal(initialLbcBalance); - - const registerFastBridgeBtcTransactionMethod2 = liquidityBridgeContract.methods.registerFastBridgeBtcTransaction( - ensure0x(data.rawTx), - ensure0x(data.pmt), - data.height, - userBtcRefundAddressBytes, - liquidityProviderBtcAddressBytes, - preHash - ); - - const checkFunction2 = result => { - const resultValueFromSecondTx = Number(result); - expect(UNPROCESSABLE_TX_ALREADY_PROCESSED_ERROR).to.be.equals(resultValueFromSecondTx) - }; - - await sendTxWithCheck( - rskTxHelper, - registerFastBridgeBtcTransactionMethod2, - cowAddress, - checkFunction2, - ); - - const finalLbcBalance = Number(await rskTxHelper.getBalance(liquidityBridgeContract._address)); - - expect(finalLbcBalance).to.equal(initialLbcBalance); - - } catch (err) { - throw new CustomError('registerFastBtcTransaction call failure', err); - } - }); -}); diff --git a/tests/04_00_05-fastbridge_operation_with_rejection.js b/tests/04_00_05-fastbridge_operation_with_rejection.js deleted file mode 100644 index 1618332a..00000000 --- a/tests/04_00_05-fastbridge_operation_with_rejection.js +++ /dev/null @@ -1,102 +0,0 @@ -const expect = require('chai').expect -const redeemScriptParser = require('@rsksmart/powpeg-redeemscript-parser'); -const btcEthUnitConverter = require('@rsksmart/btc-eth-unit-converter'); -const CustomError = require('../lib/CustomError'); -const lbc = require('../lib/liquidity-bridge-contract'); -const { REFUNDED_USER_ERROR } = require("../lib/flyover-pegin-response-codes"); -const { ERP_PUBKEYS, ERP_CSV_VALUE } = require("../lib/constants/federation-constants") -const { sendTxWithCheck, triggerRelease, getFedsPubKeys } = require('../lib/rsk-utils'); -const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); -const { getBtcClient } = require('../lib/btc-client-provider'); -const { ensure0x, wait } = require('../lib/utils'); -const { fundAddressAndGetData } = require('../lib/btc-utils'); -const { getBridge } = require('../lib/bridge-provider'); -const { mineForPeginRegistration } = require('../lib/2wp-utils'); - -describe('Executing registerFastBtcTransaction after fed change - with release', () => { - - let rskTxHelpers; - let rskTxHelper; - let btcTxHelper; - let bridge; - - before(async () => { - rskTxHelpers = getRskTransactionHelpers(); - rskTxHelper = rskTxHelpers[rskTxHelpers.length - 1]; - btcTxHelper = getBtcClient(); - bridge = getBridge(rskTxHelper.getClient()); - }); - - it('should return funds when calling registerFastBtcTransaction method surpassing locking cap after fed change', async () => { - try { - - const liquidityBridgeContract = await lbc.getLiquidityBridgeContract(Runners.hosts.federates[Runners.hosts.federates.length - 1].host); - const initialLbcBalance = Number(await rskTxHelper.getBalance(liquidityBridgeContract._address)); - const userBtcRefundAddress = (await btcTxHelper.generateBtcAddress('legacy')).address; - const userBtcRefundAddressBytes = ensure0x(btcTxHelper.decodeBase58Address(userBtcRefundAddress)); - const liquidityProviderBtcAddress = (await btcTxHelper.generateBtcAddress('legacy')).address; - const liquidityProviderBtcAddressBytes = ensure0x(btcTxHelper.decodeBase58Address(liquidityProviderBtcAddress)); - const preHash = rskTxHelper.getClient().utils.randomHex(32); - const FEDS_PUBKEYS_LIST = await getFedsPubKeys(bridge); - - const AMOUNT_TO_SEND_IN_BTC = 2500; - - const derivationHash = await liquidityBridgeContract.methods.getDerivationHash( - preHash, - userBtcRefundAddressBytes, - liquidityProviderBtcAddressBytes - ).call(); - - const amountForFlyoverInSatoshis = Number(btcEthUnitConverter.btcToSatoshis(AMOUNT_TO_SEND_IN_BTC)); - - const fundingAmountInBtc = AMOUNT_TO_SEND_IN_BTC + 1; - - const redeemScript = redeemScriptParser.getP2shErpRedeemScript(FEDS_PUBKEYS_LIST, ERP_PUBKEYS, ERP_CSV_VALUE); - - const flyoverRedeemScript = redeemScriptParser.getFlyoverRedeemScript(redeemScript, derivationHash.substring(2)); - const flyoverFedAddress = redeemScriptParser.getAddressFromRedeemScript('REGTEST', flyoverRedeemScript); - const data = await fundAddressAndGetData(btcTxHelper, flyoverFedAddress, AMOUNT_TO_SEND_IN_BTC, fundingAmountInBtc); - - const cowAddress = await rskTxHelper.newAccountWithSeed('cow'); - - await mineForPeginRegistration(rskTxHelper, btcTxHelper); - - const registerFastBridgeBtcTransactionMethod = liquidityBridgeContract.methods.registerFastBridgeBtcTransaction( - ensure0x(data.rawTx), - ensure0x(data.pmt), - data.height, - userBtcRefundAddressBytes, - liquidityProviderBtcAddressBytes, - preHash - ); - - const checkFunction = (result) => { - const resultValue = Number(result); - expect(REFUNDED_USER_ERROR).to.be.equals(resultValue) - }; - - await sendTxWithCheck( - rskTxHelper, - registerFastBridgeBtcTransactionMethod, - cowAddress, - checkFunction - ); - - const currentLbcBalance = Number(await rskTxHelper.getBalance(liquidityBridgeContract._address)); - expect(currentLbcBalance).to.equal(initialLbcBalance); - - // assert the funds are returned to the corresponding refund address when the result is REFUNDED_USER_ERROR or REFUNDED_LP_ERROR - await triggerRelease(rskTxHelpers, btcTxHelper); - await wait(500); - - const finalBalanceInSatoshis = Number(btcEthUnitConverter.btcToSatoshis(await btcTxHelper.getAddressBalance(userBtcRefundAddress))); - const difference = amountForFlyoverInSatoshis - finalBalanceInSatoshis; - const FEE_IN_SATOSHIS = Number(btcEthUnitConverter.btcToSatoshis(0.001)); - - expect(difference).to.be.at.most(FEE_IN_SATOSHIS * 2); - - } catch(e) { - throw new CustomError('registerFastBridgeBtcTransaction call failure', e); - } - }); -}); From a33a00b43f27c74fc2c648355f04ae2039a0f762 Mon Sep 17 00:00:00 2001 From: jeremy-then Date: Fri, 29 Nov 2024 14:39:22 -0400 Subject: [PATCH 2/2] Removes 01_05_51-post_hop_pegout_batching_methods.js file. --- ..._05_51-post_hop_pegout_batching_methods.js | 43 ------------------- 1 file changed, 43 deletions(-) delete mode 100644 tests/01_05_51-post_hop_pegout_batching_methods.js diff --git a/tests/01_05_51-post_hop_pegout_batching_methods.js b/tests/01_05_51-post_hop_pegout_batching_methods.js deleted file mode 100644 index ee236163..00000000 --- a/tests/01_05_51-post_hop_pegout_batching_methods.js +++ /dev/null @@ -1,43 +0,0 @@ -const chai = require('chai'); -chai.use(require('chai-as-promised')); -const expect = chai.expect; - -const peglib = require('peglib'); -const rsk = peglib.rsk; -const CustomError = require('../lib/CustomError'); - -describe('Pegout Batching - Calling new bridge methods after hop400 activation', function () { - - before(() => { - rskClient = rsk.getClient(Runners.hosts.federate.host); - }); - - it('should return 0 when calling getEstimatedFeesForNextPegOutEvent method', async () => { - try { - const estimatedFees = await rskClient.rsk.bridge.methods.getEstimatedFeesForNextPegOutEvent().call(); - expect(estimatedFees).to.be.equal("0"); - } catch (err) { - throw new CustomError('getEstimatedFeesForNextPegOutEvent call failure', err); - } - }) - - - it('should return 0 when calling getNextPegoutCreationBlockNumber method', async () => { - try { - const blockNumber = await rskClient.rsk.bridge.methods.getNextPegoutCreationBlockNumber().call(); - expect(blockNumber).to.be.equal("0"); - } catch (err) { - throw new CustomError('getNextPegoutCreationBlockNumber call failure', err); - } - }) - - it('should return 0 when calling getQueuedPegoutsCount method', async () => { - try { - const count = await rskClient.rsk.bridge.methods.getQueuedPegoutsCount().call(); - expect(count).to.be.equal("0"); - } catch (err) { - throw new CustomError('getQueuedPegoutsCount call failure', err); - } - }) - -});