Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-segwit-recovery.py
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | class SegwitRecoveryTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.block_heights = {} | self.block_heights = {} | ||||
self.tip = None | self.tip = None | ||||
self.blocks = {} | self.blocks = {} | ||||
# We have 2 nodes: | # We have 2 nodes: | ||||
# 1) node_nonstd (nodes[0]) accepts non-standard txns. We check it | # 1) node_nonstd (nodes[0]) accepts non-standard txns. It does not | ||||
# accepts segwit spending txns. | # accept Segwit recovery transactions, since it is included in | ||||
# standard flags, and transactions that violate these flags are | |||||
# never accepted into the mempool. | |||||
markblundeberg: "...never accepted into the mempool, even when configured to 'accept non-standard transactions'. | |||||
# 2) node_std (nodes[1]) doesn't accept non-standard txns and | # 2) node_std (nodes[1]) doesn't accept non-standard txns and | ||||
# doesn't have us whitelisted. It's used to test for bans, as we | # doesn't have us whitelisted. It's used to test for bans, as we | ||||
# connect directly to it via mininode and send a segwit spending | # connect directly to it via mininode and send a segwit spending | ||||
# txn. This transaction is non-standard. We check that sending | # txn. This transaction is non-standard. We check that sending | ||||
# this transaction doesn't result in a ban. | # this transaction doesn't result in a ban. | ||||
# Nodes are connected to each other, so node_std receives blocks and | # Nodes are connected to each other, so node_std receives blocks and | ||||
# transactions that node_nonstd has accepted. Since we are checking | # transactions that node_nonstd has accepted. Since we are checking | ||||
# that segwit spending txn are not resulting in bans, node_nonstd | # that segwit spending txn are not resulting in bans, node_nonstd | ||||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | def get_tests(self): | ||||
# both nodes are synchronized before continuing. | # both nodes are synchronized before continuing. | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
# Check that upgraded nodes checking for standardness are not banning | # Check that upgraded nodes checking for standardness are not banning | ||||
# nodes sending segwit spending txns. | # nodes sending segwit spending txns. | ||||
check_for_no_ban_on_rejected_tx(txspend, 64, CLEANSTACK_ERROR) | check_for_no_ban_on_rejected_tx(txspend, 64, CLEANSTACK_ERROR) | ||||
check_for_no_ban_on_rejected_tx(txspend_case0, 64, EVAL_FALSE_ERROR) | check_for_no_ban_on_rejected_tx(txspend_case0, 64, EVAL_FALSE_ERROR) | ||||
# Segwit spending txns are accepted in the mempool of nodes not checking | # Segwit recovery txns are never accepted into the mempool, | ||||
# for standardness, but rejected in nodes that check. | # as they are included in standard flags. | ||||
node_nonstd.sendrawtransaction(ToHex(txspend)) | assert_raises_rpc_error(-26, RPC_CLEANSTACK_ERROR, | ||||
node_nonstd.sendrawtransaction(ToHex(txspend_case0)) | node_nonstd.sendrawtransaction, ToHex(txspend)) | ||||
check_mempool_equal(node_nonstd, [txspend, txspend_case0]) | assert_raises_rpc_error(-26, RPC_EVAL_FALSE_ERROR, | ||||
node_nonstd.sendrawtransaction, ToHex(txspend_case0)) | |||||
assert_raises_rpc_error(-26, RPC_CLEANSTACK_ERROR, | assert_raises_rpc_error(-26, RPC_CLEANSTACK_ERROR, | ||||
node_std.sendrawtransaction, ToHex(txspend)) | node_std.sendrawtransaction, ToHex(txspend)) | ||||
assert_raises_rpc_error(-26, RPC_EVAL_FALSE_ERROR, | assert_raises_rpc_error(-26, RPC_EVAL_FALSE_ERROR, | ||||
node_std.sendrawtransaction, ToHex(txspend_case0)) | node_std.sendrawtransaction, ToHex(txspend_case0)) | ||||
# Blocks containing segwit spending txns are accepted in both nodes. | # Blocks containing segwit spending txns are accepted in both nodes. | ||||
block(5) | block(5) | ||||
postforkblock = update_block(5, [txspend, txspend_case0]) | postforkblock = update_block(5, [txspend, txspend_case0]) | ||||
yield accepted() | yield accepted() | ||||
sync_blocks(self.nodes) | sync_blocks(self.nodes) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
SegwitRecoveryTest().main() | SegwitRecoveryTest().main() |
"...never accepted into the mempool, even when configured to 'accept non-standard transactions'."