[tests] Remove is_network_split from funtional test cases
[bitcoinplatinum.git] / test / functional / listsinceblock.py
blobf3d41e573eda75ebc24b5fe9b815b1a06c404fbb
1 #!/usr/bin/env python3
2 # Copyright (c) 2017 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 """Test the listsincelast RPC."""
7 from test_framework.test_framework import BitcoinTestFramework
8 from test_framework.util import assert_equal
10 class ListSinceBlockTest (BitcoinTestFramework):
12 def __init__(self):
13 super().__init__()
14 self.setup_clean_chain = True
15 self.num_nodes = 4
17 def run_test (self):
18 '''
19 `listsinceblock` did not behave correctly when handed a block that was
20 no longer in the main chain:
22 ab0
23 / \
24 aa1 [tx0] bb1
25 | |
26 aa2 bb2
27 | |
28 aa3 bb3
30 bb4
32 Consider a client that has only seen block `aa3` above. It asks the node
33 to `listsinceblock aa3`. But at some point prior the main chain switched
34 to the bb chain.
36 Previously: listsinceblock would find height=4 for block aa3 and compare
37 this to height=5 for the tip of the chain (bb4). It would then return
38 results restricted to bb3-bb4.
40 Now: listsinceblock finds the fork at ab0 and returns results in the
41 range bb1-bb4.
43 This test only checks that [tx0] is present.
44 '''
46 self.nodes[2].generate(101)
47 self.sync_all()
49 assert_equal(self.nodes[0].getbalance(), 0)
50 assert_equal(self.nodes[1].getbalance(), 0)
51 assert_equal(self.nodes[2].getbalance(), 50)
52 assert_equal(self.nodes[3].getbalance(), 0)
54 # Split network into two
55 self.split_network()
57 # send to nodes[0] from nodes[2]
58 senttx = self.nodes[2].sendtoaddress(self.nodes[0].getnewaddress(), 1)
60 # generate on both sides
61 lastblockhash = self.nodes[1].generate(6)[5]
62 self.nodes[2].generate(7)
63 self.log.info('lastblockhash=%s' % (lastblockhash))
65 self.sync_all([self.nodes[:2], self.nodes[2:]])
67 self.join_network()
69 # listsinceblock(lastblockhash) should now include tx, as seen from nodes[0]
70 lsbres = self.nodes[0].listsinceblock(lastblockhash)
71 found = False
72 for tx in lsbres['transactions']:
73 if tx['txid'] == senttx:
74 found = True
75 break
76 assert_equal(found, True)
78 if __name__ == '__main__':
79 ListSinceBlockTest().main()