Skip to content

Conversation

ryanofsky
Copy link
Contributor

Lack of test coverage was pointed out by @jnewbery in #11687 (comment)

@jonasschnelli
Copy link
Contributor

utACK b67bd3d

@laanwj laanwj added the Wallet label Dec 21, 2017
if variant:
self.tmpdir = os.path.join(self.options.tmpdir, variant)
os.mkdir(self.tmpdir)
success = self.run_variant()
Copy link
Member

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.

Copy link
Contributor Author

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:
Copy link
Member

@maflcko maflcko Jan 4, 2018

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix.

@maflcko
Copy link
Member

maflcko commented Jan 4, 2018

Concept ACK 963315d

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK b67bd3d.


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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase with #12076 instead?

Copy link
Contributor Author

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.

@@ -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"]
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Member

@maflcko maflcko Jan 4, 2018

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@ryanofsky ryanofsky left a 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()
Copy link
Contributor Author

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:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix.

@@ -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"]
Copy link
Contributor Author

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.

@ryanofsky ryanofsky changed the title Add test coverage for bitcoin-cli multiwallet calls WIP: Add test coverage for bitcoin-cli multiwallet calls Jan 4, 2018
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
@jnewbery
Copy link
Contributor

jnewbery commented Jan 8, 2018

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 --usecli to the test framework, which could be used by any test (or most of the tests). I've made a branch that does that here: https://github.com/jnewbery/bitcoin/tree/pr11970.1. @ryanofsky - let me know what you think.

@ryanofsky
Copy link
Contributor Author

Branch looks good to me. Do you want to PR it? Happy to close this if so.

@promag
Copy link
Contributor

promag commented Jan 8, 2018

@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.

@jnewbery
Copy link
Contributor

jnewbery commented Jan 8, 2018

Do you want to PR it?

Do you mind pushing it to this PR? I'm happy to handle any review comments on my commits.

@ryanofsky
Copy link
Contributor Author

Reset to jnewbery pr11970.1, 963315d -> f4bad31, pr/mcli.2 -> pr/mcli.3

@ryanofsky ryanofsky changed the title WIP: Add test coverage for bitcoin-cli multiwallet calls Add test coverage for bitcoin-cli multiwallet calls Jan 8, 2018
Copy link
Contributor Author

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK f4bad31

Copy link
Contributor

@promag promag left a 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."""
Copy link
Contributor

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.

Copy link
Contributor

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")
Copy link
Contributor

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.

Copy link
Contributor

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.

jnewbery and others added 2 commits January 8, 2018 17:35
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.
@promag
Copy link
Contributor

promag commented Jan 8, 2018

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

@jnewbery
Copy link
Contributor

ACK a14dbff (obviously, since I authored it!)

@maflcko
Copy link
Member

maflcko commented Jan 12, 2018

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

utACK a14dbff39ea050b74b32bb0f4cbb59f4a9ad3865
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJaWTVJAAoJENLqSFDnUoslFMUP/3Hu8h6cSYR9WEKdLvai2oM2
ZSECynk2MWyLH2vuRw0b5Mw/+eEoEgQsd/CTrRsQLJTr0xg6ymFK6FBhiZYM4++k
SSG8WtpoMiWokOvkqTMz4v/plLs5oa9t++HYq13L/hVoi0p9oFbUxa/0/dgIDeyP
gL+cPkLKN2jYWUy0e9y0KJIWWpscZeuYmKzxxsT6xyjsx9fwfrW2UdWlugx0l3Aa
nesDNv9T5rXsSNg8MLppTR5o4DcKV2yxXPdQnkg7yh18aRIEY4IdWmUnv1Vqd70l
bOsvk29Ow0VHqPK0zCO+hOxnRdU5cvWnx5nWN1o5s4R+SyGfLOW8hMDaRgZWcu2B
3xNavosyLf61fBhrZ/FJirPDmx7LBkfkcxuxO9ckvEdSjA3cyPPZyRgDo/rny/Sc
P63pY4Y5Fa/fD98d3vbTFEIzSSi/4pGEfwxYQiCTMBR5PHP6Gm5i0jfjWtFkvU4M
fRPj98KyYAwDFhz/2lFD+3dClKg5HQg7Ce84enHTq0uyMjo80CThNLIAE1tTjI/K
pzFL59PAP6wBOK4C441MZVz7d1cbONQg2Aev1i/iXWRHg3eDjIEnkIsHN9N5OsAW
D3OnIFG14umFG/02H65BBPiKNH95JPTmodPZPdTF1TgZ1gGfEJ+MLgt2yl9REmMM
Cwu4THqwjUr1ahfAVdMP
=nYAd
-----END PGP SIGNATURE-----

@maflcko maflcko merged commit a14dbff into bitcoin:master Jan 12, 2018
maflcko pushed a commit that referenced this pull request Jan 12, 2018
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
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Feb 29, 2020
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
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Mar 4, 2020
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
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Nov 10, 2020
… 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
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Jun 30, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants