Skip to content

Commit

Permalink
Disable lovell
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-then committed Jan 14, 2025
1 parent b490fd6 commit e4696b2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
19 changes: 13 additions & 6 deletions lib/assertions/2wp.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,28 @@ const assertCallToPegoutBatchingBridgeMethods = (rskClient) => async (expectedCo
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).to.not.be.undefined;
expect(rejectedPeginEvent.arguments.btcTxHash).to.equal(expectedPeginBtcHash);
expect(rejectedPeginEvent.arguments.reason).to.equal(expectedRejectionReason);

const pegoutRequestedEvent = rejectedPeginTx.events[1];
expect(pegoutRequestedEvent).to.not.be.null;
const releaseRequestedEvent = rejectedPeginTx.events[1];
expect(releaseRequestedEvent).to.not.be.undefined;

const isLovell700AlreadyActive = await Runners.common.forks.lovell700.isAlreadyActive();

if(!isLovell700AlreadyActive) {
return;
}

const pegoutTransactionCreatedEvent = rejectedPeginTx.events[2];
expect(pegoutTransactionCreatedEvent).to.not.be.null;
expect(pegoutTransactionCreatedEvent).to.not.be.undefined;
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
5 changes: 4 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const createForkObject = (name, activationHeight) => {
if(isActive) {
return isActive;
}
if(this.activationHeight === -1) {
return false;
}
rskTxHelper = rskTxHelper || getRskTransactionHelper();
// Cache the result to avoid calling the network again if the fork is already active
const latestBlockNumber = await rskTxHelper.getBlockNumber();
Expand Down Expand Up @@ -88,7 +91,7 @@ global.Runners = {
hop401: createForkObject('hop401', 1010),
fingerroot500: createForkObject('fingerroot', 1350),
arrowhead600: createForkObject('arrowhead', 1600),
lovell700: createForkObject('lovell', 1700)
lovell700: createForkObject('lovell', -1)
},
additionalFederationAddresses: []
}
Expand Down
6 changes: 0 additions & 6 deletions tests/01_08_50-activate-lovell700.js

This file was deleted.

6 changes: 3 additions & 3 deletions tests/02_00_05-2wp_version1.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe('Lock funds using peg-in protocol version 1', () => {
});

expect(rejectedPeginTx).to.not.be.null;
assertRejectedPeginEvent(rejectedPeginTx, PEGIN_V1_INVALID_PAYLOAD_REASON, peginBtcTxHashWith0xPrefix, amountSentInSatoshis)
await assertRejectedPeginEvent(rejectedPeginTx, PEGIN_V1_INVALID_PAYLOAD_REASON, peginBtcTxHashWith0xPrefix, amountSentInSatoshis)
});

it('should lock with multiple OP_RETURN outputs but only one for RSK', async () => {
Expand Down Expand Up @@ -251,7 +251,7 @@ describe('Lock funds using peg-in protocol version 1', () => {
});

expect(rejectedPeginTx).to.not.be.null;
assertRejectedPeginEvent(rejectedPeginTx, PEGIN_V1_INVALID_PAYLOAD_REASON, peginBtcTxHashWith0xPrefix, amountSentInSatoshis)
await assertRejectedPeginEvent(rejectedPeginTx, PEGIN_V1_INVALID_PAYLOAD_REASON, peginBtcTxHashWith0xPrefix, amountSentInSatoshis)
});

it('should refund lock with OP_RETURN output for RSK with invalid version number', async () => {
Expand Down Expand Up @@ -311,6 +311,6 @@ describe('Lock funds using peg-in protocol version 1', () => {
});

expect(rejectedPeginTx).to.not.be.null;
assertRejectedPeginEvent(rejectedPeginTx, PEGIN_V1_INVALID_PAYLOAD_REASON, peginBtcTxHashWith0xPrefix, amountSentInSatoshis);
await assertRejectedPeginEvent(rejectedPeginTx, PEGIN_V1_INVALID_PAYLOAD_REASON, peginBtcTxHashWith0xPrefix, amountSentInSatoshis);
});
});

0 comments on commit e4696b2

Please sign in to comment.