Skip to content

Conversation

promag
Copy link
Contributor

@promag promag commented Aug 22, 2018

At the moment the new test checks for:

  • invalid usages
  • expected output for unknown command
  • current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test

@promag
Copy link
Contributor Author

promag commented Aug 22, 2018

Follow up of #13945 (comment)

@fanquake fanquake added the Tests label Aug 22, 2018
@isghe
Copy link
Contributor

isghe commented Aug 22, 2018

missing hidden category

@isghe
Copy link
Contributor

isghe commented Aug 22, 2018

missing test category (in Qt)

@promag
Copy link
Contributor Author

promag commented Aug 22, 2018

missing hidden category

It's hidden to the RPC client, and has special treatment in

if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)

@isghe
Copy link
Contributor

isghe commented Aug 22, 2018

How can be sure, external scripts analysing C/C++ Bitcoin source code, are immune to injection?

@isghe
Copy link
Contributor

isghe commented Aug 22, 2018

I would prefer a C/C++ compile time security check, not an external script security check.

@promag
Copy link
Contributor Author

promag commented Aug 22, 2018

missing test category (in Qt)

I'm not following, in Qt?

How can be sure, external scripts analysing C/C++ Bitcoin source code, are immune to injection?

What is subject to injection here?

I would prefer a C/C++ compile time security check, not an external script security check.

There is still room to that, this test file can check for other stuff, like output is sorted, formatting.

@isghe
Copy link
Contributor

isghe commented Aug 22, 2018

worst, I understood only now: it looks it is working on ./bitcoin-cli help output!

@isghe
Copy link
Contributor

isghe commented Aug 22, 2018

I'm not following, in Qt?

I found this (as I wrote here #13945 in the p.s: anyway I was able to catch the QT command rpcNestedTest.)

in file src/qt/test/rpcnestedtests.cpp line 32:

static const CRPCCommand vRPCCommands[] =
{
    { "test", "rpcNestedTest", &rpcNestedTest_rpc, {} },
};

Anyway take care, I always configure --without-gui, I usually (read it: ALWAYS) don't take care about QT.

@promag
Copy link
Contributor Author

promag commented Aug 22, 2018

Oh, that doesn't matter IMO.

@l2a5b1
Copy link
Contributor

l2a5b1 commented Aug 22, 2018

Thanks @promag!

Would it be an idea to assert that the actual titles are valid (i.e. not map the titles back to categories)?

I think this is more in spirit of a functional test and the test can then also assert that there are no true negatives (for example: "== Hidden ==", "== hidden ==", "== blockchain ==","== ==").

@promag
Copy link
Contributor Author

promag commented Aug 22, 2018

@251labs I'll update.

@promag promag force-pushed the 2018-08-test-help branch from 31e285d to 6af6d9b Compare August 23, 2018 00:39
@promag promag changed the title Assert RPC command categories Add tests for RPC help Aug 23, 2018
@promag
Copy link
Contributor Author

promag commented Aug 23, 2018

@251labs updated.

@l2a5b1
Copy link
Contributor

l2a5b1 commented Aug 24, 2018

utACK 6af6d9b

Thanks @promag! Maybe a small nit would be to assert against the full category title to catch potentially missing title suffixes (==). Other than this nit LGTM.

@isghe
Copy link
Contributor

isghe commented Aug 25, 2018

I am not an expert about functional test, and their implementations; but I like to learn new things, that's why I am asking (maybe stupid) question.

In this kind of functional and deterministic test, wouldn't be easier simply to check the sha256 output?

$ ./src/bitcoin-cli help | sha256
2ae3a94e05bbb98323f72f19272bde01f075db16c7e4357bc46815a1393cd44a

thanks :-)

@@ -152,6 +152,7 @@
'p2p_node_network_limited.py',
'feature_blocksdir.py',
'feature_config_args.py',
'rpc_help.py',
'feature_help.py',
Copy link
Member

Choose a reason for hiding this comment

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

Imo this could be combined into the feature_help test. Just adding a new function there def rpc_help(self): ... and moving the other code into def cli_help(self): ....

Copy link
Member

Choose a reason for hiding this comment

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

hmm not sure about this, my first intuition was to agree with you but now I think RPC help and options help are sufficiently different concepts (and in code) to have as separate tests
But I'll leave it to @promag

@promag
Copy link
Contributor Author

promag commented Aug 29, 2018

I tend to prefer like this because

  • follows current convention
  • more little test files is more "readable" than less bigger test files
  • more files allows parallelization

@maflcko maflcko merged commit 6af6d9b into bitcoin:master Aug 29, 2018
maflcko pushed a commit that referenced this pull request Aug 29, 2018
6af6d9b test: Add tests for RPC help (João Barbosa)

Pull request description:

  At the moment the new test checks for:
   - invalid usages
   - expected output for unknown command
   - current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test

