Skip to content

Commit

Permalink
Adds 'should reject a legacy pegin with the value exactly below minimum'
Browse files Browse the repository at this point in the history
Rebases
  • Loading branch information
jeremy-then committed Sep 30, 2024
1 parent 548c417 commit 099f712
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
22 changes: 20 additions & 2 deletions lib/2wp-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const ensurePeginIsRegistered = async (rskTxHelper, peginBtcTxHash, expectedUtxo
const MAX_ATTEMPTS = 20;
const CHECK_EVERY_MILLISECONDS = 3000;

const method = async () => {
const method = async () => {
return isUtxoRegisteredInBridge(rskTxHelper, peginBtcTxHash, expectedUtxosCount)
};

Expand Down Expand Up @@ -319,7 +319,24 @@ const get2wpBalances = async (rskTxHelper, btcTxHelper) => {
bridgeUtxosBalanceInSatoshis,
bridgeBalanceInWeisBN,
};

};

/**
* Creates a rejected_pegin event with the specified parameters.
* @param {Object} partialExpectedEvent an object with some rejected_pegin event default values.
* @param {string} btcPeginTxHash the pegin btc tx hash expected to be in the event.
* @param {string} rejectionReason the pegin rejection reason.
* @returns {BridgeEvent}
*/
const createExpectedRejectedPeginEvent = (partialExpectedEvent, btcPeginTxHash, rejectionReason) => {
const expectedEvent = {
...partialExpectedEvent,
arguments: {
btcTxHash: ensure0x(btcPeginTxHash),
reason: rejectionReason,
},
}
return expectedEvent;
};

module.exports = {
Expand All @@ -339,4 +356,5 @@ module.exports = {
createExpectedPeginBtcEvent,
getBridgeUtxosBalance,
get2wpBalances,
createExpectedRejectedPeginEvent,
};
9 changes: 7 additions & 2 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const FUNDS_MIGRATION_AGE_SINCE_ACTIVATION_END = 150;

const PEGIN_REJECTION_REASONS = {
PEGIN_CAP_SURPASSED_REASON: '1',
PEGIN_V1_INVALID_PAYLOAD_REASON: '4'
PEGIN_V1_INVALID_PAYLOAD_REASON: '4',
INVALID_AMOUNT: '5',
};

const PEGOUT_EVENTS = {
Expand All @@ -59,8 +60,12 @@ const PEGOUT_EVENTS = {

const PEGIN_EVENTS = {
PEGIN_BTC: {
name: "pegin_btc",
name: 'pegin_btc',
signature: '0x44cdc782a38244afd68336ab92a0b39f864d6c0b2a50fa1da58cafc93cd2ae5a'
},
REJECTED_PEGIN: {
name: 'rejected_pegin',
signature: '0x708ce1ead20561c5894a93be3fee64b326b2ad6c198f8253e4bb56f1626053d6'
}
};

Expand Down

0 comments on commit 099f712

Please sign in to comment.