diff --git a/tests/03_02_01-last_fork_active_powpeg_redeem_script.js b/tests/03_02_01-last_fork_active_powpeg_redeem_script.js new file mode 100644 index 00000000..9a84187f --- /dev/null +++ b/tests/03_02_01-last_fork_active_powpeg_redeem_script.js @@ -0,0 +1,31 @@ +const chai = require('chai'); +chai.use(require('chai-as-promised')); +const expect = chai.expect; + +const rsk = require('peglib').rsk; +const redeemScriptParser = require('@rsksmart/powpeg-redeemscript-parser'); +const CustomError = require('../lib/CustomError'); +const removePrefix0x = require("../lib/utils").removePrefix0x; +const { GENESIS_FEDERATION_ADDRESS, GENESIS_FEDERATION_REDEEM_SCRIPT } = require('../lib/constants'); + +describe('Calling getActivePowpegRedeemScript method after last fork before fedchange', function() { + + before(() => { + rskClient = rsk.getClient(Runners.hosts.federate.host); + }); + + it('should return the active powpeg redeem script', async () => { + try{ + const activePowpegRedeemScript = await rskClient.rsk.bridge.methods.getActivePowpegRedeemScript().call(); + const activeFederationAddressFromBridge = await rskClient.rsk.bridge.methods.getFederationAddress().call(); + const addressFromRedeemScript = redeemScriptParser.getAddressFromRedeemScript( + 'REGTEST', Buffer.from(removePrefix0x(activePowpegRedeemScript), 'hex') + ); + + expect(activePowpegRedeemScript).to.eq(GENESIS_FEDERATION_REDEEM_SCRIPT); + expect(addressFromRedeemScript).to.eq(GENESIS_FEDERATION_ADDRESS).to.eq(activeFederationAddressFromBridge); + } catch (err) { + throw new CustomError('getActivePowpegRedeemScript method validation failure', err); + } + }) +}); diff --git a/tests/04_00_02-fedchange.js b/tests/04_00_02-fedchange.js index 1cffc2a8..7e3ed13f 100644 --- a/tests/04_00_02-fedchange.js +++ b/tests/04_00_02-fedchange.js @@ -690,24 +690,6 @@ describe('RSK Federation change', function() { } }); - - it.skip('should return the active powpeg redeem script', async () => { - try{ - const activePowpegRedeemScript = await rskClientNewFed.rsk.bridge.methods.getActivePowpegRedeemScript().call(); - const activeFederationAddressFromBridge = await rskClientNewFed.rsk.bridge.methods.getFederationAddress().call(); - const addressFromRedeemScript = redeemScriptParser.getAddressFromRedeemScript( - 'REGTEST', Buffer.from(removePrefix0x(activePowpegRedeemScript), 'hex') - ); - - expect(activePowpegRedeemScript).to.eq('0x' + p2shErpFedRedeemScript.toString('hex')); - expect(addressFromRedeemScript).to.eq(expectedNewFederationAddress).to.eq(activeFederationAddressFromBridge); - } catch (err) { - throw new CustomError('getActivePowpegRedeemScript method validation failure', err); - } - }) - - - }); const getActiveFederationAddress = async() => { diff --git a/tests/05_02_01-last_fork_active_powpeg_redeem_script.js b/tests/05_02_01-last_fork_active_powpeg_redeem_script.js index 61526db9..2423d746 100644 --- a/tests/05_02_01-last_fork_active_powpeg_redeem_script.js +++ b/tests/05_02_01-last_fork_active_powpeg_redeem_script.js @@ -2,11 +2,7 @@ const chai = require("chai"); chai.use(require("chai-as-promised")); const expect = chai.expect; const peglib = require('peglib'); -const pegUtils = peglib.pegUtils; const bitcoin = peglib.bitcoin; -const pegAssertions = require('../lib/assertions/2wp'); -const rskUtilsLegacy = require('../lib/rsk-utils-legacy'); -const rskUtils = require('../lib/rsk-utils'); const { compareFederateKeys } = require("../lib/federation-utils"); const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); const rsk = require("peglib").rsk; @@ -22,6 +18,14 @@ const { KEY_TYPE_MST, } = require("../lib/constants"); const INITIAL_FEDERATION_SIZE = 3; +let btcClient; +let rskClientNewFed; +let rskClients; +let newFederationBtcPublicKeys; +let newFederationPublicKeys; +let rskTxHelpers; +let btcTxHelper; +let rskTxHelper; describe("Calling getActivePowpegRedeemScript method after last fork after fed change", function () { before(() => { rskClient = rsk.getClient(Runners.hosts.federate.host); @@ -40,8 +44,6 @@ describe("Calling getActivePowpegRedeemScript method after last fork after fed c Buffer.from(removePrefix0x(activePowpegRedeemScript), "hex") ); - rskClientOldFed = rsk.getClient(Runners.hosts.federate.host); - const NETWORK = bitcoin.networks.testnet; btcClient = bitcoin.getClient( Runners.hosts.bitcoin.rpcHost,