Repository navigation
Add test for syncing blocks generated after invalidateblock. - #17335
TheBlueMatt wants to merge 1 commit into
Conversation
479dda1 to
1b0a68c
Compare
|
Can we turn off these lints? Who cares at all if we have some unused imports in some python tests? This seems entirely useless. |
7b3518f to
50190df
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
There was a problem hiding this comment.
for p2p, since we already have RPC tests for it(I had to look)
There was a problem hiding this comment.
Prefer to use file docstrings over code comments for the top-level comment
There was a problem hiding this comment.
I don't know what a docstrng is.
There was a problem hiding this comment.
There was a problem hiding this comment.
Take a look at the other tests, particularly https://github.com/bitcoin/bitcoin/blob/master/test/functional/example_test.py#L5 and https://github.com/bitcoin/bitcoin/blob/master/test/functional/README.md#style-guidelines. Documenting what the test is supposed to be testing and why is a courtesy to any other developer who tries to understand this in future. "Test invalidateblock" doesn't explain what this test is for.
Suhas wrote this test to demonstrate a bug in invalidateblock back in 2015, and at some point between then and now it started passing, so best to just merge it so we don't regress. Closes bitcoin#5806 (the original issue in which this test was written)
50190df to
df117c8
Compare
jnewbery
left a comment
There was a problem hiding this comment.
Getting better. You'll be a python developer soon!
There was a problem hiding this comment.
Take a look at the other tests, particularly https://github.com/bitcoin/bitcoin/blob/master/test/functional/example_test.py#L5 and https://github.com/bitcoin/bitcoin/blob/master/test/functional/README.md#style-guidelines. Documenting what the test is supposed to be testing and why is a courtesy to any other developer who tries to understand this in future. "Test invalidateblock" doesn't explain what this test is for.
| raise AssertionError("Failed to invalidate initial blocks") | ||
|
|
||
| # The test framework uses a static per-node address which will generate | ||
| # a deterministic block if we have no wallet. |
There was a problem hiding this comment.
'if we have no wallet' is inaccurate. All calls to generate in the functional test framework will generate blocks to a hardcoded address.
There was a problem hiding this comment.
I think it's slightly clearer if all blocks are generated on node0 and sync'ed to node1. It makes it more obvious to someone reading the test that this is testing node1 being able to resync to an less-work chain if it previously invalidated a different chain.
| def set_test_params(self): | ||
| self.num_nodes = 2 | ||
| self.setup_clean_chain = True | ||
| self.extra_args = [[],[]] |
There was a problem hiding this comment.
This isn't required if you're not adding any extra args.
| # than the one we previously used, making this block unique. | ||
| self.nodes[0].generate(17) | ||
|
|
||
| print("All blocks generated, trying to sync") |
There was a problem hiding this comment.
Use self.log.info() rather than print
| class InvalidateBlockTest(BitcoinTestFramework): | ||
| def set_test_params(self): | ||
| self.num_nodes = 2 | ||
| self.setup_clean_chain = True |
There was a problem hiding this comment.
If you remove this line, you can also remove the following lines from run_test:
self.nodes[0].generate(1) # Leave IBD
self.sync_all()
The test will run more quickly and it'll be clearer to readers what the test is for.
|
🐙 This pull request conflicts with the target branch and needs rebase. |
|
This has unaddressed review comments from > 6 months ago. Closing and marking 'up for grabs'. @TheBlueMatt - if you want to pick this up again, let me know and I'll reopen. |
|
Picked this up in #19397. |
Suhas wrote this test to demonstrate a bug in invalidateblock back
in 2015, and at some point between then and now it started passing,
so best to just merge it so we don't regress.
Closes #5806 (the original issue in which this test was written)