Changeset View
Changeset View
Standalone View
Standalone View
qa/rpc-tests/listsinceblock.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2017 The Bitcoin Core developers | # Copyright (c) 2017 The Bitcoin Core developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal | from test_framework.util import assert_equal | ||||
class ListSinceBlockTest (BitcoinTestFramework): | class ListSinceBlockTest (BitcoinTestFramework): | ||||
def __init__(self): | def __init__(self): | ||||
super().__init__() | super().__init__() | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 4 | self.num_nodes = 4 | ||||
def run_test (self): | def run_test(self): | ||||
''' | ''' | ||||
`listsinceblock` did not behave correctly when handed a block that was | `listsinceblock` did not behave correctly when handed a block that was | ||||
no longer in the main chain: | no longer in the main chain: | ||||
ab0 | ab0 | ||||
/ \ | / \ | ||||
aa1 [tx0] bb1 | aa1 [tx0] bb1 | ||||
| | | | | | ||||
Show All 37 Lines | def run_test(self): | ||||
lastblockhash = self.nodes[1].generate(6)[5] | lastblockhash = self.nodes[1].generate(6)[5] | ||||
self.nodes[2].generate(7) | self.nodes[2].generate(7) | ||||
print('lastblockhash=%s' % (lastblockhash)) | print('lastblockhash=%s' % (lastblockhash)) | ||||
self.sync_all() | self.sync_all() | ||||
self.join_network() | self.join_network() | ||||
# listsinceblock(lastblockhash) should now include tx, as seen from nodes[0] | # listsinceblock(lastblockhash) should now include tx, as seen from | ||||
# nodes[0] | |||||
lsbres = self.nodes[0].listsinceblock(lastblockhash) | lsbres = self.nodes[0].listsinceblock(lastblockhash) | ||||
found = False | found = False | ||||
for tx in lsbres['transactions']: | for tx in lsbres['transactions']: | ||||
if tx['txid'] == senttx: | if tx['txid'] == senttx: | ||||
found = True | found = True | ||||
break | break | ||||
assert_equal(found, True) | assert_equal(found, True) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
ListSinceBlockTest().main() | ListSinceBlockTest().main() |