Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-iov committed Nov 9, 2023
1 parent af685b2 commit 09ade85
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 24 deletions.
31 changes: 31 additions & 0 deletions tests/03_02_01-last_fork_active_powpeg_redeem_script.js
Original file line number Diff line number Diff line change
@@ -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);
}
})
});
18 changes: 0 additions & 18 deletions tests/04_00_02-fedchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() => {
Expand Down
14 changes: 8 additions & 6 deletions tests/05_02_01-last_fork_active_powpeg_redeem_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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,
Expand Down

0 comments on commit 09ade85

Please sign in to comment.