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

Adds 'should reject and refund a pegout with value exactly below mini… #139

Conversation

jeremy-then
Copy link
Contributor

Adds 'should reject and refund a pegout with value exactly below minimum' test

@jeremy-then jeremy-then self-assigned this Oct 22, 2024
@jeremy-then jeremy-then requested a review from a team as a code owner October 22, 2024 01:58
Copy link

@apancorb apancorb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

lib/tests/2wp.js Outdated

// Arrange

// Create a pegin for the serder to ensure there is enough funds to pegout and because this is the natural process

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Create a pegin for the serder to ensure there is enough funds to pegout and because this is the natural process
// Create a pegin for the sender to ensure there is enough funds to pegout and because this is the natural process

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@@ -56,6 +56,12 @@ const PEGIN_UNREFUNDABLE_REASONS = {
INVALID_AMOUNT: '3',
};

const PEGOUT_REJECTION_REASONS = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my understanding, these are the codes found in rskj right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremy-then jeremy-then force-pushed the add-should-reject-and-refund-pegout-below-minimum-test branch from a26846a to 71b037b Compare October 22, 2024 15:12
@jeremy-then jeremy-then force-pushed the rits-refactors-9-2024-integration branch from d2040bb to 70af72b Compare October 24, 2024 17:27
@jeremy-then jeremy-then force-pushed the add-should-reject-and-refund-pegout-below-minimum-test branch from 36834c7 to c792c63 Compare October 26, 2024 15:37
@jeremy-then jeremy-then force-pushed the rits-refactors-9-2024-integration branch from 70af72b to a1fcb8d Compare October 26, 2024 15:37
lib/tests/2wp.js Outdated

// Create a pegin for the sender to ensure there is enough funds to pegout and because this is the natural process
const senderRecipientInfo = await createSenderRecipientInfo(rskTxHelper, btcTxHelper);
const peginValueInSatoshis = btcToSatoshis(0.5);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this value could be in function of what we are trying to do?

MIN_PEGOUT_VALUE * 2 for example?

Or maybe have a constant defined, BRIDGE_FUNDING_VALUE or something of the sort.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

lib/tests/2wp.js Outdated
const initialBtcRecipientAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, senderRecipientInfo.btcSenderAddressInfo.address);
const initialRskSenderBalanceInWeisBN = await rskTxHelper.getBalance(senderRecipientInfo.rskRecipientRskAddressInfo.address);
// Value exactly below minimum
const pegoutValueInRbtc = parseFloat((MINIMUM_PEGOUT_AMOUNT_IN_RBTC - 0.0001).toFixed(8));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this could be a lot easier if we stored the min pegout value in satoshis or weis. Less parsing and decimal handling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.


// The rsk sender balance is the same as the initial balance minus the gas fee, because the pegout amount was refunded.
const finalRskSenderBalanceInWeisBN = await rskTxHelper.getBalance(senderRecipientInfo.rskRecipientRskAddressInfo.address);
const gasFee = pegoutTransaction.gasUsed * pegoutTransaction.effectiveGasPrice;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nice, well done!

@jeremy-then jeremy-then force-pushed the add-should-reject-and-refund-pegout-below-minimum-test branch from c792c63 to c8d5e3e Compare October 30, 2024 17:30
Copy link

@marcos-iov marcos-iov merged commit 8845a44 into rits-refactors-9-2024-integration Oct 30, 2024
2 of 3 checks passed
@marcos-iov marcos-iov deleted the add-should-reject-and-refund-pegout-below-minimum-test branch October 30, 2024 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants