-
Notifications
You must be signed in to change notification settings - Fork 38.7k
TestNode tidyups #11121
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
TestNode tidyups #11121
Conversation
d3c2ea2 to
06bde74
Compare
maflcko
left a comment
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.
Concept ACK after quick glance
test/functional/txn_clone.py
Outdated
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 prefer to explicitly set the network topology and initial state of the chain.
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.
Faint agreement. It's easy to forget and start up 4 nodes when you only really need 2, for example. Not seeing the number of nodes makes that even harder to remember.
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.
Sounds good. I've added a new commit that makes setting self.num_nodes mandatory. I haven't done the same for self.setup_clean_chain, since I think it makes more sense for that to have a default. If people feel strongly, it can be added in a future commit.
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 raise RuntimeError('Not implemented') to enforce the docstring.
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.
Yes - done
kallewoof
left a comment
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.
utACK 06bde74f5ec8660975275f8594aee3a99064e327
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.
Since self knows about self.options.tmpdir, and all calls to self.add_nodes passes self.options.tmpdir as dirname argument, it seems clean to just give it a default None and to set to self.options.tmpdir if None in add_nodes.
Or perhaps remove it entirely and always use self.options.tmpdir. Will it ever be anything else?
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 point. Thanks! Added this in a new commit.
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.
extra_args=None, stderr=None maybe?
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.
TestNode.start is only ever called by TestFramework.start_node, which has its own default for extra_args, so not strictly necessary, but I agree having a default here makes it clearer. Added.
test/functional/txn_clone.py
Outdated
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.
Faint agreement. It's easy to forget and start up 4 nodes when you only really need 2, for example. Not seeing the number of nodes makes that even harder to remember.
test/functional/wallet.py
Outdated
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 does it not just add_nodes(3, ..) here and then add/start/connect the fourth node below? That would remove a lot of necessary [self.nodes[0:3]] stuff.
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.
Because there's not currently a method to add a single node. The model after this PR is to add all nodes at the top of the test and then start/stop them as required during the test.
We could potentially add an add_node() method to be called during the test, but lets leave that for a future PR.
06bde74 to
e67f8d9
Compare
|
@MarcoFalke @kallewoof - thanks for the review. I think I've responded to all your comments. New commits pushed, and rebased on master. |
e67f8d9 to
df824a9
Compare
|
utACK df824a9 |
promag
left a comment
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.
Have you thought of not having any node started automatically? There are some tests that start with stop_node(0)..
So eachrun_test(self) the nodes are explicitly started, num_nodes can go away, even setup_clean_chain would be a start_node argument.
test/functional/assumevalid.py
Outdated
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 there are more setup_clean_chain = True so why not make it the default?
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 haven't made any changes to setup_clean_chain. See earlier comment:
I haven't done the same for self.setup_clean_chain, since I think it makes more sense for that to have a default. If people feel strongly, it can be added in a future commit.
Feel free to open a PR to change/remove the default if you think that's necessary. I don't think it's required for this PR.
|
Thanks for the reivew @promag
Tests that don't need their nodes to start should override the
|
test/functional/bumpfee.py
Outdated
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 already done by setup_network.
Same for the line below.
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.
L41 stops node 1 (the encryptwallet RPC shuts down the node), so I believe all the p2p connections are lost and we need to reconnect the nodes after restarting node 1.
I've tested removing these two lines and the test fails (the next call to sync_all() fails)
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.
Sorry, missed that the node shuts down.
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.
utACK df824a92121eb68849e474e87098a441d4e52926
test/functional/pruning.py
Outdated
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 are removing timewait=900 from all calls but the first. I assume this does not cause issues?
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.
rpc_timeout is a property of TestNode set when instantiating the python object, not when starting up the bitcoind node.
test/functional/wallet.py
Outdated
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.
debug statement?
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.
derp. Fixed
test/functional/wallet.py
Outdated
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.
debug statement?
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.
yep
test/functional/wallet.py
Outdated
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 not self.nodes[:3]?
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.
fixed
test/functional/wallet.py
Outdated
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 not self.nodes[:3]?
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.
fixed
test/functional/zapwallettxes.py
Outdated
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 is this changed in a refactoring commit?
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.
fixed
Separates the act of creating a TestNode object from starting the node. The test_framework now keeps track of its list of TestNodes, and test writers can call start_node() and stop_node() without having to update the self.nodes list.
Almost all test scripts currently need to override the __init__() method. When they do that they need to call into super().__init__() as the base class does some generic initialization. This commit makes the base class __init__() call into set_test_params() method. Individual test cases can override set_test_params() to setup their test parameters.
df824a9 to
7148b74
Compare
|
Thanks @MarcoFalke . Review comments addressed. |
|
re-utACK 7148b74 |
7148b74 [tests] Functional tests must explicitly set num_nodes (John Newbery) 5448a14 [tests] don't override __init__() in individual tests (John Newbery) 6cf094a [tests] Avoid passing around member variables in test_framework (John Newbery) 36b6268 [tests] TestNode: separate add_node from start_node (John Newbery) be2a2ab [tests] fix - use rpc_timeout as rpc timeout (John Newbery) Pull request description: Some additional tidyups after the introduction of TestNode: - commit 1 makes TestNode use the correct rpc timeout. This should have been included in #11077 - commit 2 separates `add_node()` from `start_node()` as originally discussed here: #10556 (comment) with @kallewoof . The test writer no longer needs to assign to `self.nodes` when starting/stopping nodes. - commit 3 adds a `set_test_params()` method, so individual tests don't need to override `__init__()` and call `super().__init__()` Tree-SHA512: 0adb030623b96675b5c29e2890ce99ccd837ed05f721d0c91b35378c5ac01b6658174aac12f1f77402e1d38b61f39b3c43b4df85c96952565dde1cda05b0db84
3918d93 [tests] fixups from set_test_params() (John Newbery) Pull request description: #11121 had a silent merge conflict in `bitcoin_cli.py`. This fixes it. Also fixes a comment in `example_test.py` Tree-SHA512: f22a645c51c9aeda005526338ad6f2ee07f2bab172847fc54f51fecf1c79e778970be61e5e637d4e0aba3a02e5aba0737b0b57f1bc11a514a1acd94c221b54d6
8fdb6f9 [tests] fixup dbcrash interaction with add_nodes() (John Newbery) Pull request description: Another conflict with #11121. Apologies - this is entirely my fault. I didn't run the extended test suite after rebasing on master. @MarcoFalke @sdaftuar Tree-SHA512: eefce1d1c63dc4a63c5e030a541e046ad4832e8a709c0a8aad40ffdc4712b2065486778b406dfa57cfd34e66db86064278ee3fea8f2c2afd2390772875e6fa3e
…nt future similar errors f97ab35 qa: Fix bug introduced in p2p-segwit.py (Suhas Daftuar) a782042 qa: Treat mininode p2p exceptions as fatal (Suhas Daftuar) Pull request description: #11121 inadvertently broke the constructor for the `TestNode()` object in `p2p-segwit.py`, silently breaking at least one of the tests. Although the python code was raising exceptions due to a `TestNode()` object not existing (or having the right type), mininode was masking these from anyone running the test through the test_runner (like travis), because it catches all exceptions during message delivery and just prints a log message and continues. Such "graceful" handling of errors is almost certainly something we don't want in our test suite, so the first commit here attempts to prevent that type of failure from ever being masked. The second commit fixes the particular bug in `p2p-segwit.py`. Tree-SHA512: b6646e3cb1e05c35c28e8899c44104bf2e2d0384643ca87042ab7f6ec0960d89f5bf25a7b95bab6e32d401c20a6018226160500f6ddceb923e81ffb04adb4f2f
Github-Pull: bitcoin#11121 Rebased-From: be2a2ab
Separates the act of creating a TestNode object from starting the node. The test_framework now keeps track of its list of TestNodes, and test writers can call start_node() and stop_node() without having to update the self.nodes list. Github-Pull: bitcoin#11121 Rebased-From: 36b6268
Github-Pull: bitcoin#11121 Rebased-From: 6cf094a
Almost all test scripts currently need to override the __init__() method. When they do that they need to call into super().__init__() as the base class does some generic initialization. This commit makes the base class __init__() call into set_test_params() method. Individual test cases can override set_test_params() to setup their test parameters. Github-Pull: bitcoin#11121 Rebased-From: 5448a14
Github-Pull: bitcoin#11121 Rebased-From: 7148b74
7148b74 [tests] Functional tests must explicitly set num_nodes (John Newbery) 5448a14 [tests] don't override __init__() in individual tests (John Newbery) 6cf094a [tests] Avoid passing around member variables in test_framework (John Newbery) 36b6268 [tests] TestNode: separate add_node from start_node (John Newbery) be2a2ab [tests] fix - use rpc_timeout as rpc timeout (John Newbery) Pull request description: Some additional tidyups after the introduction of TestNode: - commit 1 makes TestNode use the correct rpc timeout. This should have been included in bitcoin#11077 - commit 2 separates `add_node()` from `start_node()` as originally discussed here: bitcoin#10556 (comment) with @kallewoof . The test writer no longer needs to assign to `self.nodes` when starting/stopping nodes. - commit 3 adds a `set_test_params()` method, so individual tests don't need to override `__init__()` and call `super().__init__()` Tree-SHA512: 0adb030623b96675b5c29e2890ce99ccd837ed05f721d0c91b35378c5ac01b6658174aac12f1f77402e1d38b61f39b3c43b4df85c96952565dde1cda05b0db84
3918d93 [tests] fixups from set_test_params() (John Newbery) Pull request description: bitcoin#11121 had a silent merge conflict in `bitcoin_cli.py`. This fixes it. Also fixes a comment in `example_test.py` Tree-SHA512: f22a645c51c9aeda005526338ad6f2ee07f2bab172847fc54f51fecf1c79e778970be61e5e637d4e0aba3a02e5aba0737b0b57f1bc11a514a1acd94c221b54d6
8fdb6f9 [tests] fixup dbcrash interaction with add_nodes() (John Newbery) Pull request description: Another conflict with bitcoin#11121. Apologies - this is entirely my fault. I didn't run the extended test suite after rebasing on master. @MarcoFalke @sdaftuar Tree-SHA512: eefce1d1c63dc4a63c5e030a541e046ad4832e8a709c0a8aad40ffdc4712b2065486778b406dfa57cfd34e66db86064278ee3fea8f2c2afd2390772875e6fa3e
Some additional tidyups after the introduction of TestNode:
add_node()fromstart_node()as originally discussed here: Move stop/start functions from utils.py into BitcoinTestFramework #10556 (comment) with @kallewoof . The test writer no longer needs to assign toself.nodeswhen starting/stopping nodes.set_test_params()method, so individual tests don't need to override__init__()and callsuper().__init__()