-
Notifications
You must be signed in to change notification settings - Fork 2
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
Adds 'should reject and refund a pegout with value exactly below mini… #139
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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 |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a26846a
to
71b037b
Compare
d2040bb
to
70af72b
Compare
36834c7
to
c792c63
Compare
70af72b
to
a1fcb8d
Compare
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nice, well done!
Rebasing
…mum' test Rebase.
c792c63
to
c8d5e3e
Compare
Quality Gate passedIssues Measures |
8845a44
into
rits-refactors-9-2024-integration
Adds 'should reject and refund a pegout with value exactly below minimum' test