Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Fix and add test for empty chain and reorg consistency for gettxoutsetinfo. #10445
Conversation
|
This will crash on master. Fix is currently in the per-txout PR. Edit: Sipa asked me to just add the fix here, doing so now. |
fanquake
added
the
Tests
label
May 23, 2017
|
utACK 4b3dd97 |
|
ACK 4b3dd97 FWIW: The new test crashes on master with:
Fixed in this PR. |
jnewbery
reviewed
May 24, 2017
I can't review the code change in src/txdb.cpp since I don't know that code, but I can confirm that this test causes bitcoind to crash without the code change, and passes successfully with the code change.
A few nits inline. Also consider changing line 35 of the test from:
self.num_nodes = 2to:
self.num_nodes = 1I know that wsan't changed by this PR, but 2 nodes are unnecessary for this test, and changing it to 1 cuts the test time in half (from 5s to 2.5s on my pc) due to node startup/shutdown time.
| @@ -53,6 +53,25 @@ def _test_gettxoutsetinfo(self): | ||
| assert_equal(len(res['bestblock']), 64) | ||
| assert_equal(len(res['hash_serialized']), 64) | ||
| + b1hash = node.getblockhash(1) |
jnewbery
May 24, 2017
Member
Can you add a comment (or info log) here explaining what this test is for:
self.log.info("Test that gettxoutsetinfo() works for blockchain with just the genesis block")| + assert_equal(res2['transactions'], 0) | ||
| + assert_equal(res2['total_amount'], Decimal('0')) | ||
| + assert_equal(res2['height'], 0) | ||
| + assert_equal(res2['txouts'], 0) |
jnewbery
May 24, 2017
Member
Why not test all fields:
assert_equal(res2['bestblock'], node.getblockhash(0)))
assert_equal(len(res2['hash_serialized']), 64)| + assert_equal(res2['txouts'], 0) | ||
| + | ||
| + node.reconsiderblock(b1hash) | ||
| + |
jnewbery
May 24, 2017
Member
Again, a comment/info log would be nice here:
self.log.info("Test that gettxoutsetinfo() returns the same result after invalidate/reconsider block")| + node.reconsiderblock(b1hash) | ||
| + | ||
| + res3 = node.gettxoutsetinfo() | ||
| + assert_equal(res['total_amount'], res3['total_amount']) |
jnewbery
May 24, 2017
Member
Consider just testing equality of res and res3 for succinctness:
assert_equal(res, res3)
gmaxwell
May 25, 2017
Member
Equality will be the wrong comparison with the disk usage field which is about to be added.
|
ACK |
|
updated for @jnewbery 's nits. (Thanks!) |
|
tested reACK 513da90 |
|
utACK 513da90 |
|
reACK 513da90 |
gmaxwell commentedMay 23, 2017
No description provided.