Fix and add test for empty chain and reorg consistency for gettxoutsetinfo. #10445
pull gmaxwell wants to merge 2 commits into bitcoin:master from gmaxwell:test_more_gettxoutset changing 2 files +30 −2-
gmaxwell commented at 10:11 pm on May 23, 2017: contributor
-
gmaxwell commented at 10:11 pm on May 23, 2017: contributorThis 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.
-
Fix: make CCoinsViewDbCursor::Seek work for missing keys
Thanks to Suhas Daftuar for figuring this out.
-
fanquake added the label Tests on May 23, 2017
-
sipa commented at 1:55 am on May 24, 2017: memberutACK 4b3dd975a303a0d7efaec790c387f0285a4bb8c4
-
jonasschnelli approved
-
jonasschnelli commented at 6:29 am on May 24, 2017: contributorutACK 4b3dd975a303a0d7efaec790c387f0285a4bb8c4
-
paveljanik commented at 6:52 am on May 24, 2017: contributor
ACK https://github.com/bitcoin/bitcoin/commit/4b3dd975a303a0d7efaec790c387f0285a4bb8c4
FWIW: The new test crashes on master with:
02017-05-24 06:50:24.034000 TestFramework (INFO): Initializing test directory /var/folders/65/fn0h49r55k7779vg1b_h461r0000gn/T/test0wr7ofxj 1Assertion failed: (valid_), function key, file leveldb/db/db_iter.cc, line 67.
Fixed in this PR.
-
in test/functional/blockchain.py:58 in 4b3dd975a3 outdated
52@@ -53,6 +53,25 @@ def _test_gettxoutsetinfo(self): 53 assert_equal(len(res['bestblock']), 64) 54 assert_equal(len(res['hash_serialized']), 64) 55 56+ b1hash = node.getblockhash(1)
jnewbery commented at 3:52 pm on May 24, 2017:Can you add a comment (or info log) here explaining what this test is for:
0self.log.info("Test that gettxoutsetinfo() works for blockchain with just the genesis block")
gmaxwell commented at 9:10 am on May 25, 2017:donein test/functional/blockchain.py:65 in 4b3dd975a3 outdated
58+ 59+ res2 = node.gettxoutsetinfo() 60+ assert_equal(res2['transactions'], 0) 61+ assert_equal(res2['total_amount'], Decimal('0')) 62+ assert_equal(res2['height'], 0) 63+ assert_equal(res2['txouts'], 0)
jnewbery commented at 3:54 pm on May 24, 2017:Why not test all fields:
0assert_equal(res2['bestblock'], node.getblockhash(0))) 1assert_equal(len(res2['hash_serialized']), 64)
gmaxwell commented at 9:10 am on May 25, 2017:done (and also added that to the first check)in test/functional/blockchain.py:71 in 4b3dd975a3 outdated
61+ assert_equal(res2['total_amount'], Decimal('0')) 62+ assert_equal(res2['height'], 0) 63+ assert_equal(res2['txouts'], 0) 64+ 65+ node.reconsiderblock(b1hash) 66+
jnewbery commented at 3:54 pm on May 24, 2017:Again, a comment/info log would be nice here:
0self.log.info("Test that gettxoutsetinfo() returns the same result after invalidate/reconsider block")
gmaxwell commented at 9:10 am on May 25, 2017:donein test/functional/blockchain.py:73 in 4b3dd975a3 outdated
63+ assert_equal(res2['txouts'], 0) 64+ 65+ node.reconsiderblock(b1hash) 66+ 67+ res3 = node.gettxoutsetinfo() 68+ assert_equal(res['total_amount'], res3['total_amount'])
jnewbery commented at 3:56 pm on May 24, 2017:Consider just testing equality of res and res3 for succinctness:
0assert_equal(res, res3)
gmaxwell commented at 1:28 am on May 25, 2017:Equality will be the wrong comparison with the disk usage field which is about to be added.jnewbery commented at 4:01 pm on May 24, 2017: memberI 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:
0 self.num_nodes = 2
to:
0 self.num_nodes = 1
I 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.
sdaftuar commented at 4:06 pm on May 24, 2017: memberACKAdd test for empty chain and reorg consistency for gettxoutsetinfo. 513da90cddjnewbery commented at 5:08 pm on May 25, 2017: membersdaftuar commented at 6:44 pm on May 25, 2017: memberutACK 513da90paveljanik commented at 9:31 am on May 26, 2017: contributorreACK 513da90sipa merged this on May 26, 2017sipa closed this on May 26, 2017
sipa referenced this in commit b4b057a3e0 on May 26, 2017gmaxwell renamed this:
Add test for empty chain and reorg consistency for gettxoutsetinfo.
Fix and add test for empty chain and reorg consistency for gettxoutsetinfo.
on Jun 1, 2017luke-jr referenced this in commit 2a02cb9bd4 on Jun 3, 2017luke-jr referenced this in commit 471f9211d6 on Jun 3, 2017luke-jr referenced this in commit 41d92ff8fd on Jun 3, 2017luke-jr referenced this in commit 0bd7fc9706 on Jun 3, 2017luke-jr referenced this in commit 01c0c34949 on Jun 3, 2017luke-jr referenced this in commit 00230ce885 on Jun 5, 2017luke-jr referenced this in commit b43ac53162 on Jun 5, 2017luke-jr referenced this in commit 87a21d5922 on Jun 5, 2017nomnombtc referenced this in commit 0dfd00dcd4 on Jul 17, 2017codablock referenced this in commit 22a92ff4d3 on Sep 27, 2017codablock referenced this in commit 939cf65f6b on Oct 12, 2017codablock referenced this in commit fc5ced317f on Oct 24, 2017UdjinM6 referenced this in commit ab4511f475 on Nov 8, 2017DrahtBot 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: 2024-11-21 15:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me