-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Add test coverage for bitcoin-cli multiwallet calls #11970
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
Conversation
utACK b67bd3d |
if variant: | ||
self.tmpdir = os.path.join(self.options.tmpdir, variant) | ||
os.mkdir(self.tmpdir) | ||
success = self.run_variant() |
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'd prefer if this was renamed to status
.
Also, we don't support different statūs for variants, since the test runner has to print one status per test script. Thus, I'd prefer if the result of run_variant
was appended to the list status
and then (outside the for loop):
- All statūs the same =>
sys.exit(TEST_EXIT_${STATUS})
- Different statūs, probably best to exit with failure.
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.
Will rename. The behavior you're describing is what I was intending and what should happen after fixing the bug below (no need for an array/list just to return one status).
self.tmpdir = os.path.join(self.options.tmpdir, variant) | ||
os.mkdir(self.tmpdir) | ||
success = self.run_variant() | ||
if success == TestStatus.SKIPPED and exit_code == TEST_EXIT_PASSED: |
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.
Skipping a test for different variant will result in FAILED
instead of SKIPPED
, no?
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.
Will fix.
Concept ACK 963315d |
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 b67bd3d.
test/functional/multiwallet.py
Outdated
|
||
def run_test(self): | ||
assert_equal(set(self.nodes[0].listwallets()), {"w1", "w2", "w3", "w"}) | ||
data_dir = lambda *p: os.path.join(self.nodes[0].datadir, 'regtest', *p) |
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.
Rebase with #12076 instead?
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.
Rebase with #12076 instead?
I think #11687 does a better job of cleaning up this particular test than #12076. But in general my preference is to resolve conflicts when they arise instead of adding unnecessary dependencies between prs to avoid conflicts. Better for prs to be smaller, more targeted, with fewer dependencies when this is possible, because reviewing changes requires more effort than resolving simple merge conflicts.
test/functional/multiwallet.py
Outdated
@@ -17,69 +17,78 @@ def set_test_params(self): | |||
self.setup_clean_chain = True | |||
self.num_nodes = 1 | |||
self.extra_args = [['-wallet=w1', '-wallet=w2', '-wallet=w3', '-wallet=w']] | |||
self.variants = ["rpc", "cli"] |
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.
BTW, I thought of:
self.matrix = { mode: ['rpc', 'cli'], foo: ... }
Which would generate all combinations.
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.
What is the suggestion? That seems identical to current test except it renames things and adds a foo.
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 if it was not clear. The suggestion is to support combinations. A more decent example:
self.matrix = { a: ['a1', 'a2'], b: ['b1', 'b2', 'b3'] }
This would call 6 times run_test
.
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 be added when needed, i.e. later.
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.
Sure, I didn't mean to do it here. Variants is enough in this PR.
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.
@jnewbery it would be good to have feedback on the idea of supporting test variants, and on the locations of log / data files with variants since it may impact utils like combine_logs and test_runner.
Marking WIP, since this needs design feedback and at least one bugfix, and there are other PRs I'd prioritize.
if variant: | ||
self.tmpdir = os.path.join(self.options.tmpdir, variant) | ||
os.mkdir(self.tmpdir) | ||
success = self.run_variant() |
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.
Will rename. The behavior you're describing is what I was intending and what should happen after fixing the bug below (no need for an array/list just to return one status).
self.tmpdir = os.path.join(self.options.tmpdir, variant) | ||
os.mkdir(self.tmpdir) | ||
success = self.run_variant() | ||
if success == TestStatus.SKIPPED and exit_code == TEST_EXIT_PASSED: |
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.
Will fix.
test/functional/multiwallet.py
Outdated
@@ -17,69 +17,78 @@ def set_test_params(self): | |||
self.setup_clean_chain = True | |||
self.num_nodes = 1 | |||
self.extra_args = [['-wallet=w1', '-wallet=w2', '-wallet=w3', '-wallet=w']] | |||
self.variants = ["rpc", "cli"] |
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.
What is the suggestion? That seems identical to current test except it renames things and adds a foo.
Parse JSONRPCException errors, and avoid JSON decode exception if RPC method returns a plain string.
Change TestNodeCLI.__call__() to return a new instance instead of modifying the existing instance. This way, it's possible to create different cli objects that have their own options (for example -rpcwallet options to connect to different wallets), and options set for a single call (`node.cli(options).method(args)`) will no longer leak into future calls.
Support same get_request and batch methods as AuthServiceProxy
I'm a weak concept NACK on the new variants logic. It seems to add a lot of machinery and obscures the test flow logic for just this one test case. Perhaps if there are wider use cases it makes sense to add this, but if it's just for this test, I don't think it makes sense. An alternative approach is to add a new parameter |
Branch looks good to me. Do you want to PR it? Happy to close this if so. |
@jnewbery the test test/functional/address_types.py sounds like a candidate from a matrix type of test. But, as you point out, it isn't worth losing the simplicity of the test framework. |
Do you mind pushing it to this PR? I'm happy to handle any review comments on my commits. |
Reset to jnewbery pr11970.1, 963315d -> f4bad31, pr/mcli.2 -> pr/mcli.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.
ACK f4bad31
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 f4bad31.
@@ -74,8 +75,11 @@ def __init__(self, i, dirname, extra_args, rpchost, timewait, binary, stderr, mo | |||
|
|||
def __getattr__(self, name): | |||
"""Dispatches any unrecognised messages to the RPC connection.""" |
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.
In commit "[tests] allow tests to be run with --usecli"
Improve 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.
fixed
@@ -113,6 +116,8 @@ def main(self): | |||
success = TestStatus.FAILED | |||
|
|||
try: | |||
if self.options.usecli and not self.supports_cli: | |||
raise SkipTest("--usecli specificed but test does not support using CLI") |
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 SkipTest
? IMO should fail immediately in the test runner.
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 allows --usecli
to be passed to test_runner and any tests that don't support --usecli
will be skipped:
./test_runner.py --usecli
[...]
TEST | STATUS | DURATION
abandonconflict.py | ○ Skipped | 2 s
bip65-cltv-p2p.py | ○ Skipped | 2 s
[...]
multiwallet.py | ✓ Passed | 4 s
multiwallet.py --usecli | ✓ Passed | 4 s
[...]
zmq_test.py | ○ Skipped | 2 s
ALL | ✓ Passed | 140 s (accumulated)
Runtime: 36 s
I have however fixed the typo in the exception message.
test_framework accepts a new --usecli parameter. Running the test with this parameter will cause all RPCs to be sent through bitcoin-cli rather than directly over http. By default, individual test cases do not support --usecli, and self.supports_cli must be set to True in the set_test_params method. We can make supports_cli default to True in future once we know which tests will fail with use_cli.
Add test coverage for bitcoin-cli multiwallet calls.
ACK a14dbff. Running a single also works as expected IMO: ./test/functional/abandonconflict.py --usecli && echo should not echo
2018-01-08 23:05:51.549000 TestFramework (WARNING): Test Skipped: --usecli specified but test does not support using CLI
2018-01-08 23:05:51.549000 TestFramework (INFO): Stopping nodes
2018-01-08 23:05:51.549000 TestFramework (INFO): Cleaning up
2018-01-08 23:05:51.550000 TestFramework (INFO): Test skipped |
ACK a14dbff (obviously, since I authored it!) |
|
a14dbff Allow multiwallet.py to be used with --usecli (Russell Yanofsky) f6ade9c [tests] allow tests to be run with --usecli (John Newbery) ff9a363 TestNodeCLI batch emulation (Russell Yanofsky) ca9085a Prevent TestNodeCLI.args mixups (Russell Yanofsky) fcfb952 Improve TestNodeCLI output parsing (Russell Yanofsky) Pull request description: Lack of test coverage was pointed out by @jnewbery in #11687 (comment) Tree-SHA512: 5f10e31abad11a5edab0da4e2515e39547adb6ab9e55e50427ab2eb7ec9a43d6b896b579b15863e5edc9beee7d8bf1c84d9dabd247be0760a1b9ae39e1e8ee02
a14dbff Allow multiwallet.py to be used with --usecli (Russell Yanofsky) f6ade9c [tests] allow tests to be run with --usecli (John Newbery) ff9a363 TestNodeCLI batch emulation (Russell Yanofsky) ca9085a Prevent TestNodeCLI.args mixups (Russell Yanofsky) fcfb952 Improve TestNodeCLI output parsing (Russell Yanofsky) Pull request description: Lack of test coverage was pointed out by @jnewbery in bitcoin#11687 (comment) Tree-SHA512: 5f10e31abad11a5edab0da4e2515e39547adb6ab9e55e50427ab2eb7ec9a43d6b896b579b15863e5edc9beee7d8bf1c84d9dabd247be0760a1b9ae39e1e8ee02
a14dbff Allow multiwallet.py to be used with --usecli (Russell Yanofsky) f6ade9c [tests] allow tests to be run with --usecli (John Newbery) ff9a363 TestNodeCLI batch emulation (Russell Yanofsky) ca9085a Prevent TestNodeCLI.args mixups (Russell Yanofsky) fcfb952 Improve TestNodeCLI output parsing (Russell Yanofsky) Pull request description: Lack of test coverage was pointed out by @jnewbery in bitcoin#11687 (comment) Tree-SHA512: 5f10e31abad11a5edab0da4e2515e39547adb6ab9e55e50427ab2eb7ec9a43d6b896b579b15863e5edc9beee7d8bf1c84d9dabd247be0760a1b9ae39e1e8ee02
… such Summary: The option `--usecli` was added to test_framework in [[bitcoin/bitcoin#11970 | PR11970]]. Running the test with this parameter will cause all RPCs to be sent through `bitcoin-cli` rather than directly over http. But the test were not all annotated accordingly. 74 tests were unnecessarily skipped. Explicitely annotating the tests that do not support this option will allow to make this lack of support the exception, and identify these tests clearly as needing to be fixed in the future. This commit has currently no effect, as `self.supports_cli` is still considered `False` by default. This will be changed in the next commit. In addition to the tests skipped in the Core PR, I also found the following tests to not support `--usecli`: - `abc_wallet_standardness`: `TypeError: Object of type 'Decimal' is not JSON serializable` (will be fixed when backporting PR17705) - `abc-magnetic-anomaly-mining`: idem - `p2p_blocksonly`: idem - `rpc_whitelist`: `AttributeError: 'NoneType' object has no attribute 'rfind'` (this test was added after PR17675 and should have been skipped in Core as well) - `abc_p2p_fullblocktest`: `OSError: [Errno 7] Argument list too long: '.../bitcoin-abc/build/src/bitcoin-cli'` - `wallet_groups` : idem This is a backport of Core [[bitcoin/bitcoin#17675 | PR17675]] [1/2] bitcoin/bitcoin@993e38a Test Plan: `test/functional/test_runner.py --usecli` Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D8316
a14dbff Allow multiwallet.py to be used with --usecli (Russell Yanofsky) f6ade9c [tests] allow tests to be run with --usecli (John Newbery) ff9a363 TestNodeCLI batch emulation (Russell Yanofsky) ca9085a Prevent TestNodeCLI.args mixups (Russell Yanofsky) fcfb952 Improve TestNodeCLI output parsing (Russell Yanofsky) Pull request description: Lack of test coverage was pointed out by @jnewbery in bitcoin#11687 (comment) Tree-SHA512: 5f10e31abad11a5edab0da4e2515e39547adb6ab9e55e50427ab2eb7ec9a43d6b896b579b15863e5edc9beee7d8bf1c84d9dabd247be0760a1b9ae39e1e8ee02
Lack of test coverage was pointed out by @jnewbery in #11687 (comment)