[qa] smartfees: Properly use ordered dict #7980

pull MarcoFalke wants to merge 2 commits into bitcoin:master from MarcoFalke:Mf1604-qaOrderedDict changing 1 files +7 −8
  1. MarcoFalke commented at 9:13 PM on April 30, 2016: member

    Dictionaries are not guaranteed to be sorted; Use an OrderedDict to avoid random failures of the smartfees test.

  2. MarcoFalke added the label Tests on Apr 30, 2016
  3. paveljanik commented at 4:16 PM on May 1, 2016: contributor

    @MarcoFalke Marko, do you have a sample of how it fails without this change? I did 100 runs of master to compare and ACK this and it was always OK...

  4. MarcoFalke commented at 11:05 AM on May 2, 2016: member

    @paveljanik This depends on your environment. I will post exact steps to reproduce tonight, when I am home.

  5. laanwj commented at 2:02 PM on May 2, 2016: member

    +1 for using OrderedDict. Normal dicts's order is randomized (they use a random seed for security reasons) and it's clear that the order of those outputs here matters.

    Aside: as of Python 3.5 OrderedDict is implemented in C and hence almost as fast as normal dict. Not that it matters in this particular instance.

  6. laanwj commented at 2:03 PM on May 2, 2016: member

    To reproduce I'd suggest using an OrderedDict with the items reversed.

    (can't do it myself right now, running the extended test suite using python 3)

    This PR is also part of #7814.

  7. MarcoFalke commented at 4:05 PM on May 2, 2016: member

    @paveljanik To test this you can use python -h to see how you enable random hash seeds, if it is not yet enabled.

    E.g. python -R qa/rpc-tests/smartfees.py --srcdir=src fails on master, passes with this patch.

  8. paveljanik commented at 4:32 PM on May 2, 2016: contributor

    Still not able to reproduce here on master, OS X.

    On the other hand, this command now failed for me on OS X, with this PR:

    $ python -R qa/rpc-tests/smartfees.py  --srcdir=src
    Initializing test directory /var/folders/65/fn0h49r55k7779vg1b_h461r0000gn/T/test2CcA11
    This test is time consuming, please be patient
    Splitting inputs to small size so we can generate low priority tx's
    Finished splitting
    Will output estimates for 1/2/3/6/15/25 blocks
    Creating transactions and mining them with a block size that can't keep up
    JSONRPC error: 16: bad-txns-in-belowout
      File "/private/tmp/bitcoin-7980/qa/rpc-tests/test_framework/test_framework.py", line 135, in main
        self.run_test()
      File "qa/rpc-tests/smartfees.py", line 244, in run_test
        self.transact_and_mine(10, self.nodes[2])
      File "qa/rpc-tests/smartfees.py", line 220, in transact_and_mine
        self.memutxo, Decimal("0.005"), min_fee, min_fee)
      File "qa/rpc-tests/smartfees.py", line 67, in small_txpuzzle_randfee
        txid = from_node.sendrawtransaction(completetx, True)
      File "/private/tmp/bitcoin-7980/qa/rpc-tests/test_framework/coverage.py", line 50, in __call__
        return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
      File "/private/tmp/bitcoin-7980/qa/rpc-tests/test_framework/authproxy.py", line 139, in __call__
        raise JSONRPCException(response['error'])
    Stopping nodes
    Cleaning up
    Failed
    $ 
    

    Edit: Python is Python 2.7 on this test machine.

  9. paveljanik commented at 4:44 PM on May 2, 2016: contributor

    When I run the test as ./smartfee.py, it is always OK here though (both master and this PR) - this is what I did before.

    Using your method (with or without -R), I have various failures here, e.g.:

    bitcoin-master$ python -R qa/rpc-tests/smartfees.py  --srcdir=src
    Initializing test directory /var/folders/65/fn0h49r55k7779vg1b_h461r0000gn/T/test_u6yGY
    This test is time consuming, please be patient
    Splitting inputs to small size so we can generate low priority tx's
    Unexpected exception caught during testing: IndexError('pop from empty list',)
      File "/private/tmp/bitcoin-master/qa/rpc-tests/test_framework/test_framework.py", line 133, in main
        self.setup_network()
      File "qa/rpc-tests/smartfees.py", line 165, in setup_network
        split_inputs(self.nodes[0], self.nodes[0].listunspent(0), self.txouts, True)
      File "qa/rpc-tests/smartfees.py", line 79, in split_inputs
        prevtxout = txins.pop()
    Stopping nodes
    Cleaning up
    Failed
    bitcoin-master$ 
    
  10. [qa] smartfees: Properly use ordered dict fa17f93fbd
  11. MarcoFalke force-pushed on May 2, 2016
  12. MarcoFalke commented at 5:36 PM on May 2, 2016: member

    @paveljanik Thanks for noticing! Of course I need to fix it in the other places as well...

  13. paveljanik commented at 8:25 PM on May 2, 2016: contributor
  14. [qa] Fix typos in doc and comments 43bbcd0753
  15. MarcoFalke force-pushed on May 2, 2016
  16. MarcoFalke commented at 6:29 AM on May 3, 2016: member

    @paveljanik Done, thx.

  17. paveljanik commented at 7:08 AM on May 3, 2016: contributor

    20 runs of rm -rf cache/; python -R qa/rpc-tests/smartfees.py --srcdir=src in both master and this PR: master 12x Failed, this PR: all OK.

    ACK https://github.com/bitcoin/bitcoin/pull/7980/commits/43bbcd075355630544a530f3cc52014edb3787b2

  18. MarcoFalke merged this on May 3, 2016
  19. MarcoFalke closed this on May 3, 2016

  20. MarcoFalke referenced this in commit 88b77c7da0 on May 3, 2016
  21. MarcoFalke deleted the branch on May 3, 2016
  22. MarcoFalke referenced this in commit c0fe8b5c7d on Jun 9, 2016
  23. nomnombtc referenced this in commit 648205dd6a on Nov 12, 2016
  24. nomnombtc referenced this in commit 4a9e64d714 on Nov 12, 2016
  25. nomnombtc referenced this in commit bf26bc90e5 on Nov 13, 2016
  26. sickpig referenced this in commit a5b404a860 on Nov 14, 2016
  27. DrahtBot locked this on Sep 8, 2021
Labels

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-13 18:15 UTC

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