-
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 when fee per kb is above valu… #140
Adds 'should reject and refund a pegout when fee per kb is above valu… #140
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
|
||
// 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 we can have a default constant for 0.5 as well?
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 think there's no need for this. This is not the minimum pegin value or any significan value. This is just to have enough funds on the rsk address. This value could change from test to test. For example, in the future pegout test where we will need to create a lot of pegouts to assert that the Bridge split them, we will probably need to send way more funds. So, that value could change.
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.
As long as this value does not repeat in other places, it is ok to me.
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.
Left a similar comment in another PR.
Not a big deal, open to discuss it. If the value won't always be the same then maybe it doesn't make sense to have a constant. But it could maybe at least be a constant within the test to not make it a magic number.
Option 2 is to calculate this value depending on what the test needs. If we are doing a peg-out for pegoutValue=X
, then this value could be pegoutValue * 2
Open to hear other ideas
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.
57c7280
to
08d4d77
Compare
36834c7
to
c792c63
Compare
08d4d77
to
aed2792
Compare
lib/constants.js
Outdated
@@ -116,6 +116,9 @@ const PEGIN_V1_RSKT_PREFIX_HEX = '52534b54'; | |||
|
|||
const MINIMUM_PEGOUT_AMOUNT_IN_RBTC = 0.0025; | |||
|
|||
const FEE_PER_KB_CHANGE_PK = '6a4b49312b91e203ddfb9bc2d900ebbd46fbede46a7462e770bedcb11ad405e9'; |
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.
A bit nit from my side, but whenever I see PK
I wish I could tell if it means public or private key. And the difference is quite important
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.
await sendTransaction(rskTxHelper, bridge.methods.voteFeePerKbChange(feePerKbInSatoshis), FEE_PER_KB_CHANGE_ADDR); | ||
|
||
const finalFeePerKb = await bridge.methods.getFeePerKb().call(); | ||
expect(Number(finalFeePerKb)).to.equal(Number(feePerKbInSatoshis)); |
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.
You could also do a call
before sending the transaction, and assert the response code
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.
A call
to voteFeePerKbChange
or getFeePerKb
?
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, by calling sendTxWithCheck
.
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.
Left a similar comment in another PR.
Not a big deal, open to discuss it. If the value won't always be the same then maybe it doesn't make sense to have a constant. But it could maybe at least be a constant within the test to not make it a magic number.
Option 2 is to calculate this value depending on what the test needs. If we are doing a peg-out for pegoutValue=X
, then this value could be pegoutValue * 2
Open to hear other ideas
lib/tests/2wp.js
Outdated
const btcPeginTxHash = await sendPegin(rskTxHelper, btcTxHelper, senderRecipientInfo.btcSenderAddressInfo, satoshisToBtc(peginValueInSatoshis)); | ||
await ensurePeginIsRegistered(rskTxHelper, btcPeginTxHash); |
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.
Could this whole part maybe be moved to a method? fundBridgeForPegout
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.
c792c63
to
c8d5e3e
Compare
58d00aa
to
102700b
Compare
f39a419
to
f5065f6
Compare
lib/tests/2wp.js
Outdated
const initial2wpBalances = await get2wpBalances(rskTxHelper, btcTxHelper); | ||
const initialBtcRecipientAddressBalanceInSatoshis = await getBtcAddressBalanceInSatoshis(btcTxHelper, senderRecipientInfo.btcSenderAddressInfo.address); | ||
const initialRskSenderBalanceInWeisBN = await rskTxHelper.getBalance(senderRecipientInfo.rskRecipientRskAddressInfo.address); | ||
const pegoutValueInSatoshis = MINIMUM_PEGOUT_AMOUNT_IN_SATOSHIS - 1; |
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.
Is this a good idea? We want the pegout to be rejected for the fee value, I wouldn't see an invalid pegout request. That could create some confusion
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.
Quality Gate passedIssues Measures |
1aecc22
into
rits-refactors-9-2024-integration
Adds 'should reject and refund a pegout when fee per kb is above value' test