Dictionaries are not guaranteed to be sorted; Use an OrderedDict to avoid random failures of the smartfees test.
[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-
MarcoFalke commented at 9:13 PM on April 30, 2016: member
- MarcoFalke added the label Tests on Apr 30, 2016
-
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...
-
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.
-
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.
-
MarcoFalke commented at 4:05 PM on May 2, 2016: member
@paveljanik To test this you can use
python -hto see how you enable random hash seeds, if it is not yet enabled.E.g.
python -R qa/rpc-tests/smartfees.py --srcdir=srcfails on master, passes with this patch. -
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.
-
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$ -
[qa] smartfees: Properly use ordered dict fa17f93fbd
- MarcoFalke force-pushed on May 2, 2016
-
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...
-
paveljanik commented at 8:25 PM on May 2, 2016: contributor
Tests are running. @MarcoFalke Feel free to cherrypick typos from https://github.com/bitcoin/bitcoin/commit/bcdd81cc8abf3505c827610190daa746be7e0d96
-
[qa] Fix typos in doc and comments 43bbcd0753
- MarcoFalke force-pushed on May 2, 2016
-
MarcoFalke commented at 6:29 AM on May 3, 2016: member
@paveljanik Done, thx.
-
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=srcin both master and this PR: master 12x Failed, this PR: all OK.ACK https://github.com/bitcoin/bitcoin/pull/7980/commits/43bbcd075355630544a530f3cc52014edb3787b2
- MarcoFalke merged this on May 3, 2016
- MarcoFalke closed this on May 3, 2016
- MarcoFalke referenced this in commit 88b77c7da0 on May 3, 2016
- MarcoFalke deleted the branch on May 3, 2016
- MarcoFalke referenced this in commit c0fe8b5c7d on Jun 9, 2016
- nomnombtc referenced this in commit 648205dd6a on Nov 12, 2016
- nomnombtc referenced this in commit 4a9e64d714 on Nov 12, 2016
- nomnombtc referenced this in commit bf26bc90e5 on Nov 13, 2016
- sickpig referenced this in commit a5b404a860 on Nov 14, 2016
- DrahtBot locked this on Sep 8, 2021