Dash Core
0.12.2.1
P2P Digital Currency
forknotify.py
Go to the documentation of this file.
1
#!/usr/bin/env python2
2
# Copyright (c) 2014-2015 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
6
#
7
# Test -alertnotify
8
#
9
10
from
test_framework.test_framework
import
BitcoinTestFramework
11
from
test_framework.util
import
*
12
13
class
ForkNotifyTest
(
BitcoinTestFramework
):
14
15
alert_filename =
None
# Set by setup_network
16
17
def
setup_network
(self):
18
self.
nodes
= []
19
self.
alert_filename
= os.path.join(self.options.tmpdir,
"alert.txt"
)
20
with open(self.
alert_filename
,
'w'
)
as
f:
21
pass
# Just open then close to create zero-length file
22
self.
nodes
.append(
start_node
(0, self.options.tmpdir,
23
[
"-blockversion=2"
,
"-alertnotify=echo %s >> \""
+ self.
alert_filename
+
"\""
]))
24
# Node1 mines block.version=211 blocks
25
self.
nodes
.append(
start_node
(1, self.options.tmpdir,
26
[
"-blockversion=211"
]))
27
connect_nodes
(self.
nodes
[1], 0)
28
29
self.
is_network_split
=
False
30
self.
sync_all
()
31
32
def
run_test
(self):
33
# Mine 51 up-version blocks
34
self.
nodes
[1].
generate
(51)
35
self.
sync_all
()
36
# -alertnotify should trigger on the 51'st,
37
# but mine and sync another to give
38
# -alertnotify time to write
39
self.
nodes
[1].
generate
(1)
40
self.
sync_all
()
41
42
with open(self.
alert_filename
,
'r') as f:
43
alert_text = f.read()
44
45
if
len(alert_text) == 0:
46
raise
AssertionError(
"-alertnotify did not warn of up-version blocks"
)
47
48
# Mine more up-version blocks, should not get more alerts:
49
self.
nodes
[1].
generate
(1)
50
self.
sync_all
()
51
self.
nodes
[1].
generate
(1)
52
self.
sync_all
()
53
54
with open(self.
alert_filename
,
'r') as f:
55
alert_text2 = f.read()
56
57
if
alert_text != alert_text2:
58
raise
AssertionError(
"-alertnotify excessive warning of up-version blocks"
)
59
60
if
__name__ ==
'__main__'
:
61
ForkNotifyTest
().
main
()
forknotify.ForkNotifyTest.alert_filename
alert_filename
Definition:
forknotify.py:15
test_framework.util.connect_nodes
def connect_nodes(from_connection, node_num)
Definition:
util.py:343
test_framework.test_framework
Definition:
test_framework.py:1
test_framework.test_framework.BitcoinTestFramework
Definition:
test_framework.py:32
forknotify.ForkNotifyTest.run_test
def run_test(self)
Definition:
forknotify.py:32
forknotify.ForkNotifyTest.nodes
nodes
Definition:
forknotify.py:18
forknotify.ForkNotifyTest.setup_network
def setup_network(self)
Definition:
forknotify.py:17
test_framework.util.start_node
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None)
Definition:
util.py:281
generate
UniValue generate(const UniValue ¶ms, bool fHelp)
Definition:
mining.cpp:122
test_framework.test_framework.BitcoinTestFramework.main
def main(self)
Definition:
test_framework.py:97
forknotify.ForkNotifyTest.is_network_split
is_network_split
Definition:
forknotify.py:29
test_framework.util
Definition:
util.py:1
test_framework.test_framework.BitcoinTestFramework.sync_all
def sync_all(self)
Definition:
test_framework.py:78
forknotify.ForkNotifyTest
Definition:
forknotify.py:13
qa
rpc-tests
forknotify.py
Generated on Thu Dec 14 2017 13:15:01 for Dash Core by
1.8.14