[CoinControl] Allow non-wallet owned change addresses
[bitcoinplatinum.git] / qa / rpc-tests / forknotify.py
bloba1901aedab890d92dac8f64b42d0961607b0edb8
1 #!/usr/bin/env python3
2 # Copyright (c) 2014-2016 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.
7 # Test -alertnotify
10 from test_framework.test_framework import BitcoinTestFramework
11 from test_framework.util import *
13 class ForkNotifyTest(BitcoinTestFramework):
15 def __init__(self):
16 super().__init__()
17 self.num_nodes = 2
18 self.setup_clean_chain = False
20 alert_filename = None # Set by setup_network
22 def setup_network(self):
23 self.nodes = []
24 self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt")
25 with open(self.alert_filename, 'w', encoding='utf8') as f:
26 pass # Just open then close to create zero-length file
27 self.nodes.append(start_node(0, self.options.tmpdir,
28 ["-blockversion=2", "-alertnotify=echo %s >> \"" + self.alert_filename + "\""]))
29 # Node1 mines block.version=211 blocks
30 self.nodes.append(start_node(1, self.options.tmpdir,
31 ["-blockversion=211"]))
32 connect_nodes(self.nodes[1], 0)
34 self.is_network_split = False
35 self.sync_all()
37 def run_test(self):
38 # Mine 51 up-version blocks
39 self.nodes[1].generate(51)
40 self.sync_all()
41 # -alertnotify should trigger on the 51'st,
42 # but mine and sync another to give
43 # -alertnotify time to write
44 self.nodes[1].generate(1)
45 self.sync_all()
47 with open(self.alert_filename, 'r', encoding='utf8') as f:
48 alert_text = f.read()
50 if len(alert_text) == 0:
51 raise AssertionError("-alertnotify did not warn of up-version blocks")
53 # Mine more up-version blocks, should not get more alerts:
54 self.nodes[1].generate(1)
55 self.sync_all()
56 self.nodes[1].generate(1)
57 self.sync_all()
59 with open(self.alert_filename, 'r', encoding='utf8') as f:
60 alert_text2 = f.read()
62 if alert_text != alert_text2:
63 raise AssertionError("-alertnotify excessive warning of up-version blocks")
65 if __name__ == '__main__':
66 ForkNotifyTest().main()