Merge #10445: Add test for empty chain and reorg consistency for gettxoutsetinfo.
513da90cd Add test for empty chain and reorg consistency for gettxoutsetinfo. (Gregory Maxwell) 822755a42 Fix: make CCoinsViewDbCursor::Seek work for missing keys (Pieter Wuille) Tree-SHA512: e549921e8b8f599bf61ebe0ee7ef1d2f474043723d633e24665fe434b996a98e039612de8a1c2cd16b63f154943ff5ea1c1935e9561cfb813a00d47d926d0b22
This commit is contained in:
parent
9a266e68d0
commit
fc5ced317f
@ -37,8 +37,7 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
initialize_chain(self.options.tmpdir)
|
||||
|
||||
def setup_network(self, split=False):
|
||||
self.nodes = start_nodes(2, self.options.tmpdir)
|
||||
connect_nodes_bi(self.nodes, 0, 1)
|
||||
self.nodes = start_nodes(1, self.options.tmpdir)
|
||||
self.is_network_split = False
|
||||
self.sync_all()
|
||||
|
||||
@ -56,9 +55,33 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
assert_equal(res[u'height'], 200)
|
||||
assert_equal(res[u'txouts'], 200)
|
||||
assert_equal(res[u'bytes_serialized'], 14273),
|
||||
assert_equal(res['bestblock'], node.getblockhash(200))
|
||||
assert_equal(len(res[u'bestblock']), 64)
|
||||
assert_equal(len(res[u'hash_serialized']), 64)
|
||||
|
||||
self.log.info("Test that gettxoutsetinfo() works for blockchain with just the genesis block")
|
||||
b1hash = node.getblockhash(1)
|
||||
node.invalidateblock(b1hash)
|
||||
|
||||
res2 = node.gettxoutsetinfo()
|
||||
assert_equal(res2['transactions'], 0)
|
||||
assert_equal(res2['total_amount'], Decimal('0'))
|
||||
assert_equal(res2['height'], 0)
|
||||
assert_equal(res2['txouts'], 0)
|
||||
assert_equal(res2['bestblock'], node.getblockhash(0))
|
||||
assert_equal(len(res2['hash_serialized']), 64)
|
||||
|
||||
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'])
|
||||
assert_equal(res['transactions'], res3['transactions'])
|
||||
assert_equal(res['height'], res3['height'])
|
||||
assert_equal(res['txouts'], res3['txouts'])
|
||||
assert_equal(res['bestblock'], res3['bestblock'])
|
||||
assert_equal(res['hash_serialized'], res3['hash_serialized'])
|
||||
|
||||
def _test_getblockheader(self):
|
||||
node = self.nodes[0]
|
||||
|
||||
|
@ -104,7 +104,11 @@ CCoinsViewCursor *CCoinsViewDB::Cursor() const
|
||||
that restriction. */
|
||||
i->pcursor->Seek(DB_COINS);
|
||||
// Cache key of first record
|
||||
i->pcursor->GetKey(i->keyTmp);
|
||||
if (i->pcursor->Valid()) {
|
||||
i->pcursor->GetKey(i->keyTmp);
|
||||
} else {
|
||||
i->keyTmp.first = 0; // Make sure Valid() and GetKey() return false
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user