Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_listsinceblock.py
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | def test_reorg(self): | ||||
# Split network into two | # Split network into two | ||||
self.split_network() | self.split_network() | ||||
# send to nodes[0] from nodes[2] | # send to nodes[0] from nodes[2] | ||||
senttx = self.nodes[2].sendtoaddress(self.nodes[0].getnewaddress(), 1) | senttx = self.nodes[2].sendtoaddress(self.nodes[0].getnewaddress(), 1) | ||||
# generate on both sides | # generate on both sides | ||||
lastblockhash = self.nodes[1].generate(6)[5] | nodes1_last_blockhash = self.nodes[1].generate(6)[-1] | ||||
self.nodes[2].generate(7) | nodes2_first_blockhash = self.nodes[2].generate(7)[0] | ||||
self.log.debug('lastblockhash={}'.format(lastblockhash)) | self.log.debug( | ||||
"nodes[1] last blockhash = {}".format(nodes1_last_blockhash)) | |||||
self.log.debug( | |||||
"nodes[2] first blockhash = {}".format(nodes2_first_blockhash)) | |||||
self.sync_all(self.nodes[:2]) | self.sync_all(self.nodes[:2]) | ||||
self.sync_all(self.nodes[2:]) | self.sync_all(self.nodes[2:]) | ||||
self.join_network() | self.join_network() | ||||
# listsinceblock(lastblockhash) should now include tx, as seen from | # listsinceblock(nodes1_last_blockhash) should now include tx as seen from nodes[0] | ||||
# nodes[0] | # and return the block height which listsinceblock now exposes since | ||||
lsbres = self.nodes[0].listsinceblock(lastblockhash) | # a5e7795. | ||||
Fabien: rABC6098a1cb2b25 | |||||
found = False | transactions = self.nodes[0].listsinceblock( | ||||
for tx in lsbres['transactions']: | nodes1_last_blockhash)['transactions'] | ||||
if tx['txid'] == senttx: | found = next(tx for tx in transactions if tx['txid'] == senttx) | ||||
found = True | assert_equal( | ||||
break | found['blockheight'], | ||||
assert found | self.nodes[0].getblockheader(nodes2_first_blockhash)['height']) | ||||
def test_double_spend(self): | def test_double_spend(self): | ||||
''' | ''' | ||||
This tests the case where the same UTXO is spent twice on two separate | This tests the case where the same UTXO is spent twice on two separate | ||||
blocks as part of a reorg. | blocks as part of a reorg. | ||||
ab0 | ab0 | ||||
/ \ | / \ | ||||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |
rABC6098a1cb2b25