-
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 create multiple pegouts with mixed values same and above… #163
Adds 'should create multiple pegouts with mixed values same and above… #163
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, minor comments
const txPromise = rskTxHelper.sendTransaction({ | ||
from: rskFromAddress, | ||
to: BRIDGE_ADDRESS, | ||
value: amountInWeisBN, | ||
gasPrice: TO_BRIDGE_GAS_PRICE, | ||
}); | ||
|
||
if(!mine) { |
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.
nit:
if(!mine) { | |
if (!mine) { |
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 just noticed there is a mixed of if (
an if(
in the test. I always prefer if(
. But what should we always use? @nathanieliov , @marcos-iov , @julia-zack .
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.
|
||
await triggerRelease(rskTxHelpers, btcTxHelper, callbacks); | ||
|
||
// Checking all the pegout events are emitted and in order |
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.
It seems they all get mined in the same block. How are we verifying the order?
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.
They all get mined in the same block, otherwise, the test would fail.
Since they can get mined in different order, I'm forced to use pegoutsEvents.find
index of indices and getAddressUtxo
to find the corresponding utxos.
const txPromise = rskTxHelper.sendTransaction({ | ||
from: rskFromAddress, | ||
to: BRIDGE_ADDRESS, | ||
value: amountInWeisBN, | ||
gasPrice: TO_BRIDGE_GAS_PRICE, | ||
}); | ||
|
||
if(!mine) { |
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.
2ac0319
to
5c567a3
Compare
9c1d2e2
to
253411e
Compare
… minimum' test Rebase
5c567a3
to
bc9cb09
Compare
const pegoutCreatedCallback = async () => { | ||
bridgeStateAfterPegoutCreation = await getBridgeState(rskTxHelper.getClient()); | ||
}; |
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 might be missing something, what's the value of this callback? It will simply get the Bridge state and do nothing with it
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.
This is used to get the pegouts waiting for confirmations in the Bridge. Here: https://github.com/rsksmart/rootstock-integration-tests/pull/163/files#diff-530dff31017eb3e951f3872538c0ad19594ae9ce04870a05b9f8029fc16225aeR997
This is used to get the raw btc tx, the rsk hash of the pegout creation tx, and the creation block number.
Without this, we wouldn't be able to assert the btc tx hash of the releaseRequestedEvent
, batchPegoutCreatedEvent
and pegoutConfirmedEvent
events. So the test would not be as robust. This is to ensure that the btc tx hash that the Bridge shows when the pegout is created, is the same that gets emitted in the events.
This helps assert all the values of the events. The old tests just partially asserted the values and some were checked just for assert is not null
and etc. Now, with this new approach, we can assert all the values, which is a better practice.
const pegoutTransaction2 = await pegoutTransaction2Promise; | ||
const pegoutTransaction3 = await pegoutTransaction3Promise; | ||
|
||
// Assert |
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.
Should we check the Bridge state at this point? To assert there are 3 pegout requests created
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.
Good idea.
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/btc-utils.js
Outdated
@@ -187,11 +187,16 @@ const waitForBitcoinMempoolToGetTxs = async (btcTxHelper, maxAttempts = 3, check | |||
return Number(btcToSatoshis(await btcTxHelper.getAddressBalance(btcAddress))); | |||
}; | |||
|
|||
const base58AddressToHexString = (base58Address) => { |
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.
toHexString
doesn't say much. Maybe we should call this toHash160
? If that is the case, not sure what the hex string is representing here
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 |
f44d0b6
into
rits-refactors-9-2024-integration
Adds 'should create multiple pegouts with mixed values same and above minimum' test