Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_notifications.py
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.tx_filename).st_size >= (block_count * 65), timeout=10) | self.tx_filename).st_size >= (block_count * 65), timeout=10) | ||||
# file content should equal the generated transaction hashes | # file content should equal the generated transaction hashes | ||||
txids_rpc = list( | txids_rpc = list( | ||||
map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count))) | map(lambda t: t['txid'], self.nodes[1].listtransactions("*", block_count))) | ||||
with open(self.tx_filename, 'r') as f: | with open(self.tx_filename, 'r') as f: | ||||
assert_equal(sorted(txids_rpc), sorted(f.read().splitlines())) | assert_equal(sorted(txids_rpc), sorted(f.read().splitlines())) | ||||
# Mine another 41 up-version blocks. -alertnotify should trigger on the 51st. | |||||
self.log.info("test -alertnotify for bip9") | |||||
self.nodes[1].generate(41) | |||||
self.sync_all() | |||||
# Give bitcoind 10 seconds to write the alert notification | |||||
wait_until(lambda: os.path.isfile(self.alert_filename) | |||||
and os.path.getsize(self.alert_filename), timeout=10) | |||||
with open(self.alert_filename, 'r', encoding='utf8') as f: | |||||
alert_text = f.read() | |||||
# Mine more up-version blocks, should not get more alerts: | |||||
self.nodes[1].generate(2) | |||||
self.sync_all() | |||||
with open(self.alert_filename, 'r', encoding='utf8') as f: | |||||
alert_text2 = f.read() | |||||
os.remove(self.alert_filename) | |||||
self.log.info( | |||||
"-alertnotify should not continue notifying for more unknown version blocks") | |||||
assert_equal(alert_text, alert_text2) | |||||
# Create an invalid chain and ensure the node warns. | # Create an invalid chain and ensure the node warns. | ||||
self.log.info("test -alertnotify for forked chain") | self.log.info("test -alertnotify for forked chain") | ||||
fork_block = self.nodes[0].getbestblockhash() | fork_block = self.nodes[0].getbestblockhash() | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
invalid_block = self.nodes[0].getbestblockhash() | invalid_block = self.nodes[0].getbestblockhash() | ||||
self.nodes[0].generate(7) | self.nodes[0].generate(7) | ||||
# Invalidate a large branch, which should trigger an alert. | # Invalidate a large branch, which should trigger an alert. | ||||
Show All 13 Lines |