Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skipping legacy tests that started failing when all forks were active… #74

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions lib/assertions/2wp.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ const assertCallToPegoutBatchingBridgeMethods = (rskClient) => async (expectedCo

const estimatedFees = await rskClient.rsk.bridge.methods.getEstimatedFeesForNextPegOutEvent().call();
// Using Arithmetic Sequence To Calculate The Estimated Fee
const expectedEstimatedFee = expectedCount > 0 ? MAX_ESTIMATED_FEE_PER_PEGOUT + (expectedCount - 1) * FEE_DIFFERENCE_PER_PEGOUT : 0;
// With the 'running with all forks active', the estimated fees are always calculated.
const expectedEstimatedFee = MAX_ESTIMATED_FEE_PER_PEGOUT + (expectedCount - 1) * FEE_DIFFERENCE_PER_PEGOUT;
expect(Number(estimatedFees)).to.equal(expectedEstimatedFee);

const nextPegoutCreationBlockNumber = await rskClient.rsk.bridge.methods.getNextPegoutCreationBlockNumber().call();
expect(Number(nextPegoutCreationBlockNumber)).to.equal(expectedNextPegoutCreationBlockNumber);
}

const assertRejectedPeginEvent = (rejectedPeginTx, expectedRejectionReason, expectedPeginBtcHash, expectedRefundAmountInSatoshis) => {
const assertRejectedPeginEvent = async (rejectedPeginTx, expectedRejectionReason, expectedPeginBtcHash, expectedRefundAmountInSatoshis) => {
const rejectedPeginEvent = rejectedPeginTx.events[0];
expect(rejectedPeginEvent).to.not.be.null;
expect(rejectedPeginEvent.arguments.btcTxHash).to.equal(expectedPeginBtcHash);
Expand All @@ -126,12 +127,17 @@ const assertRejectedPeginEvent = (rejectedPeginTx, expectedRejectionReason, expe
const pegoutRequestedEvent = rejectedPeginTx.events[1];
expect(pegoutRequestedEvent).to.not.be.null;

const pegoutTransactionCreatedEvent = rejectedPeginTx.events[2];
expect(pegoutTransactionCreatedEvent).to.not.be.null;
const encodedUtxoOutpointValues = Buffer.from(removePrefix0x(pegoutTransactionCreatedEvent.arguments.utxoOutpointValues), 'hex');
const federationUtxoValues = encodeOutpointValuesAsMap([{"valueInSatoshis": expectedRefundAmountInSatoshis}]);
const outpointValues = decodeOutpointValues(encodedUtxoOutpointValues);
expect(outpointValues.every(value => value in federationUtxoValues)).to.be.true;
// TODO: remove this check when lovell is active by default like the other forks.
const isLovellAlreadyActive = await Runners.common.forks.lovell700.isAlreadyActive();
if(isLovellAlreadyActive) {
const pegoutTransactionCreatedEvent = rejectedPeginTx.events[2];
expect(pegoutTransactionCreatedEvent).to.not.be.null;
const encodedUtxoOutpointValues = Buffer.from(removePrefix0x(pegoutTransactionCreatedEvent.arguments.utxoOutpointValues), 'hex');
const federationUtxoValues = encodeOutpointValuesAsMap([{"valueInSatoshis": expectedRefundAmountInSatoshis}]);
const outpointValues = decodeOutpointValues(encodedUtxoOutpointValues);
expect(outpointValues.every(value => value in federationUtxoValues)).to.be.true;
}

}

module.exports = {
Expand Down
4 changes: 3 additions & 1 deletion lib/tests/activate-fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const { getRskTransactionHelpers } = require('../rsk-tx-helper-provider');

const execute = (fork, getFederates) => {

describe(`Activate ${fork.name} fork`, () => {
// Skipped due to 'running with all forks active' changes.

describe.skip(`Activate ${fork.name} fork`, () => {

it(`should mine blocks until reach ${fork.activationHeight}th block in order to activate the fork`, async () => {
try {
Expand Down
21 changes: 11 additions & 10 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const createForkObject = (name, activationHeight) => {
rskTxHelper = rskTxHelper || getRskTransactionHelper();
// Cache the result to avoid calling the network again if the fork is already active
const latestBlockNumber = await rskTxHelper.getBlockNumber();
isActive = latestBlockNumber >= this.activationHeight;
isActive = this.activationHeight !== -1 && latestBlockNumber >= this.activationHeight;
return isActive;
}

Expand All @@ -80,15 +80,16 @@ global.Runners = {
hosts: {},
common: {
forks: {
orchid: createForkObject('orchid', 100),
wasabi100: createForkObject('wasabi', 250),
papyrus200: createForkObject('papyrus', 450),
iris300: createForkObject('iris', 700),
hop400: createForkObject('hop', 1000),
hop401: createForkObject('hop401', 1010),
fingerroot500: createForkObject('fingerroot', 1350),
arrowhead600: createForkObject('arrowhead', 1600),
lovell700: createForkObject('lovell', 1700)
orchid: createForkObject('orchid', 1),
wasabi100: createForkObject('wasabi', 1),
papyrus200: createForkObject('papyrus', 1),
iris300: createForkObject('iris', 1),
hop400: createForkObject('hop', 1),
hop401: createForkObject('hop401', 1),
fingerroot500: createForkObject('fingerroot', 1),
arrowhead600: createForkObject('arrowhead', 1),
arrowhead631: createForkObject('arrowhead631', 1),
lovell700: createForkObject('lovell', -1)
},
additionalFederationAddresses: []
}
Expand Down
4 changes: 3 additions & 1 deletion tests/01_01_02-pre_orchid_bridge_constant_fns.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const bridgeCallsTests = require('../lib/tests/bridge-calls');

bridgeCallsTests.execute('Bridge calls and txs from contracts to constant fns (pre-orchid)', () => Runners.hosts.federate.host, false);
// Skipped due to 'running with all forks active' changes.

// bridgeCallsTests.execute('Bridge calls and txs from contracts to constant fns (pre-orchid)', () => Runners.hosts.federate.host, false);
3 changes: 2 additions & 1 deletion tests/01_01_03-pre_orchid_lock_whitelist_fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ const WHITELIST_ADDRESSES = {
'mnr8aGuc3tZb63gyssWssAz98LEojwTs9b' : 100000000000
};

// Skipped due to 'running with all forks active' changes.

describe('RFS-170 test before fork', () => {
describe.skip('RFS-170 test before fork', () => {
const RFS_170_ACTIVATION_BLOCK = Runners.common.forks.orchid.activationHeight;

before(async () => {
Expand Down
10 changes: 6 additions & 4 deletions tests/01_01_50-activate_orchid_fork.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const activateForkTest = require('../lib/tests/activate-fork');

activateForkTest.execute(
Runners.common.forks.orchid,
() => Runners.hosts.federates
);
// Skipped due to 'running with all forks active' changes.

// activateForkTest.execute(
// Runners.common.forks.orchid,
// () => Runners.hosts.federates
// );
4 changes: 3 additions & 1 deletion tests/01_01_51-post_orchid_bridge_constant_fns.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const bridgeCallsTests = require('../lib/tests/bridge-calls');

bridgeCallsTests.execute('Bridge calls and txs from contracts to constant fns', () => Runners.hosts.federate.host, true);
// Skipped due to 'running with all forks active' changes.

// bridgeCallsTests.execute('Bridge calls and txs from contracts to constant fns', () => Runners.hosts.federate.host, true);
2 changes: 2 additions & 0 deletions tests/01_01_52-post_orchid_lock_whitelist_fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ let rskTxHelper;
let rskTxHelpers;
let bridge;

// TODO: analyze why these tests are passing after the 'running with all forks active' changes.

describe('RFS-170 test after fork', () => {
before(async () => {
btcTxHelper = getBtcClient();
Expand Down
4 changes: 3 additions & 1 deletion tests/01_02_01-pre_wasabi_fed_pubkeys_fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ let fedChangeAddress;
let preWasabiBridge;
let postWasabiBridge;

describe('Multiple federation member keys test before fork', () => {
// Skipped due to 'running with all forks active' changes.

describe.skip('Multiple federation member keys test before fork', () => {

const ACTIVATION_BLOCK = Runners.common.forks.wasabi100.activationHeight;

Expand Down
10 changes: 6 additions & 4 deletions tests/01_02_50-activate_wasabi_fork.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const activateForkTest = require('../lib/tests/activate-fork');

activateForkTest.execute(
Runners.common.forks.wasabi100,
() => Runners.hosts.federates
);
// Skipped due to 'running with all forks active' changes.

// activateForkTest.execute(
// Runners.common.forks.wasabi100,
// () => Runners.hosts.federates
// );
6 changes: 5 additions & 1 deletion tests/01_02_51-post_wasabi_fed_pubkeys_fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const fulfillRequirementsToRunAsSingleTestFile = async () => {
await activateFork(Runners.common.forks.wasabi100);
};

// Skipped due to 'running with all forks active' changes.
// TODO: should this test file be named '01_02_51-bridge-fed-public-keys-management-methods' or something like that after 'running with all forks active' changes?

describe('Multiple federation member keys test after fork', () => {

const ACTIVATION_BLOCK = Runners.common.forks.wasabi100.activationHeight;
Expand All @@ -34,7 +37,8 @@ describe('Multiple federation member keys test after fork', () => {
bridge = getBridge(rskTxHelper.getClient(), await getLatestActiveForkName());
});

it(`should be at a height higher than ${ACTIVATION_BLOCK}`, async () => {
// This is not doing anything now. Can be deleted.
it.skip(`should be at a height higher than ${ACTIVATION_BLOCK}`, async () => {
try{
const blockNum = await rskTxHelper.getBlockNumber();
expect(blockNum > ACTIVATION_BLOCK).to.be.true;
Expand Down
6 changes: 5 additions & 1 deletion tests/01_03_01-lock_whitelist_pre_papyrus.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ const assertNonMatchedAmountsExist = (testCaseAmounts, peginBtcTx, returnTx) =>
expect(nonMatchedAmounts.length).to.equal(0);
}

describe('Lock whitelisting', () => {

// Skipped due to 'running with all forks active' changes.
// Should we delete this whole file?

describe.skip('Lock whitelisting', () => {
before(async () => {
if(process.env.RUNNING_SINGLE_TEST_FILE) {
await fulfillRequirementsToRunAsSingleTestFile();
Expand Down
4 changes: 3 additions & 1 deletion tests/01_03_02-pre_papyrus_locking_cap.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ const CustomError = require('../lib/CustomError');

const NETWORK = bitcoin.networks.testnet;

describe('Calling locking cap methods before papyrus200', function() {
// Skipped due to 'running with all forks active' changes.

describe.skip('Calling locking cap methods before papyrus200', function() {

before(() => {
rskClient = rsk.getClient(Runners.hosts.federate.host);
Expand Down
5 changes: 4 additions & 1 deletion tests/01_03_03-pre_papyrus_coinbase_information.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const CustomError = require('../lib/CustomError');

const NETWORK = bitcoin.networks.testnet;

// Should the name of this test class simply be: 01_03_03-coinbase_information?

describe('Calling coinbase information methods before papyrus', function() {

before(() => {
Expand All @@ -37,7 +39,8 @@ describe('Calling coinbase information methods before papyrus', function() {
}
})

it('should return false when calling hasBtcBlockCoinbaseTransactionInformation method', async () => {
// Should assert for true instead?
it.skip('should return false when calling hasBtcBlockCoinbaseTransactionInformation method', async () => {
try{
let randomHex = web3.utils.randomHex;
let stringHex = randomHex(32);
Expand Down
6 changes: 5 additions & 1 deletion tests/01_03_04-2wp_segwit_not_compatible.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ let rskTxHelpers;
let rskTxHelper;
let btcTxHelper;

// TODO: no need for fulfillRequirementsToRunAsSingleTestFile functions to activate the forks now. Update them all or remove them.
const fulfillRequirementsToRunAsSingleTestFile = async () => {
await rskUtils.activateFork(Runners.common.forks.wasabi100);
};

describe('Lock p2sh-p2wpkh address', () => {
// Skipped due to 'running with all forks active' changes.

describe.skip('Lock p2sh-p2wpkh address', () => {
before(async () => {
rskTxHelpers = getRskTransactionHelpers();
rskTxHelper = rskTxHelpers[0];
Expand Down Expand Up @@ -46,6 +49,7 @@ describe('Lock p2sh-p2wpkh address', () => {

await rskUtils.triggerRelease(rskTxHelpers, btcTxHelper);

// With all the forks active from the beginning, the uxto is registered, which makes the assertion fail.
const isPeginUtxoRegistered = await isUtxoRegisteredInBridge(rskTxHelper, btcPeginTxHash);
expect(isPeginUtxoRegistered).to.be.false;

Expand Down
9 changes: 5 additions & 4 deletions tests/01_03_05-2wp_multisig_not_compatible.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ describe('Peg-in multisig address', () => {
}
});

// Should fail and not refund when sending a pengin from a multisig address pre papyrus
it('Peg-in should fail when using multisig address', async () => {
it('Peg-in should fail and funds should be refunded when using multisig address', async () => {
const latestActiveForkName = await getLatestActiveForkName();
const bridge = getBridge(rskTxHelper.getClient(), latestActiveForkName);

Expand All @@ -45,14 +44,16 @@ describe('Peg-in multisig address', () => {
const federationAddressBalanceAfterPegin = Number(await btcTxHelper.getAddressBalance(federationAddress));
expect(Number(federationAddressBalanceAfterPegin)).to.be.equal(Number(federationAddressBalanceInitial + minimumPeginValueInBtc));

await rskUtils.triggerRelease(rskTxHelpers, btcTxHelper);

const isPeginUtxoRegistered = await isUtxoRegisteredInBridge(rskTxHelper, btcPeginTxHash);
expect(isPeginUtxoRegistered).to.be.false;

const federationAddressBalanceFinal = Number(await btcTxHelper.getAddressBalance(federationAddress));
expect(Number(federationAddressBalanceFinal)).to.be.equal(Number(federationAddressBalanceInitial + minimumPeginValueInBtc));
expect(Number(federationAddressBalanceFinal)).to.be.equal(Number(federationAddressBalanceInitial));

const senderAddressBalanceFinal = await btcTxHelper.getAddressBalance(senderAddress.address);
expect(Number(senderAddressBalanceFinal)).to.be.equal(0);
expect(Number(senderAddressBalanceFinal)).to.be.at.most(minimumPeginValueInBtc);
});
});

2 changes: 0 additions & 2 deletions tests/01_03_06-2wp_no_locking_cap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const { sendPegin, ensurePeginIsRegistered, sendTxToBridge } = require('../lib/2
const { getBridge, getLatestActiveForkName } = require('../lib/precompiled-abi-forks-util');
const { getDerivedRSKAddressInformation } = require('@rsksmart/btc-rsk-derivation');
const btcEthUnitConverter = require('@rsksmart/btc-eth-unit-converter');
const whitelistingAssertions = require('../lib/assertions/whitelisting');

describe('Transfer BTC to RBTC before papyrus200', function() {

Expand Down Expand Up @@ -35,7 +34,6 @@ describe('Transfer BTC to RBTC before papyrus200', function() {

it('should do a multiple pegouts from the same rsk address after making a pegin', async () => {
const btcAddressInfo = await btcTxHelper.generateBtcAddress('legacy');
await whitelistingAssertions.assertAddLimitedLockWhitelistAddress(rskTxHelper, btcAddressInfo.address, Number(btcEthUnitConverter.btcToSatoshis(PEGIN_VALUE_IN_BTC)));
await rskUtils.mineAndSync(rskTxHelpers);

const recipientRskAddressInfo = getDerivedRSKAddressInformation(btcAddressInfo.privateKey, btcTxHelper.btcConfig.network);
Expand Down
10 changes: 6 additions & 4 deletions tests/01_03_50-activate_papyrus_fork.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const activateForkTest = require('../lib/tests/activate-fork');

activateForkTest.execute(
Runners.common.forks.papyrus200,
() => Runners.hosts.federates
);
// Skipped due to 'running with all forks active' changes.

// activateForkTest.execute(
// Runners.common.forks.papyrus200,
// () => Runners.hosts.federates
// );
4 changes: 3 additions & 1 deletion tests/01_03_51-2wp_release_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ const BTC_TX_FEE = bitcoin.btcToSatoshis(0.001);
const WHITELIST_CHANGE_PK = '3890187a3071327cee08467ba1b44ed4c13adb2da0d5ffcc0563c371fa88259c';
const WHITELIST_CHANGE_ADDR = '87d2a0f33744929da08b65fd62b627ea52b25f8e';

describe('Release events (for whitelisting) after papyrus activation', function() {
// Skipped due to 'running with all forks active' changes.

describe.skip('Release events (for whitelisting) after papyrus activation', function() {
var addresses;

before(async () => {
Expand Down
4 changes: 3 additions & 1 deletion tests/01_03_52-disable_lock_whitelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const fulfillRequirementsToRunAsSingleTestFile = async () => {
await rskUtils.activateFork(Runners.common.forks.papyrus200);
};

describe('Disable whitelisting', function() {
// Skipped due to 'running with all forks active' changes.

describe.skip('Disable whitelisting', function() {

before(async () => {
if(process.env.RUNNING_SINGLE_TEST_FILE) {
Expand Down
10 changes: 7 additions & 3 deletions tests/01_04_01-pre_iris_2wp.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ const AMOUNT_TO_LOCK_IN_BTC = 2;
let rskTxHelper;
let btcTxHelper;

describe('Lock funds using peg-in protocol version 1 before iris300', () => {
// Skipped due to 'running with all forks active' changes.
// No need for this test anymore after running tests with all forks active, since pegin and pegout tests are already being covered in other tests.

describe.skip('Lock funds using peg-in protocol version 1 before iris300', () => {
before(async () => {
rskTxHelper = getRskTransactionHelper();
btcTxHelper = getBtcClient()
});

// TODO: rename this test accordingly.
it('should lock using p2pkh sender to derived address, ignoring OP_RETURN output', async () => {
// Create legacy type address to use as sender
const senderAddressInformation = await btcTxHelper.generateBtcAddress('legacy');
Expand Down Expand Up @@ -51,8 +55,8 @@ describe('Lock funds using peg-in protocol version 1 before iris300', () => {
expect(Number(initialSenderBalance)).to.equal(0);
expect(Number(finalSenderBalance)).to.equal(0);
expect(Number(initialDerivedAddressBalance)).to.equal(0);
expect(Number(finalDerivedAddressBalance)).to.equal(Number(btcEthUnitConverter.btcToWeis(AMOUNT_TO_LOCK_IN_BTC)));
expect(Number(finalDerivedAddressBalance)).to.equal(0);
expect(Number(initialDestinationAddressBalance)).to.equal(0);
expect(Number(finalDestinationAddressBalance)).to.equal(0);
expect(Number(finalDestinationAddressBalance)).to.equal(Number(btcEthUnitConverter.btcToWeis(AMOUNT_TO_LOCK_IN_BTC)));
});
});
4 changes: 3 additions & 1 deletion tests/01_04_01-pre_iris_liquidity_bridge_contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const lbc = require('../lib/liquidity-bridge-contract');

let liquidityBridgeContract;

describe('Call liquidity bridge contract before iris300', () => {
// Skipped due to 'running with all forks active' changes.

describe.skip('Call liquidity bridge contract before iris300', () => {

it('should create the testing contract', async () => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const CustomError = require('../lib/CustomError');

const NETWORK = bitcoin.networks.testnet;

describe('Calling registerFastBridgeBtcTransaction before iris', function() {
// Skipped due to 'running with all forks active' changes.

describe.skip('Calling registerFastBridgeBtcTransaction before iris', function() {

before(() => {
rskClient = rsk.getClient(Runners.hosts.federate.host);
Expand Down
4 changes: 3 additions & 1 deletion tests/01_04_03-pre_iris_call_receive_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const CustomError = require('../lib/CustomError');

const NETWORK = bitcoin.networks.testnet;

describe('Calling method receiveHeader before iris300', function() {
// Skipped due to 'running with all forks active' changes.

describe.skip('Calling method receiveHeader before iris300', function() {

before(() => {
rskClient = rsk.getClient(Runners.hosts.federate.host);
Expand Down
Loading
Loading