-
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
01-04-54-post-iris-call-receive-headers / 01-04-55-post-iris-call-receive-header #26
01-04-54-post-iris-call-receive-headers / 01-04-55-post-iris-call-receive-header #26
Conversation
jpikora-iov
commented
Dec 19, 2023
- first part refactor of 01-04-54-post-iris-call-receive-headers 01_04_54-post_iris_call_receive_headers.js
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.
Changes look good but if the plan is to run the same test 3 times we should encapsulate the logic in a single file to avoid repeating code everywhere. I can help you with this
package-lock.json
Outdated
@@ -1,7 +1,7 @@ | |||
{ | |||
"name": "rootstock-integration-tests", | |||
"version": "1.0.0", | |||
"lockfileVersion": 3, | |||
"lockfileVersion": 2, |
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.
Make sure you are using node v18
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.
Using node v20 now.
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 couple of comments. Rebase with the latest changes on main. And run npm i
with nodejs version 20.
const bridge = getBridge(rskTxHelper.getClient(), await getLatestActiveForkName()); | ||
const blockNumberInitial = await bridge.methods.getBtcBlockchainBestChainHeight().call(); | ||
const cowAddress = await rskTxHelper.newAccountWithSeed('cow'); | ||
const blockHash = await btcTxHelper.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 know we have things like this in many places, but it's a bit confusing. Let's start fixing that.
The await btcTxHelper.mine();
call returns an array of btc block hashes, the ones that were mined. In this case, only one block was mined. But still, it returns an array. So let's called that blockHashes
to make it clear.
const { getRskTransactionHelpers } = require('../lib/rsk-tx-helper-provider'); | ||
const { getBtcClient } = require('../lib/btc-client-provider'); | ||
const { getBridge, getLatestActiveForkName } = require('../lib/precompiled-abi-forks-util'); | ||
const { activateFork, sendTxWithCheck } = require('../lib/rsk-utils'); |
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.
activateFork
is not being used here.
ddacf09
to
f325463
Compare
pipeline:run |
pipeline:run |
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.
} | ||
}); | ||
}); | ||
twoWpTests.execute('Calling receiveHeaders after iris300', () => Runners.hosts.federate.host); |
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.
Remember to leave a blank line at the end of each file, check the pther files also
@@ -1,47 +1,3 @@ | |||
const expect = require('chai').expect; | |||
const twoWpTests = require('../lib/tests/post_iris_call_receive_headers'); |
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.
const twoWpTests = require('../lib/tests/post_iris_call_receive_headers'); | |
const receiveHeadersTests = require('../lib/tests/post_iris_call_receive_headers'); |
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.
Check the same on the remaining files
@@ -0,0 +1,3 @@ | |||
const twoWpTests = require('../lib/tests/post_iris_call_receive_headers'); | |||
|
|||
twoWpTests.execute('Calling receiveHeaders after arrowhead600', () => Runners.hosts.federate.host); |
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.
twoWpTests.execute('Calling receiveHeaders after arrowhead600', () => Runners.hosts.federate.host); | |
twoWpTests.execute('Calling receiveHeaders after last fork is active', () => Runners.hosts.federate.host); |
If we put here after arrowhead
then we'll need to update this every time a new rskj version is released
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.
Check the other files also
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.
Also the file naming seems a bit confusing. 03
prefix means that the latest fork is active, right? So no need to call each file last_fork_active....
And what's the logic for the numbers following 03_? Some are 01, 03, 50, etc
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 guess we are just following the line / list to keep the order of execution... @ed-iov ?
03_02_01-last_fork_active_powpeg_redeem_script.js
03_03_54-last_fork_active_call_receive_headers.js
03_03_55-last_fork_active_call_receive_header.js
04_00_01-key_control_initial_federation.js
04_00_02-fedchange.js
04_00_03-key_control_second_federation.js
04_00_04-2wp_after_fedchange.js
04_00_05-fastbridge_operation_with_rejection.js
04_00_06-fastbridge_after_fed_change.js
05_00_01-fee_per_kb.js
05_02_01-last_fork_active_powpeg_redeem_script.js
05_03_54-last_fork_active_call_receive_headers.js
05_03_55-last_fork_active_call_receive_header.js
the 54 / 55 comes from the original name. so i believe these can be skipped or replaced with 00...
const blockHeader = await btcTxHelper.getBlockHeader(blockHashes[0], false); | ||
const blockchainInitialHeigth = await bridge.methods.getBtcBlockchainBestChainHeight().call(); | ||
|
||
await sendTxWithCheck( |
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.
Can we put the method call and the callback in the own variables? It will make it easier to read
rskTxHelper, | ||
bridge.methods.receiveHeader(ensure0x(blockHeader)), | ||
cowAddress, | ||
(result) => { expect(Number(result)).to.be.equal(0) } |
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.
The expected result 0
should also probably be in it's own constant. It will make it much clearer to understand
const blockHashes = await btcTxHelper.mine(); | ||
const blockHeader = await btcTxHelper.getBlockHeader(blockHashes[0], false); | ||
const result = await bridge.methods.receiveHeader(ensure0x(blockHeader)).call(); | ||
expect(result).to.be.equal('-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.
Same with this value, perhaps we could have a file with receive header response codes
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 would probably put just first 2 in the test file it's self...
why keep the rest if we don't use them?
const HEADER_RECEIVED = 0
const RECEIVE_HEADER_CALLED_TOO_SOON = -1;
const RECEIVE_HEADER_BLOCK_TOO_OLD = -2;
const RECEIVE_HEADER_CANT_FOUND_PREVIOUS_BLOCK = -3;
const RECEIVE_HEADER_BLOCK_PREVIOUSLY_SAVED = -4;
const RECEIVE_HEADER_UNEXPECTED_EXCEPTION = -99;
await activateFork(Runners.common.forks[forkName]); | ||
}; | ||
|
||
const execute = (description, getRskHost) => { |
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.
Not part of this ticket but I guess we should consider adding new test cases for the different error codes this method can return.
cc @ed-iov
const bridge = getBridge(rskTxHelper.getClient(), await getLatestActiveForkName()); | ||
const blockNumberInitial = await bridge.methods.getBtcBlockchainBestChainHeight().call(); | ||
const cowAddress = await rskTxHelper.newAccountWithSeed('cow'); | ||
const blockHashes = await btcTxHelper.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.
Should we also all call updateBridge here as in receiveHeader
test to make sure that the Bridge is up to date and that we a re informing a valid block?
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.
not sure, it was in the original test for receiveHeader but not int the receiveHeaders one... @jeremy-then ??
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.
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.
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.
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.
Looks good now, just a minor comment. I'm not sure about adding last_fork_active
prefix to all files though, what's the purpose? I thought that the number prefix 03, 04, 05 already indicates that the last fork is active, right?
lib/tests/call_receive_header.js
Outdated
@@ -9,6 +9,9 @@ let rskTxHelper; | |||
let btcTxHelper; | |||
let bridge; | |||
|
|||
const HEADER_RECEIVED_OK = 0; | |||
const RECEIVE_HEADER_CALLED_TOO_SOON = "-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.
why string?
lib/tests/call_receive_header.js
Outdated
const blockHashes = await btcTxHelper.mine(); | ||
const blockHeader = await btcTxHelper.getBlockHeader(blockHashes[0], false); | ||
const result = await bridge.methods.receiveHeader(ensure0x(blockHeader)).call(); | ||
expect(result).to.be.equal(RECEIVE_HEADER_CALLED_TOO_SOON); |
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.
expect(result).to.be.equal(RECEIVE_HEADER_CALLED_TOO_SOON); | |
expect(Number(result)).to.be.equal(RECEIVE_HEADER_CALLED_TOO_SOON); |
That should do it
Quality Gate passedKudos, no new issues were introduced! 0 New issues |
pipeline:run |
1 similar comment
pipeline:run |
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.