[qa/rpc-tests] A test base class instead of skeleton.py #3956

pull alonmuroch wants to merge 2 commits into bitcoin:master from alonmuroch:rpc_skeleton_class changing 3 files +145 −185
  1. alonmuroch commented at 9:22 AM on March 25, 2014: contributor

    Motivation - skeleton.py is a template for RPC tests. instead of creating a copy each time someone creates a new test (difficult to maintain and update fixes), new tests can simply inherit the Skeleton class in skeleton.py.

    What i did -

    1. Changed skeleton.py so all methods are inside a function
    2. Changed listtransactions.py to inherit from the Skeleton class, now only implements run_test
    3. added an exampe test file (TEST_EXAMPLE.py) to serve as a template for future tests.
  2. added in qa/rpc-tests a test skeleton, changed listtransactions.py accordingly and added a template for future tests named TEST_EXAMPLE.py 5b63af7632
  3. laanwj commented at 9:19 AM on March 26, 2014: member

    Not all tests may want to have the same setup steps or arguments. Defining a rigid base class limits flexibility.

    For example tests may want a different number of nodes, different command line arguments, or nodes with special configuration, etc.

    If you take this into account in a base class you may end up with some huge overdesigned system (which people have to learn before they can contribute tests).

  4. alonmuroch commented at 9:27 AM on March 26, 2014: contributor

    For very different test setups, a common base class may not work. The thing is, Gavin just made some changes to the RPC testing(#3863), for now we have only one test that implements the skeleton test, what if we had a 100 that were based on the skeleton .. we would have had to go and fix manually all of them.

  5. laanwj commented at 9:30 AM on March 26, 2014: member

    Well in the least you then need to have methods on the skeleton object (that can be overridden) that provide all the configurable steps such as command line arguments, node setup, ...

    If subclasses end up overriding everything in the skeleton it will be exactly the same and you still need to manually fix everything.

  6. small changes 48b991a930
  7. in qa/rpc-tests/listtransactions.py:None in 5b63af7632 outdated
     130 | -        nodes = start_nodes(2, options.tmpdir)
     131 | -        connect_nodes(nodes[1], 0)
     132 | +    def run(self):
     133 | +        super(ListtransactionsTest, self).main()
     134 | +    
     135 | +    def check_array_result(self,object_array, to_match, expected):
    


    laanwj commented at 9:31 AM on March 26, 2014:

    This is a generic utility function, no need to make it part of a class (ie, no use of self or global state).


    alonmuroch commented at 8:54 AM on March 27, 2014:

    Fixed

  8. in qa/rpc-tests/TEST_EXAMPLE.py:None in 5b63af7632 outdated
      12 | +# 1) Change class name to your test
      13 | +class MyTest(baseclass):
      14 | +    
      15 | +    # 2) Change 'MyTest' to class name
      16 | +    def run(self):
      17 | +        super(MyTest, self).main()
    


    laanwj commented at 9:32 AM on March 26, 2014:

    Why add this method, and not just call MyTest().main() in step 4?


    alonmuroch commented at 8:52 AM on March 27, 2014:

    Fixed it.

  9. alonmuroch commented at 8:56 AM on March 27, 2014: contributor

    I can start creating methods that the parent class can override (init_nodes, stop_nodes,parse_options,etc. ).... but i think the current setup is pretty wide ... you have 200 blocks with 4 nodes ... i think can cover a lot of tests, don't you ?

  10. laanwj commented at 8:58 AM on March 27, 2014: member

    I do not want to make that judgement for others.

  11. laanwj commented at 1:14 PM on June 3, 2014: member

    So, I think that the base idea here is good, but it needs finer customizability in the base class. Adding init_nodes, stop_nodes, parse_options etc, as you said, makes sense.

  12. BitcoinPullTester commented at 2:48 PM on June 23, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p3956_48b991a930d516a74cf525aaa02159ce0d857aac/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  13. laanwj commented at 1:17 PM on July 8, 2014: member

    Closing this because of inactivity.

  14. laanwj closed this on Jul 8, 2014

  15. gavinandresen referenced this in commit cad6570458 on Jul 8, 2014
  16. gavinandresen referenced this in commit c9cfbb4c1d on Jul 8, 2014
  17. gavinandresen referenced this in commit e8097f7df1 on Jul 9, 2014
  18. MathyV referenced this in commit 91e1026830 on Nov 24, 2014
  19. reddink referenced this in commit 0ee12ccbf6 on May 27, 2020
  20. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 06:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me