diff --git a/lib/assertions/2wp.js b/lib/assertions/2wp.js index 614d8435..ac525d68 100644 --- a/lib/assertions/2wp.js +++ b/lib/assertions/2wp.js @@ -118,34 +118,10 @@ const assertCallToPegoutBatchingBridgeMethods = (rskClient) => async (expectedCo expect(Number(nextPegoutCreationBlockNumber)).to.equal(expectedNextPegoutCreationBlockNumber); } -const assertRejectedPeginEvent = async (rejectedPeginTx, expectedRejectionReason, expectedPeginBtcHash, expectedRefundAmountInSatoshis) => { - - const rejectedPeginEvent = rejectedPeginTx.events[0]; - expect(rejectedPeginEvent).to.not.be.undefined; - expect(rejectedPeginEvent.arguments.btcTxHash).to.equal(expectedPeginBtcHash); - expect(rejectedPeginEvent.arguments.reason).to.equal(expectedRejectionReason); - - const releaseRequestedEvent = rejectedPeginTx.events[1]; - expect(releaseRequestedEvent).to.not.be.undefined; - - // TODO: uncomment when RSKIP419 is active - // const isLovell700AlreadyActive = await Runners.common.forks.lovell700.isAlreadyActive(); - // if(!isLovell700AlreadyActive) { - // return; - // } - // const pegoutTransactionCreatedEvent = rejectedPeginTx.events[2]; - // expect(pegoutTransactionCreatedEvent).to.not.be.undefined; - // const encodedUtxoOutpointValues = Buffer.from(removePrefix0x(pegoutTransactionCreatedEvent.arguments.utxoOutpointValues), 'hex'); - // const outpointValues = decodeOutpointValues(encodedUtxoOutpointValues); - // expect(outpointValues.every(value => value in federationUtxoValues)).to.be.true; - -} - module.exports = { with: (btcClient, rskClient, pegClient) => ({ assertBitcoinBalance: assertBitcoinBalance(btcClient, rskClient, pegClient), assertLock: assertLock(btcClient, rskClient, pegClient), }), assertCallToPegoutBatchingBridgeMethods, - assertRejectedPeginEvent, }; diff --git a/lib/bridge-provider.js b/lib/bridge-provider.js index 040fe985..c73d1d64 100644 --- a/lib/bridge-provider.js +++ b/lib/bridge-provider.js @@ -1,4 +1,3 @@ -const precompiledAbisArrowhead = require("@rsksmart/rsk-precompiled-abis"); const precompiledAbisLovell = require("@rsksmart/rsk-precompiled-abis-lovell"); const Web3 = require("web3"); @@ -8,14 +7,7 @@ const Web3 = require("web3"); * @returns {Bridge} */ const getBridge = async (rskClient) => { - - const isLovellActive = await Runners.common.forks.lovell700.isAlreadyActive(); - - if(isLovellActive) { - return new rskClient.eth.Contract(precompiledAbisLovell.bridge.abi, precompiledAbisLovell.bridge.address); - } - - return new rskClient.eth.Contract(precompiledAbisArrowhead.bridge.abi, precompiledAbisArrowhead.bridge.address); + return new rskClient.eth.Contract(precompiledAbisLovell.bridge.abi, precompiledAbisLovell.bridge.address); }; /** @@ -23,11 +15,7 @@ const getBridge = async (rskClient) => { * @returns {json} The bridge abi in json format */ const getBridgeAbi = async () => { - const isLovellActive = await Runners.common.forks.lovell700.isAlreadyActive(); - if(isLovellActive) { - return precompiledAbisLovell.bridge.abi; - } - return precompiledAbisArrowhead.bridge.abi; + return precompiledAbisLovell.bridge.abi; }; module.exports = { diff --git a/lib/tests/2wp.js b/lib/tests/2wp.js index 1230ab4f..4802fd3b 100644 --- a/lib/tests/2wp.js +++ b/lib/tests/2wp.js @@ -463,14 +463,8 @@ const execute = (description, getRskHost) => { // To ensure no refund is made, let's try to push any possible refund pegout. await triggerRelease(rskTxHelpers, btcTxHelper); - - const isLovellActive = await Runners.common.forks.lovell700.isAlreadyActive(); - if(isLovellActive) { - await assertBtcPeginTxHashProcessed(btcPeginTxHash); - } else { - await assertPeginTxHashNotProcessed(btcPeginTxHash); - } + await assertBtcPeginTxHashProcessed(btcPeginTxHash); // Two events are emitted in this scenario: rejected_pegin and unrefundable_pegin. await assertExpectedRejectedPeginEventIsEmitted(btcPeginTxHash, blockNumberBeforePegin, PEGIN_REJECTION_REASONS.LEGACY_PEGIN_UNDETERMINED_SENDER); @@ -769,8 +763,7 @@ const execute = (description, getRskHost) => { // Assert - const isLovellActive = await Runners.common.forks.lovell700.isAlreadyActive(); - const expectedPegoutValue = isLovellActive ? satoshisToWeis(pegoutValueInSatoshis) : pegoutValueInSatoshis; + const expectedPegoutValue = satoshisToWeis(pegoutValueInSatoshis); await assertExpectedReleaseRequestRejectedEventIsEmitted(senderRecipientInfo.rskRecipientRskAddressInfo.address, expectedPegoutValue, PEGOUT_REJECTION_REASONS.LOW_AMOUNT); await assert2wpBalanceIsUnchanged(initial2wpBalances); @@ -813,8 +806,7 @@ const execute = (description, getRskHost) => { // Assert - const isLovellActive = await Runners.common.forks.lovell700.isAlreadyActive(); - const expectedPegoutValue = isLovellActive ? satoshisToWeis(pegoutValueInSatoshis) : pegoutValueInSatoshis; + const expectedPegoutValue = satoshisToWeis(pegoutValueInSatoshis); await assertExpectedReleaseRequestRejectedEventIsEmitted(senderRecipientInfo.rskRecipientRskAddressInfo.address, expectedPegoutValue, PEGOUT_REJECTION_REASONS.FEE_ABOVE_VALUE); await assert2wpBalanceIsUnchanged(initial2wpBalances); @@ -853,8 +845,7 @@ const execute = (description, getRskHost) => { // Assert - const isLovellActive = await Runners.common.forks.lovell700.isAlreadyActive(); - const expectedPegoutValue = isLovellActive ? satoshisToWeis(pegoutValueInSatoshis) : pegoutValueInSatoshis; + const expectedPegoutValue = satoshisToWeis(pegoutValueInSatoshis); const contractAddressChecksummed = rskTxHelper.getClient().utils.toChecksumAddress(ensure0x(callReleaseBtcContract.options.address)); const expectedEvent = createExpectedReleaseRequestRejectedEvent(contractAddressChecksummed, expectedPegoutValue, PEGOUT_REJECTION_REASONS.CALLER_CONTRACT); @@ -994,24 +985,22 @@ const execute = (description, getRskHost) => { const blockNumberAfterPegoutRelease = await rskTxHelper.getBlockNumber(); const pegoutsEvents = await getPegoutEventsInBlockRange(rskTxHelper, pegoutTransaction1.blockNumber, blockNumberAfterPegoutRelease); - const isLovellActive = await Runners.common.forks.lovell700.isAlreadyActive(); - // The release_request_received event of the first pegout request const rskSender1Address = rskTxHelper.getClient().utils.toChecksumAddress(ensure0x(senderRecipientInfo1.rskRecipientRskAddressInfo.address)); const releaseRequestReceivedEvent1 = pegoutsEvents.find(event => event.arguments.sender === rskSender1Address); - const expectedPegoutValue1 = isLovellActive ? satoshisToWeis(pegout1ValueInSatoshis) : pegout1ValueInSatoshis; + const expectedPegoutValue1 = satoshisToWeis(pegout1ValueInSatoshis); assertReleaseRequestReceivedEvent(releaseRequestReceivedEvent1, rskSender1Address, senderRecipientInfo1.btcSenderAddressInfo.address, expectedPegoutValue1); // The release_request_received event of the second pegout request const rskSender2Address = rskTxHelper.getClient().utils.toChecksumAddress(ensure0x(senderRecipientInfo2.rskRecipientRskAddressInfo.address)); const releaseRequestReceivedEvent2 = pegoutsEvents.find(event => event.arguments.sender === rskSender2Address); - const expectedPegoutValue2 = isLovellActive ? satoshisToWeis(pegout2ValueInSatoshis) : pegout2ValueInSatoshis; + const expectedPegoutValue2 = satoshisToWeis(pegout2ValueInSatoshis); assertReleaseRequestReceivedEvent(releaseRequestReceivedEvent2, rskSender2Address, senderRecipientInfo2.btcSenderAddressInfo.address, expectedPegoutValue2); // The release_request_received event of the third pegout request const rskSender3Address = rskTxHelper.getClient().utils.toChecksumAddress(ensure0x(senderRecipientInfo3.rskRecipientRskAddressInfo.address)); const releaseRequestReceivedEvent3 = pegoutsEvents.find(event => event.arguments.sender === rskSender3Address); - const expectedPegoutValue3 = isLovellActive ? satoshisToWeis(pegout3ValueInSatoshis) : pegout3ValueInSatoshis; + const expectedPegoutValue3 = satoshisToWeis(pegout3ValueInSatoshis); assertReleaseRequestReceivedEvent(releaseRequestReceivedEvent3, rskSender3Address, senderRecipientInfo3.btcSenderAddressInfo.address, expectedPegoutValue3); const pegoutWaitingForConfirmationWhenPegoutWasCreated = bridgeStateAfterPegoutCreation.pegoutsWaitingForConfirmations[0]; @@ -1022,22 +1011,19 @@ const execute = (description, getRskHost) => { const releaseRequestedEvent = pegoutsEvents[3]; assertReleaseRequestedEvent(releaseRequestedEvent, pegoutCreationRskTransactionHash, btcTransaction.getId(), totalPegoutValueInSatoshis); - if(isLovellActive) { - // pegout_transaction_created event - const pegoutTransactionCreatedEvent = pegoutsEvents[4]; - assertPegoutTransactionCreatedEvent(pegoutTransactionCreatedEvent, btcTransaction, bridgeStateBeforePegoutCreation); - } - + const pegoutTransactionCreatedEvent = pegoutsEvents[4]; + assertPegoutTransactionCreatedEvent(pegoutTransactionCreatedEvent, btcTransaction, bridgeStateBeforePegoutCreation); + // batch_pegout_created event - const batchPegoutCreatedEvent = pegoutsEvents[isLovellActive ? 5 : 4]; + const batchPegoutCreatedEvent = pegoutsEvents[5]; assertBatchPegoutCreatedEvent(batchPegoutCreatedEvent, btcTransaction.getId(), [pegoutTransaction1.transactionHash, pegoutTransaction2.transactionHash, pegoutTransaction3.transactionHash]); // pegout_confirmed event - const pegoutConfirmedEvent = pegoutsEvents[isLovellActive ? 6 : 5]; + const pegoutConfirmedEvent = pegoutsEvents[6]; assertPegoutConfirmedEvent(pegoutConfirmedEvent, btcTransaction.getId(), pegoutWaitingForConfirmationWhenPegoutWasCreated.pegoutCreationBlockNumber); // add_signature events - const addSignatureEvents = pegoutsEvents.slice(isLovellActive ? 7 : 6, pegoutsEvents.length - 1); + const addSignatureEvents = pegoutsEvents.slice(7, pegoutsEvents.length - 1); assertAddSignatureEvents(addSignatureEvents, releaseRequestedEvent); // release_btc event @@ -1218,8 +1204,7 @@ const assertSuccessfulPegoutEventsAreEmitted = async (pegoutsEvents, pegoutReque // release_request_received event const releaseRequestReceivedEvent = pegoutsEvents[0]; - const isLovellActive = await Runners.common.forks.lovell700.isAlreadyActive(); - const expectedPegoutValue = isLovellActive ? (pegoutValueInWeis || satoshisToWeis(pegoutValueInSatoshis)) : pegoutValueInSatoshis; + const expectedPegoutValue = pegoutValueInWeis || satoshisToWeis(pegoutValueInSatoshis); assertReleaseRequestReceivedEvent(releaseRequestReceivedEvent, rskSenderAddress, senderRecipientInfo.btcSenderAddressInfo.address, expectedPegoutValue); // release_requested event @@ -1227,21 +1212,18 @@ const assertSuccessfulPegoutEventsAreEmitted = async (pegoutsEvents, pegoutReque const releaseRequestedEvent = pegoutsEvents[1]; assertReleaseRequestedEvent(releaseRequestedEvent, pegoutCreationRskTransactionHash, btcTransaction.getId(), pegoutValueInSatoshis); - if(isLovellActive) { - // pegout_transaction_created event - const pegoutTransactionCreatedEvent = pegoutsEvents[2]; - assertPegoutTransactionCreatedEvent(pegoutTransactionCreatedEvent, btcTransaction, bridgeStateBeforePegoutCreation); - } + const pegoutTransactionCreatedEvent = pegoutsEvents[2]; + assertPegoutTransactionCreatedEvent(pegoutTransactionCreatedEvent, btcTransaction, bridgeStateBeforePegoutCreation); // batch_pegout_created event - const batchPegoutCreatedEvent = pegoutsEvents[isLovellActive ? 3 : 2]; + const batchPegoutCreatedEvent = pegoutsEvents[3]; assertBatchPegoutCreatedEvent(batchPegoutCreatedEvent, btcTransaction.getId(), [pegoutRequestReceivedTransactionHash]); // pegout_confirmed event - const pegoutConfirmedEvent = pegoutsEvents[isLovellActive ? 4 : 3]; + const pegoutConfirmedEvent = pegoutsEvents[4]; assertPegoutConfirmedEvent(pegoutConfirmedEvent, btcTransaction.getId(), pegoutWaitingForConfirmationWhenPegoutWasCreated.pegoutCreationBlockNumber); - const addSignatureEvents = pegoutsEvents.slice(isLovellActive ? 5 : 4, pegoutsEvents.length - 1); + const addSignatureEvents = pegoutsEvents.slice(5, pegoutsEvents.length - 1); assertAddSignatureEvents(addSignatureEvents, releaseRequestedEvent); // Final event, release_btc diff --git a/lib/tests/activate-fork b/lib/tests/activate-fork.js similarity index 90% rename from lib/tests/activate-fork rename to lib/tests/activate-fork.js index 462d6631..e13f0941 100644 --- a/lib/tests/activate-fork +++ b/lib/tests/activate-fork.js @@ -5,7 +5,8 @@ const { getRskTransactionHelpers } = require('../rsk-tx-helper-provider'); const execute = (fork) => { - describe(`Activate ${fork.name} fork`, () => { + // Unskip when there is a new fork to be tested pre and post. + describe.skip(`Activate ${fork.name} fork`, () => { it(`should mine blocks until reach ${fork.activationHeight}th block in order to activate the fork`, async () => { try { diff --git a/lib/tests/change-federation.js b/lib/tests/change-federation.js index a7ee6b7f..81aa2791 100644 --- a/lib/tests/change-federation.js +++ b/lib/tests/change-federation.js @@ -91,7 +91,6 @@ const execute = (description, newFederationConfig) => { let newFederationPublicKeys; let btcTxHelper; let minimumPeginValueInSatoshis; - let isLovellActive; let expectedFlyoverAddress; let svpSpendBtcTransaction; let proposedFederationInfo; @@ -153,8 +152,6 @@ const execute = (description, newFederationConfig) => { await ensurePeginIsRegistered(rskTxHelper, btcPeginTxHash); } - isLovellActive = await Runners.common.forks.lovell700.isAlreadyActive(); - }); it('should create a pending federation', async () => { @@ -260,10 +257,6 @@ const execute = (description, newFederationConfig) => { it('should create the proposed federation', async function () { - if(!isLovellActive) { - return this.skip(); - } - proposedFederationInfo = await getProposedFederationInfo(bridge); expect(proposedFederationInfo.size).to.be.equal(newFederationPublicKeys.length, 'The proposed federation size should be the expected one.'); @@ -276,10 +269,6 @@ const execute = (description, newFederationConfig) => { }); it('should not have created svp fund transaction and there should not be any SVP values in storage yet', async function () { - - if(!isLovellActive) { - return this.skip(); - } const bridgeState = await getBridgeState(rskTxHelper.getClient()); @@ -292,10 +281,6 @@ const execute = (description, newFederationConfig) => { it('should create the SVP Fund transaction on the next updateCollections call', async function () { - if(!isLovellActive) { - return this.skip(); - } - // Act const initialBridgeState = await getBridgeState(rskTxHelper.getClient()); @@ -367,10 +352,6 @@ const execute = (description, newFederationConfig) => { it('should release and register the svp fund transaction and create the svp spend transaction', async function () { - if(!isLovellActive) { - return this.skip(); - } - // Mining to have enough confirmations for the SVP fund transaction and updating the bridge. await rskUtils.mineAndSync(rskTxHelpers, 3); await rskUtils.waitAndUpdateBridge(rskTxHelper); @@ -400,10 +381,6 @@ const execute = (description, newFederationConfig) => { it('should register the SVP Spend transaction and finish the SVP process', async function () { - if(!isLovellActive) { - return this.skip(); - } - const blockNumberBeforeUpdateCollections = await rskTxHelper.getBlockNumber(); const expectedCountOfSignatures = Math.floor(newFederationPublicKeys.length / 2) + 1; @@ -467,9 +444,7 @@ const execute = (description, newFederationConfig) => { expect(activeFederationAddressInfo.creationBlockNumber).to.be.equal(commitFederationCreationBlockNumber, 'The new active federation creation block number should be the expected one.'); expect(activeFederationAddressInfo.size).to.be.equal(newFederationPublicKeys.length, 'The new active federation size should be the expected one.'); - if(isLovellActive) { - expect(activeFederationAddressInfo.creationTime).to.be.equal(proposedFederationInfo.creationTime, 'The new active federation creation time should be the same as the proposed federation creation time.'); - } + expect(activeFederationAddressInfo.creationTime).to.be.equal(proposedFederationInfo.creationTime, 'The new active federation creation time should be the same as the proposed federation creation time.'); const retiringFederationSize = Number(await bridge.methods.getRetiringFederationSize().call()); expect(retiringFederationSize).to.be.equal(initialFederationPublicKeys.length, 'The retiring federation size should be the same as the initial federation size.'); diff --git a/test.js b/test.js index aaea266c..c83b837d 100644 --- a/test.js +++ b/test.js @@ -94,7 +94,7 @@ global.Runners = { fingerroot500: createForkObject('fingerroot500', 1), arrowhead600: createForkObject('arrowhead600', 1), arrowhead631: createForkObject('arrowhead631', 1), - lovell700: createForkObject('lovell700', 1750), + lovell700: createForkObject('lovell700', 1), }, additionalFederationAddresses: [] } diff --git a/tests/03_00_01-powpeg_redeem_script.js b/tests/00_00_05-powpeg_redeem_script.js similarity index 86% rename from tests/03_00_01-powpeg_redeem_script.js rename to tests/00_00_05-powpeg_redeem_script.js index 9036c08b..94b0a51c 100644 --- a/tests/03_00_01-powpeg_redeem_script.js +++ b/tests/00_00_05-powpeg_redeem_script.js @@ -11,8 +11,7 @@ const { GENESIS_FEDERATION_REDEEM_SCRIPT, } = require('../lib/constants/federation-constants'); -// No need for this test now since it is checking the genesis regtest fed address but we changed the federation at the start of the test. -describe.skip('Calling getActivePowpegRedeemScript method after last fork before fedchange', function() { +describe('Calling getActivePowpegRedeemScript method before federation change', function() { let rskTxHelpers; let rskTxHelper; let bridge; diff --git a/tests/04_00_01-key_control_initial_federation.js b/tests/00_00_06-key_control_initial_federation.js similarity index 75% rename from tests/04_00_01-key_control_initial_federation.js rename to tests/00_00_06-key_control_initial_federation.js index bd583dce..a0b273c3 100644 --- a/tests/04_00_01-key_control_initial_federation.js +++ b/tests/00_00_06-key_control_initial_federation.js @@ -1,9 +1,10 @@ const fedAssertions = require('../lib/assertions/fed'); -var fedAssert; +let fedAssert; -const INITIAL_FEDERATION_SIZE = 5; +const INITIAL_FEDERATION_SIZE = 3; +// TODO: refactor this test to stop using lib/assertions/fed library since it uses the peglib library describe('Federate nodes key control - initial federation', function() { before(() => { fedAssert = fedAssertions.with(Runners.hosts.federates); diff --git a/tests/00_00_05-change-federation.js b/tests/00_00_07-change-federation.js similarity index 100% rename from tests/00_00_05-change-federation.js rename to tests/00_00_07-change-federation.js diff --git a/tests/04_00_03-key_control_second_federation.js b/tests/00_00_08-key_control_second_federation.js similarity index 75% rename from tests/04_00_03-key_control_second_federation.js rename to tests/00_00_08-key_control_second_federation.js index 6428fc88..eb81b5c4 100644 --- a/tests/04_00_03-key_control_second_federation.js +++ b/tests/00_00_08-key_control_second_federation.js @@ -1,13 +1,15 @@ const rsk = require('peglib').rsk; const fedAssertions = require('../lib/assertions/fed'); -var fedAssert; +let fedAssert; -const INITIAL_FEDERATION_SIZE = 5; +const INITIAL_FEDERATION_SIZE = 3; const INITIAL_FEDERATOR_BALANCE_IN_BTC = 1; +// TODO: refactor this test to get rid of the peglib library describe('Federate nodes key control - second federation', function() { before(() => { + console.log('Runners.hosts.federates.length', Runners.hosts.federates.length); fedAssert = fedAssertions.with(Runners.hosts.federates); }); diff --git a/tests/01_01_52-post_orchid_lock_whitelist_fork.js b/tests/01_01_52-lock_whitelist_fork.js similarity index 98% rename from tests/01_01_52-post_orchid_lock_whitelist_fork.js rename to tests/01_01_52-lock_whitelist_fork.js index 330aa1d8..fb809dcf 100644 --- a/tests/01_01_52-post_orchid_lock_whitelist_fork.js +++ b/tests/01_01_52-lock_whitelist_fork.js @@ -17,7 +17,7 @@ let rskTxHelper; let rskTxHelpers; let bridge; -describe('RFS-170 test after fork', () => { +describe('Whitelist methods tests', () => { before(async () => { btcTxHelper = getBtcClient(); rskTxHelpers = getRskTransactionHelpers(); diff --git a/tests/01_02_51-post_wasabi_fed_pubkeys_fork.js b/tests/01_02_51-fed_pubkeys_fork.js similarity index 96% rename from tests/01_02_51-post_wasabi_fed_pubkeys_fork.js rename to tests/01_02_51-fed_pubkeys_fork.js index ad2a95ef..196123a1 100644 --- a/tests/01_02_51-post_wasabi_fed_pubkeys_fork.js +++ b/tests/01_02_51-fed_pubkeys_fork.js @@ -12,7 +12,7 @@ let rskTxHelper; let fedChangeAddress; let bridge; -describe('Multiple federation member keys test after fork', () => { +describe('Bridge federator methods tests', () => { before(async () => { rskTxHelper = getRskTransactionHelper(); diff --git a/tests/01_03_54-post-papyrus_coinbase_information.js b/tests/01_03_54-coinbase_information.js similarity index 91% rename from tests/01_03_54-post-papyrus_coinbase_information.js rename to tests/01_03_54-coinbase_information.js index d1ccb70d..27d306ea 100644 --- a/tests/01_03_54-post-papyrus_coinbase_information.js +++ b/tests/01_03_54-coinbase_information.js @@ -4,15 +4,13 @@ const rskUtils = require('../lib/rsk-utils'); const { wait, ensure0x, retryWithCheck } = require('../lib/utils'); const CustomError = require('../lib/CustomError'); const { getBridge } = require('../lib/bridge-provider'); -const { getBtcClient } = require('../lib//btc-client-provider'); +const { getBtcClient } = require('../lib/btc-client-provider'); const btcEthUnitConverter = require('@rsksmart/btc-eth-unit-converter'); const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); -const { getLogger } = require('../logger'); -describe('Calling coinbase information methods after papyrus', () => { +describe('Calling coinbase information methods', () => { - const logger = getLogger(); let btcClient; let rskTxHelper; let rskTxHelpers; @@ -23,7 +21,7 @@ describe('Calling coinbase information methods after papyrus', () => { rskTxHelper = rskTxHelpers[0]; }); - it('should return true when calling hasBtcBlockCoinbaseTransactionInformation method', async () => { + it('should work when calling Bridge coinbase related methods', async () => { try { const rskTxSenderAddress = await rskTxHelper.newAccountWithSeed('test'); diff --git a/tests/01_04_51-post_iris_register_flyover_btc_transaction.js b/tests/01_04_51-register_flyover_btc_transaction.js similarity index 94% rename from tests/01_04_51-post_iris_register_flyover_btc_transaction.js rename to tests/01_04_51-register_flyover_btc_transaction.js index 020a5681..cb0e42bf 100644 --- a/tests/01_04_51-post_iris_register_flyover_btc_transaction.js +++ b/tests/01_04_51-register_flyover_btc_transaction.js @@ -16,7 +16,8 @@ let rskTxHelper; let btcTxHelper; let bridge; -describe.skip('Calling registerFastBtcTransaction after iris', () => { +// TODO: Fails with 'Internal AssertionError: expected -304 to equal 20000000000000000000' error. Pending to analyze. +describe.skip('Calling registerFastBridgeBtcTransaction after iris', () => { before(async () => { rskTxHelpers = getRskTransactionHelpers(); @@ -25,7 +26,7 @@ describe.skip('Calling registerFastBtcTransaction after iris', () => { bridge = await getBridge(rskTxHelper.getClient(), Runners.common.forks.iris300.name); }); - it('should return value transferred when calling registerFastBtcTransaction method', async () => { + it('should return value transferred when calling registerFastBridgeBtcTransaction method', async () => { try { diff --git a/tests/01_04_52-post_iris_user_call.js b/tests/01_04_52-user_call.js similarity index 89% rename from tests/01_04_52-post_iris_user_call.js rename to tests/01_04_52-user_call.js index 5f24fe77..c8d1bb23 100644 --- a/tests/01_04_52-post_iris_user_call.js +++ b/tests/01_04_52-user_call.js @@ -9,7 +9,10 @@ const CustomError = require('../lib/CustomError'); const NETWORK = bitcoin.networks.testnet; -describe('Calling registerFastBridgeBtcTransaction after iris', function() { +describe('Calling registerFastBridgeBtcTransaction', function() { + let rskClient; + let btcClient; + let pegClient; before(() => { rskClient = rsk.getClient(Runners.hosts.federate.host); @@ -20,7 +23,6 @@ describe('Calling registerFastBridgeBtcTransaction after iris', function() { NETWORK ); pegClient = pegUtils.using(btcClient, rskClient); - utils = rskUtilsLegacy.with(btcClient, rskClient, pegClient); }); it('should return error when user calling registerFastBridgeBtcTransaction method', async () => { @@ -33,8 +35,7 @@ describe('Calling registerFastBridgeBtcTransaction after iris', function() { let addressBtcBytes = libUtils.ensure0x(bitcoin.addresses.decodeBase58Address(addressBtc)); let callResult = await rskClient.rsk.bridge.methods.registerFastBridgeBtcTransaction("0x", 1, stringHex, stringHex, addressBtcBytes, randomAddress, addressBtcBytes, false).call(); expect(Number(callResult)).to.equal(errorUserCalls); - } - catch (err) { + } catch (err) { throw new CustomError('registerFastBridgeBtcTransaction call failure', err); } }) diff --git a/tests/01_04_54-call_receive_headers.js b/tests/01_04_54-call_receive_headers.js new file mode 100644 index 00000000..e79df467 --- /dev/null +++ b/tests/01_04_54-call_receive_headers.js @@ -0,0 +1,3 @@ +const receiveHeadersTests = require('../lib/tests/call_receive_headers'); + +receiveHeadersTests.execute('Calling receiveHeaders', () => Runners.hosts.federate.host); diff --git a/tests/01_04_54-post_iris_call_receive_headers.js b/tests/01_04_54-post_iris_call_receive_headers.js deleted file mode 100644 index 0e511f44..00000000 --- a/tests/01_04_54-post_iris_call_receive_headers.js +++ /dev/null @@ -1,3 +0,0 @@ -const receiveHeadersTests = require('../lib/tests/call_receive_headers'); - -receiveHeadersTests.execute('Calling receiveHeaders after iris300', () => Runners.hosts.federate.host); diff --git a/tests/01_04_55-call_receive_header.js b/tests/01_04_55-call_receive_header.js new file mode 100644 index 00000000..9c7d04b4 --- /dev/null +++ b/tests/01_04_55-call_receive_header.js @@ -0,0 +1,3 @@ +const receiveHeaderTests = require('../lib/tests/call_receive_header'); + +receiveHeaderTests.execute('Calling receiveHeader'); diff --git a/tests/01_04_55-post_iris_call_receive_header.js b/tests/01_04_55-post_iris_call_receive_header.js deleted file mode 100644 index b92b4cf8..00000000 --- a/tests/01_04_55-post_iris_call_receive_header.js +++ /dev/null @@ -1,3 +0,0 @@ -const receiveHeaderTests = require('../lib/tests/call_receive_header'); - -receiveHeaderTests.execute('Calling receiveHeader after iris300', () => Runners.hosts.federate.host); diff --git a/tests/01_04_56-post_iris_flyover_sending_same_tx_without_witness_twice.js b/tests/01_04_56-flyover_sending_same_tx_without_witness_twice.js similarity index 91% rename from tests/01_04_56-post_iris_flyover_sending_same_tx_without_witness_twice.js rename to tests/01_04_56-flyover_sending_same_tx_without_witness_twice.js index 4e4404c6..38a2ac22 100644 --- a/tests/01_04_56-post_iris_flyover_sending_same_tx_without_witness_twice.js +++ b/tests/01_04_56-flyover_sending_same_tx_without_witness_twice.js @@ -12,7 +12,8 @@ const { fundAddressAndGetData } = require('../lib/btc-utils'); const { getBridge } = require('../lib/bridge-provider'); const { mineForPeginRegistration } = require('../lib/2wp-utils'); -describe.skip('Executing registerFastBtcTransaction post hop - sending same tx without witness twice', () => { +// TODO: Fails with 'Internal AssertionError: expected 40000000000000000 to equal -304' error. Pending to analyze. +describe.skip('Executing registerFastBridgeBtcTransaction post hop - sending same tx without witness twice', () => { let rskTxHelpers; let rskTxHelper; @@ -26,7 +27,7 @@ describe.skip('Executing registerFastBtcTransaction post hop - sending same tx w bridge = await getBridge(rskTxHelper.getClient()); }); - it(`should execute first tx successfully and fail executing second tx due to hash already used when calling registerFastBtcTransaction sending same tx twice`, async () => { + it(`should execute first tx successfully and fail executing second tx due to hash already used when calling registerFastBridgeBtcTransaction sending same tx twice`, async () => { try { const liquidityBridgeContract = await lbc.getLiquidityBridgeContract(Runners.hosts.federate.host); @@ -112,7 +113,7 @@ describe.skip('Executing registerFastBtcTransaction post hop - sending same tx w expect(finalLbcBalance).to.equal(finalBalance); } catch (err) { - throw new CustomError('registerFastBtcTransaction call failure', err); + throw new CustomError('registerFastBridgeBtcTransaction call failure', err); } }); diff --git a/tests/01_04_57-post_iris_flyover_sending_same_tx_with_witness_twice.js b/tests/01_04_57-flyover_sending_same_tx_with_witness_twice.js similarity index 92% rename from tests/01_04_57-post_iris_flyover_sending_same_tx_with_witness_twice.js rename to tests/01_04_57-flyover_sending_same_tx_with_witness_twice.js index 738e0500..5611b5bd 100644 --- a/tests/01_04_57-post_iris_flyover_sending_same_tx_with_witness_twice.js +++ b/tests/01_04_57-flyover_sending_same_tx_with_witness_twice.js @@ -12,7 +12,8 @@ const { fundAddressAndGetData } = require('../lib/btc-utils'); const { getBridge } = require('../lib/bridge-provider'); const { mineForPeginRegistration } = require('../lib/2wp-utils'); -describe.skip('Executing registerFastBtcTransaction post hop - sending same tx with witness twice', () => { +// TODO: Fails with 'Internal AssertionError: expected 40000000000000000 to equal -304' error. Pending to analyze. +describe.skip('Executing registerFastBridgeBtcTransaction post hop - sending same tx with witness twice', () => { let rskTxHelpers; let rskTxHelper; @@ -26,7 +27,7 @@ describe.skip('Executing registerFastBtcTransaction post hop - sending same tx w bridge = await getBridge(rskTxHelper.getClient()); }); - it(`should execute first tx successfully and fail executing second tx due to hash already used when calling registerFastBtcTransaction sending same tx twice`, async () => { + it(`should execute first tx successfully and fail executing second tx due to hash already used when calling registerFastBridgeBtcTransaction sending same tx twice`, async () => { try { const liquidityBridgeContract = await lbc.getLiquidityBridgeContract(Runners.hosts.federate.host); @@ -129,7 +130,7 @@ describe.skip('Executing registerFastBtcTransaction post hop - sending same tx w expect(finalLbcBalance).to.equal(finalBalance); } catch (err) { - throw new CustomError('registerFastBtcTransaction call failure', err); + throw new CustomError('registerFastBridgeBtcTransaction call failure', err); } }); }); diff --git a/tests/01_05_52-post_hop_pegout_batching_first_requests.js b/tests/01_05_52-pegout_batching_first_requests.js similarity index 95% rename from tests/01_05_52-post_hop_pegout_batching_first_requests.js rename to tests/01_05_52-pegout_batching_first_requests.js index 97ae469e..dc6c8556 100644 --- a/tests/01_05_52-post_hop_pegout_batching_first_requests.js +++ b/tests/01_05_52-pegout_batching_first_requests.js @@ -4,13 +4,18 @@ const CustomError = require('../lib/CustomError'); const _2wpUtilsLegacy = require('../lib/2wp-utils-legacy'); const pegAssertions = require('../lib/assertions/2wp'); -let pegoutCount = 0; // TODO: Refactor these tests // Some tests fail after running all tests with all forks active from scratch. // More analysis need to be done. Also, these tests use legacy functions. We need to refactor them. describe.skip('Pegout Batching - New Pegout Requests Then Call new bridge methods', function () { + let pegoutCount = 0; + let rskClient; + let btcClient; + let pegClient; + let assertCallToBridgeMethodsRunner; + before(() => { rskClient = rsk.getClient(Runners.hosts.federate.host); btcClient = bitcoin.getClient( diff --git a/tests/01_05_53-post_hop_pegout_batching_second_requests.js b/tests/01_05_53-pegout_batching_second_requests.js similarity index 94% rename from tests/01_05_53-post_hop_pegout_batching_second_requests.js rename to tests/01_05_53-pegout_batching_second_requests.js index 4f09f99b..fdd64ca8 100644 --- a/tests/01_05_53-post_hop_pegout_batching_second_requests.js +++ b/tests/01_05_53-pegout_batching_second_requests.js @@ -11,16 +11,21 @@ const { NUMBER_OF_BLOCKS_BTW_PEGOUTS } = require('../lib/constants/pegout-consta const rskUtils = require('../lib/rsk-utils'); const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); -let pegoutCount = 0; -let currentBlockNumber; -let assertCallToBridgeMethodsRunner; -let rskTxHelpers; // TODO: Refactor these tests // Some tests fail after running all tests with all forks active from scratch. // More analysis need to be done. Also, these tests use legacy functions. We need to refactor them. describe.skip('Pegout Batching - Execute Pegout Transaction And Call New Bridge Methods', function () { + let pegoutCount = 0; + let currentBlockNumber; + let assertCallToBridgeMethodsRunner; + let rskClients; + let rskClient; + let btcClient; + let pegClient; + let rskTxHelpers; + before(() => { rskClients = Runners.hosts.federates.map(federate => rsk.getClient(federate.host)); rskClient = rsk.getClient(Runners.hosts.federate.host); diff --git a/tests/01_05_54-post_hop_pegout_batching_third_requests.js b/tests/01_05_54-pegout_batching_third_requests.js similarity index 98% rename from tests/01_05_54-post_hop_pegout_batching_third_requests.js rename to tests/01_05_54-pegout_batching_third_requests.js index dca6a7da..f2ce3c39 100644 --- a/tests/01_05_54-post_hop_pegout_batching_third_requests.js +++ b/tests/01_05_54-pegout_batching_third_requests.js @@ -27,7 +27,7 @@ let rskTxHelpers; // TODO: Refactor these tests // Some tests fail after running all tests with all forks active from scratch. // More analysis need to be done. Also, these tests use legacy functions. We need to refactor them. -describe.skip('Pegout Batching - Execute Pegout Transaction And Call New Bridge Methods', function () { +describe('Pegout Batching - Execute Pegout Transaction And Call New Bridge Methods', function () { before(async () => { rskClients = Runners.hosts.federates.map(federate => rsk.getClient(federate.host)); diff --git a/tests/01_05_55-post_hop_pegout_batching_fourth_requests.js b/tests/01_05_55-pegout_batching_fourth_requests.js similarity index 93% rename from tests/01_05_55-post_hop_pegout_batching_fourth_requests.js rename to tests/01_05_55-pegout_batching_fourth_requests.js index 8b9513f0..05832709 100644 --- a/tests/01_05_55-post_hop_pegout_batching_fourth_requests.js +++ b/tests/01_05_55-pegout_batching_fourth_requests.js @@ -9,18 +9,19 @@ const _2wpUtilsLegacy = require('../lib/2wp-utils-legacy'); const pegAssertions = require('../lib/assertions/2wp'); const { NUMBER_OF_BLOCKS_BTW_PEGOUTS } = require('../lib/constants/pegout-constants'); -let currentBlockNumber; -let pegoutCount = 0; -let rskClients; -let rskClient; -let btcClient; -let pegClient; - // TODO: Refactor these tests // Some tests fail after running all tests with all forks active from scratch. // More analysis need to be done. Also, these tests use legacy functions. We need to refactor them. describe.skip('Pegout Batching - New Pegout Requests Then Call new bridge methods', function () { + let currentBlockNumber; + let pegoutCount = 0; + let rskClients; + let rskClient; + let btcClient; + let pegClient; + let assertCallToBridgeMethodsRunner; + before(() => { rskClients = Runners.hosts.federates.map(federate => rsk.getClient(federate.host)); rskClient = rsk.getClient(Runners.hosts.federate.host); diff --git a/tests/01_05_56-post_hop_pegout_batching_advance_blockchain.js b/tests/01_05_56-pegout_batching_advance_blockchain.js similarity index 95% rename from tests/01_05_56-post_hop_pegout_batching_advance_blockchain.js rename to tests/01_05_56-pegout_batching_advance_blockchain.js index a19689ef..ec19cf3a 100644 --- a/tests/01_05_56-post_hop_pegout_batching_advance_blockchain.js +++ b/tests/01_05_56-pegout_batching_advance_blockchain.js @@ -6,13 +6,15 @@ const { NUMBER_OF_BLOCKS_BTW_PEGOUTS } = require('../lib/constants/pegout-consta const rskUtils = require('../lib/rsk-utils'); const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); -let rskTxHelpers; - // TODO: Refactor these tests // Some tests fail after running all tests with all forks active from scratch. // More analysis need to be done. Also, these tests use legacy functions. We need to refactor them. describe.skip('Pegout Batching - Advance the blockchain until the next pegout creation height (no pegout requests).', function () { + let rskTxHelpers; + let rskClient; + let assertCallToBridgeMethodsRunner; + before(() => { rskClient = rsk.getClient(Runners.hosts.federate.host); assertCallToBridgeMethodsRunner = pegAssertions.assertCallToPegoutBatchingBridgeMethods(rskClient); diff --git a/tests/01_05_57-post_hop_active_powpeg_redeem_script.js b/tests/01_05_57-active_powpeg_redeem_script.js similarity index 100% rename from tests/01_05_57-post_hop_active_powpeg_redeem_script.js rename to tests/01_05_57-active_powpeg_redeem_script.js diff --git a/tests/01_05_58-post_hop_register_fast_bridge_btc_below_minimum.js b/tests/01_05_58-register_fast_bridge_btc_below_minimum.js similarity index 95% rename from tests/01_05_58-post_hop_register_fast_bridge_btc_below_minimum.js rename to tests/01_05_58-register_fast_bridge_btc_below_minimum.js index 5322f310..5846ca65 100644 --- a/tests/01_05_58-post_hop_register_fast_bridge_btc_below_minimum.js +++ b/tests/01_05_58-register_fast_bridge_btc_below_minimum.js @@ -14,7 +14,7 @@ const { mineForPeginRegistration } = require('../lib/2wp-utils'); // TODO: Refactor these tests // Some tests fail after running all tests with all forks active from scratch. // More analysis need to be done. Also, these tests use legacy functions. We need to refactor them. -describe.skip('Executing registerFastBtcTransaction after hop - send funds below minimum', () => { +describe.skip('Executing registerFastBridgeBtcTransaction after hop - send funds below minimum', () => { let rskTxHelpers; let rskTxHelper; @@ -28,7 +28,7 @@ describe.skip('Executing registerFastBtcTransaction after hop - send funds below bridge = await getBridge(rskTxHelper.getClient()); }); - it(`should return UNPROCESSABLE_TX_AMOUNT_SENT_BELOW_MINIMUM_ERROR(${UNPROCESSABLE_TX_AMOUNT_SENT_BELOW_MINIMUM_ERROR}) when calling registerFastBtcTransaction method sending amount below minimum`, async () => { + it(`should return UNPROCESSABLE_TX_AMOUNT_SENT_BELOW_MINIMUM_ERROR(${UNPROCESSABLE_TX_AMOUNT_SENT_BELOW_MINIMUM_ERROR}) when calling registerFastBridgeBtcTransaction method sending amount below minimum`, async () => { try { const liquidityBridgeContract = await lbc.getLiquidityBridgeContract(Runners.hosts.federate.host); diff --git a/tests/01_06_51-post_fingerroot500_get-estimated_fees_for_next_pegout_should_returned_correct_estimated.js b/tests/01_06_51-get-estimafees_for_next_pegout_should_returned_correct_estimated.js similarity index 100% rename from tests/01_06_51-post_fingerroot500_get-estimated_fees_for_next_pegout_should_returned_correct_estimated.js rename to tests/01_06_51-get-estimafees_for_next_pegout_should_returned_correct_estimated.js diff --git a/tests/01_07_00-activate-latest-fork.js b/tests/01_07_00-activate-latest-fork.js index 7475ead8..315bf0fd 100644 --- a/tests/01_07_00-activate-latest-fork.js +++ b/tests/01_07_00-activate-latest-fork.js @@ -1,5 +1,6 @@ const activateForkTest = require('../lib/tests/activate-fork'); +// Skipped activate-fork.js. When there is a new fork to be tested pre and post, unskip it in the activate-fork.js file activateForkTest.execute( Runners.common.forks.lovell700 ); diff --git a/tests/01_07_01-2wp_after_latest_fork_activated.js b/tests/01_07_01-2wp_after_latest_fork_activated.js deleted file mode 100644 index 43bcebda..00000000 --- a/tests/01_07_01-2wp_after_latest_fork_activated.js +++ /dev/null @@ -1,5 +0,0 @@ -const twoWpTests = require('../lib/tests/2wp'); - -twoWpTests.execute( - 'BTC <=> RSK 2WP after latest fork activates' -); diff --git a/tests/04_00_01-second-federation-change.js b/tests/04_00_01-second-federation-change.js deleted file mode 100644 index 8610312c..00000000 --- a/tests/04_00_01-second-federation-change.js +++ /dev/null @@ -1,3 +0,0 @@ -const federationChangeTests = require('../lib/tests/change-federation'); - -federationChangeTests.execute('Second Federation change', Runners.config.federations.thirdFederation); // First svp federation change diff --git a/tests/04_00_06-fastbridge_after_fed_change.js b/tests/04_00_06-fastbridge_after_fed_change.js deleted file mode 100644 index c972bc6f..00000000 --- a/tests/04_00_06-fastbridge_after_fed_change.js +++ /dev/null @@ -1,89 +0,0 @@ -const expect = require('chai').expect -const redeemScriptParser = require('@rsksmart/powpeg-redeemscript-parser'); -const { UNPROCESSABLE_TX_AMOUNT_SENT_BELOW_MINIMUM_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 { ERP_PUBKEYS, ERP_CSV_VALUE } = require("../lib/constants/federation-constants") -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 after hop and federation changed', () => { - - let rskTxHelpers; - let rskTxHelper; - let btcTxHelper; - let bridge; - - before(async () => { - rskTxHelpers = getRskTransactionHelpers(); - rskTxHelper = rskTxHelpers[rskTxHelpers.length - 1]; - btcTxHelper = getBtcClient(); - bridge = await getBridge(rskTxHelper.getClient()); - }); - - it(`should return UNPROCESSABLE_TX_AMOUNT_SENT_BELOW_MINIMUM_ERROR(${UNPROCESSABLE_TX_AMOUNT_SENT_BELOW_MINIMUM_ERROR}) when calling registerFastBtcTransaction method sending amount below minimum after fed changed`, 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 = 0.05; - - const derivationHash = await liquidityBridgeContract.methods.getDerivationHash( - preHash, - userBtcRefundAddressBytes, - liquidityProviderBtcAddressBytes - ).call(); - - 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(UNPROCESSABLE_TX_AMOUNT_SENT_BELOW_MINIMUM_ERROR).to.be.equals(resultValue); - }; - - await sendTxWithCheck( - rskTxHelper, - registerFastBridgeBtcTransactionMethod, - cowAddress, - checkFunction - ); - - const currentLbcBalance = Number(await rskTxHelper.getBalance(liquidityBridgeContract._address)); - expect(currentLbcBalance).to.equal(initialLbcBalance); - - } catch(e) { - throw new CustomError('registerFastBridgeBtcTransaction call failure', e); - } - }); -}); diff --git a/tests/05_00_01-2wp-after-svp-federation-change.js b/tests/05_00_01-2wp-after-svp-federation-change.js deleted file mode 100644 index 0ea2babb..00000000 --- a/tests/05_00_01-2wp-after-svp-federation-change.js +++ /dev/null @@ -1,5 +0,0 @@ -const twoWpTests = require('../lib/tests/2wp'); - -twoWpTests.execute( - 'BTC <=> RSK 2WP after svp federation change' -); diff --git a/tests/05_00_02-call_receive_headers.js b/tests/05_00_02-call_receive_headers.js deleted file mode 100644 index bcf837c9..00000000 --- a/tests/05_00_02-call_receive_headers.js +++ /dev/null @@ -1,3 +0,0 @@ -const receiveHeadersTests = require('../lib/tests/call_receive_headers'); - -receiveHeadersTests.execute('Calling receiveHeaders after federation change', () => Runners.hosts.federate.host); diff --git a/tests/05_00_03-call_receive_header.js b/tests/05_00_03-call_receive_header.js deleted file mode 100644 index b6f67229..00000000 --- a/tests/05_00_03-call_receive_header.js +++ /dev/null @@ -1,3 +0,0 @@ -const receiveHeaderTests = require('../lib/tests/call_receive_header'); - -receiveHeaderTests.execute('Calling receiveHeader after federation change'); diff --git a/tests/05_00_04-powpeg_redeem_script.js b/tests/05_00_04-powpeg_redeem_script.js deleted file mode 100644 index e645ba02..00000000 --- a/tests/05_00_04-powpeg_redeem_script.js +++ /dev/null @@ -1,88 +0,0 @@ -const chai = require('chai'); -chai.use(require('chai-as-promised')); -const expect = chai.expect; -const redeemScriptParser = require('@rsksmart/powpeg-redeemscript-parser'); -const { compareFederateKeys } = require('../lib/federation-utils'); -const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); -const CustomError = require('../lib/CustomError'); -const { removePrefix0x } = require('../lib/utils'); -const { publicKeyToCompressed } = require('../lib/btc-utils'); -const { getBridge } = require('../lib/bridge-provider'); - -// in order to run this as a single test file, it requires a federation change so follow the following command -// npm run run-single-test-file 04_00_02-fedchange.js,05_02_01-last_fork_active_powpeg_redeem_script.js - -const { - ERP_PUBKEYS, - ERP_CSV_VALUE, - KEY_TYPE_BTC, - KEY_TYPE_RSK, - KEY_TYPE_MST, -} = require('../lib/constants/federation-constants'); -const INITIAL_FEDERATION_SIZE = 3; - -let rskTxHelpers; -let rskTxHelper; -let bridge; - -// Skipped because 04_00_02-fedchange.js is skipped and this one depends on it. -describe.skip('Calling getActivePowpegRedeemScript method after last fork after fed change', function() { - before(async () => { - rskTxHelpers = getRskTransactionHelpers(); - rskTxHelper = rskTxHelpers[0]; - bridge = await getBridge(rskTxHelper.getClient()); - }); - - it('should return the active powpeg redeem script', async () => { - try { - const activePowpegRedeemScript = await bridge.methods - .getActivePowpegRedeemScript() - .call(); - const activeFederationAddressFromBridge = await bridge.methods.getFederationAddress().call(); - const addressFromRedeemScript = redeemScriptParser.getAddressFromRedeemScript( - 'REGTEST', - Buffer.from(removePrefix0x(activePowpegRedeemScript), 'hex'), - ); - const newFederationPublicKeys = Runners.hosts.federates - .filter((federate, index) => index >= INITIAL_FEDERATION_SIZE) - .map((federate) => ({ - [KEY_TYPE_BTC]: publicKeyToCompressed( - federate.publicKeys[KEY_TYPE_BTC], - ), - [KEY_TYPE_RSK]: publicKeyToCompressed( - federate.publicKeys[KEY_TYPE_RSK], - ), - [KEY_TYPE_MST]: publicKeyToCompressed( - federate.publicKeys[KEY_TYPE_MST], - ), - })) - .sort(compareFederateKeys); - const newFederationBtcPublicKeys = newFederationPublicKeys.map( - (publicKeys) => publicKeys[KEY_TYPE_BTC], - ); - const p2shErpFedRedeemScript = redeemScriptParser.getP2shErpRedeemScript( - newFederationBtcPublicKeys, - ERP_PUBKEYS, - ERP_CSV_VALUE, - ); - const expectedNewFederationAddress = - redeemScriptParser.getAddressFromRedeemScript( - 'REGTEST', - p2shErpFedRedeemScript, - ); - - expect(removePrefix0x(activePowpegRedeemScript)).to.eq(p2shErpFedRedeemScript.toString('hex')); - - - expect(addressFromRedeemScript) - .to.eq(expectedNewFederationAddress); - expect(addressFromRedeemScript) - .to.eq(activeFederationAddressFromBridge); - } catch (err) { - throw new CustomError( - 'getActivePowpegRedeemScript method validation failure', - err, - ); - } - }); -});