Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-segwit-recovery.py
Show All 30 Lines | from test_framework.script import ( | ||||
hash160, | hash160, | ||||
OP_EQUAL, | OP_EQUAL, | ||||
OP_HASH160, | OP_HASH160, | ||||
OP_TRUE, | OP_TRUE, | ||||
) | ) | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_raises_rpc_error, | assert_raises_rpc_error, | ||||
sync_blocks, | |||||
) | ) | ||||
TEST_TIME = int(time.time()) | TEST_TIME = int(time.time()) | ||||
# Error due to non clean stack | # Error due to non clean stack | ||||
CLEANSTACK_ERROR = 'non-mandatory-script-verify-flag (Script did not clean its stack)' | CLEANSTACK_ERROR = 'non-mandatory-script-verify-flag (Script did not clean its stack)' | ||||
RPC_CLEANSTACK_ERROR = CLEANSTACK_ERROR + " (code 64)" | RPC_CLEANSTACK_ERROR = CLEANSTACK_ERROR + " (code 64)" | ||||
EVAL_FALSE_ERROR = 'non-mandatory-script-verify-flag (Script evaluated without error but finished with a false/empty top stack elem' | EVAL_FALSE_ERROR = 'non-mandatory-script-verify-flag (Script evaluated without error but finished with a false/empty top stack elem' | ||||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Mine txfund, as it can't go into node_std mempool because it's | # Mine txfund, as it can't go into node_std mempool because it's | ||||
# nonstandard. | # nonstandard. | ||||
block(5555) | block(5555) | ||||
update_block(5555, [txfund, txfund_case0]) | update_block(5555, [txfund, txfund_case0]) | ||||
accepted(node_nonstd) | accepted(node_nonstd) | ||||
# Check both nodes are synchronized before continuing. | # Check both nodes are synchronized before continuing. | ||||
sync_blocks(self.nodes) | self.sync_blocks() | ||||
# 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( | check_for_no_ban_on_rejected_tx( | ||||
node_nonstd, txspend, CLEANSTACK_ERROR) | node_nonstd, txspend, CLEANSTACK_ERROR) | ||||
check_for_no_ban_on_rejected_tx( | check_for_no_ban_on_rejected_tx( | ||||
node_nonstd, txspend_case0, EVAL_FALSE_ERROR) | node_nonstd, txspend_case0, EVAL_FALSE_ERROR) | ||||
check_for_no_ban_on_rejected_tx( | check_for_no_ban_on_rejected_tx( | ||||
Show All 11 Lines | def run_test(self): | ||||
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) | ||||
update_block(5, [txspend, txspend_case0]) | update_block(5, [txspend, txspend_case0]) | ||||
accepted(node_nonstd) | accepted(node_nonstd) | ||||
sync_blocks(self.nodes) | self.sync_blocks() | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
SegwitRecoveryTest().main() | SegwitRecoveryTest().main() |