Tree-SHA512: f987535d001b1cd300656588602b1634099ea68a1dd2282180c30fa56caf7f990be9e2dc86c7431dfcf7fd686d0299a8d4935df178a2c9f0fb6fbebcba748eb5

# command titles
titles = [line[3:-3] for line in node.help().splitlines() if line.startswith('==')]
assert_equal(titles, ['Blockchain', 'Control', 'Generating', 'Mining', 'Network', 'Rawtransactions', 'Util', 'Wallet', 'Zmq'])
Copy link
Member

Choose a reason for hiding this comment

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

zmq is only available when installed. Should check for that like the other zmq tests?

@promag promag deleted the 2018-08-test-help branch September 2, 2018 21:02
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Oct 25, 2018
toxeus pushed a commit to toxeus/bitcoin that referenced this pull request Nov 28, 2018
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 27, 2021
6af6d9b test: Add tests for RPC help (João Barbosa)

Pull request description:

  At the moment the new test checks for:
   - invalid usages
   - expected output for unknown command
   - current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test

Tree-SHA512: f987535d001b1cd300656588602b1634099ea68a1dd2282180c30fa56caf7f990be9e2dc86c7431dfcf7fd686d0299a8d4935df178a2c9f0fb6fbebcba748eb5
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 28, 2021
6af6d9b test: Add tests for RPC help (João Barbosa)

Pull request description:

  At the moment the new test checks for:
   - invalid usages
   - expected output for unknown command
   - current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test

Tree-SHA512: f987535d001b1cd300656588602b1634099ea68a1dd2282180c30fa56caf7f990be9e2dc86c7431dfcf7fd686d0299a8d4935df178a2c9f0fb6fbebcba748eb5
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 29, 2021
6af6d9b test: Add tests for RPC help (João Barbosa)

Pull request description:

  At the moment the new test checks for:
   - invalid usages
   - expected output for unknown command
   - current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test

Tree-SHA512: f987535d001b1cd300656588602b1634099ea68a1dd2282180c30fa56caf7f990be9e2dc86c7431dfcf7fd686d0299a8d4935df178a2c9f0fb6fbebcba748eb5
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 29, 2021
6af6d9b test: Add tests for RPC help (João Barbosa)

Pull request description:

  At the moment the new test checks for:
   - invalid usages
   - expected output for unknown command
   - current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test

Tree-SHA512: f987535d001b1cd300656588602b1634099ea68a1dd2282180c30fa56caf7f990be9e2dc86c7431dfcf7fd686d0299a8d4935df178a2c9f0fb6fbebcba748eb5
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 29, 2021
6af6d9b test: Add tests for RPC help (João Barbosa)

Pull request description:

  At the moment the new test checks for:
   - invalid usages
   - expected output for unknown command
   - current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test

Tree-SHA512: f987535d001b1cd300656588602b1634099ea68a1dd2282180c30fa56caf7f990be9e2dc86c7431dfcf7fd686d0299a8d4935df178a2c9f0fb6fbebcba748eb5
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 29, 2021
6af6d9b test: Add tests for RPC help (João Barbosa)

Pull request description:

  At the moment the new test checks for:
   - invalid usages
   - expected output for unknown command
   - current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test

Tree-SHA512: f987535d001b1cd300656588602b1634099ea68a1dd2282180c30fa56caf7f990be9e2dc86c7431dfcf7fd686d0299a8d4935df178a2c9f0fb6fbebcba748eb5
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 29, 2021
6af6d9b test: Add tests for RPC help (João Barbosa)

Pull request description:

  At the moment the new test checks for:
   - invalid usages
   - expected output for unknown command
   - current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test

Tree-SHA512: f987535d001b1cd300656588602b1634099ea68a1dd2282180c30fa56caf7f990be9e2dc86c7431dfcf7fd686d0299a8d4935df178a2c9f0fb6fbebcba748eb5
Munkybooty pushed a commit to Munkybooty/dash that referenced this pull request Jun 30, 2021
6af6d9b test: Add tests for RPC help (João Barbosa)

Pull request description:

  At the moment the new test checks for:
   - invalid usages
   - expected output for unknown command
   - current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test

Tree-SHA512: f987535d001b1cd300656588602b1634099ea68a1dd2282180c30fa56caf7f990be9e2dc86c7431dfcf7fd686d0299a8d4935df178a2c9f0fb6fbebcba748eb5
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
6af6d9b test: Add tests for RPC help (João Barbosa)

Pull request description:

  At the moment the new test checks for:
   - invalid usages
   - expected output for unknown command
   - current RPC command titles (derived from command categories) — this prevents adding wrong RPC categories and new categories must be added to the test

Tree-SHA512: f987535d001b1cd300656588602b1634099ea68a1dd2282180c30fa56caf7f990be9e2dc86c7431dfcf7fd686d0299a8d4935df178a2c9f0fb6fbebcba748eb5
@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.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants