Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-schnorr.py
| Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | def build_block(self, parent, transactions=(), nTime=None): | ||||
| create_coinbase(block_height), | create_coinbase(block_height), | ||||
| block_time, | block_time, | ||||
| txlist=transactions, | txlist=transactions, | ||||
| ) | ) | ||||
| block.solve() | block.solve() | ||||
| self.block_heights[block.hash_int] = block_height | self.block_heights[block.hash_int] = block_height | ||||
| return block | return block | ||||
| def check_for_ban_on_rejected_tx(self, tx, reject_reason=None): | def check_for_reason_on_rejected_tx(self, tx, reject_reason=None): | ||||
| """Check we are disconnected when sending a txn that the node rejects. | """Check we are disconnected when sending a txn that the node rejects. | ||||
| (Can't actually get banned, since bitcoind won't ban local peers.)""" | (Can't actually get banned, since bitcoind won't ban local peers.)""" | ||||
| self.nodes[0].p2ps[0].send_txs_and_test( | self.nodes[0].p2ps[0].send_txs_and_test( | ||||
| [tx], | [tx], | ||||
| self.nodes[0], | self.nodes[0], | ||||
| success=False, | success=False, | ||||
| reject_reason=reject_reason, | reject_reason=reject_reason, | ||||
| expect_disconnect=True, | |||||
| ) | ) | ||||
| self.reconnect_p2p() | |||||
| def check_for_ban_on_rejected_block(self, block, reject_reason=None): | def check_for_ban_on_rejected_block(self, block, reject_reason=None): | ||||
| """Check we are disconnected when sending a block that the node rejects. | """Check we are disconnected when sending a block that the node rejects. | ||||
| (Can't actually get banned, since bitcoind won't ban local peers.)""" | (Can't actually get banned, since bitcoind won't ban local peers.)""" | ||||
| self.nodes[0].p2ps[0].send_blocks_and_test( | self.nodes[0].p2ps[0].send_blocks_and_test( | ||||
| [block], | [block], | ||||
| self.nodes[0], | self.nodes[0], | ||||
| ▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
| self.log.info("Schnorr in multisig is rejected with mandatory error.") | self.log.info("Schnorr in multisig is rejected with mandatory error.") | ||||
| assert_raises_rpc_error( | assert_raises_rpc_error( | ||||
| -26, | -26, | ||||
| SCHNORR_MULTISIG_ERROR, | SCHNORR_MULTISIG_ERROR, | ||||
| node.sendrawtransaction, | node.sendrawtransaction, | ||||
| ToHex(schnorrmultisigtx), | ToHex(schnorrmultisigtx), | ||||
| ) | ) | ||||
| # And it is banworthy. | # And it is banworthy. | ||||
| self.check_for_ban_on_rejected_tx(schnorrmultisigtx, SCHNORR_MULTISIG_ERROR) | self.check_for_reason_on_rejected_tx(schnorrmultisigtx, SCHNORR_MULTISIG_ERROR) | ||||
| # And it can't be mined | # And it can't be mined | ||||
| self.check_for_ban_on_rejected_block( | self.check_for_ban_on_rejected_block( | ||||
| self.build_block(tip, [schnorrmultisigtx]), SCHNORR_MULTISIG_ERROR | self.build_block(tip, [schnorrmultisigtx]), SCHNORR_MULTISIG_ERROR | ||||
| ) | ) | ||||
| self.log.info("Bad 64-byte sig is rejected with mandatory error.") | self.log.info("Bad 64-byte sig is rejected with mandatory error.") | ||||
| # In CHECKSIG it's invalid Schnorr and hence NULLFAIL. | # In CHECKSIG it's invalid Schnorr and hence NULLFAIL. | ||||
| assert_raises_rpc_error( | assert_raises_rpc_error( | ||||
| -26, NULLFAIL_ERROR, node.sendrawtransaction, ToHex(sig64checksigtx) | -26, NULLFAIL_ERROR, node.sendrawtransaction, ToHex(sig64checksigtx) | ||||
| ) | ) | ||||
| # In CHECKMULTISIG it's invalid length and hence BAD_LENGTH. | # In CHECKMULTISIG it's invalid length and hence BAD_LENGTH. | ||||
| assert_raises_rpc_error( | assert_raises_rpc_error( | ||||
| -26, SCHNORR_MULTISIG_ERROR, node.sendrawtransaction, ToHex(sig64multisigtx) | -26, SCHNORR_MULTISIG_ERROR, node.sendrawtransaction, ToHex(sig64multisigtx) | ||||
| ) | ) | ||||
| # Sending these transactions is banworthy. | # Sending these transactions is banworthy. | ||||
| self.check_for_ban_on_rejected_tx(sig64checksigtx, NULLFAIL_ERROR) | self.check_for_reason_on_rejected_tx(sig64checksigtx, NULLFAIL_ERROR) | ||||
| self.check_for_ban_on_rejected_tx(sig64multisigtx, SCHNORR_MULTISIG_ERROR) | self.check_for_reason_on_rejected_tx(sig64multisigtx, SCHNORR_MULTISIG_ERROR) | ||||
| # And they can't be mined either... | # And they can't be mined either... | ||||
| self.check_for_ban_on_rejected_block( | self.check_for_ban_on_rejected_block( | ||||
| self.build_block(tip, [sig64checksigtx]), NULLFAIL_ERROR | self.build_block(tip, [sig64checksigtx]), NULLFAIL_ERROR | ||||
| ) | ) | ||||
| self.check_for_ban_on_rejected_block( | self.check_for_ban_on_rejected_block( | ||||
| self.build_block(tip, [sig64multisigtx]), SCHNORR_MULTISIG_ERROR | self.build_block(tip, [sig64multisigtx]), SCHNORR_MULTISIG_ERROR | ||||
| ) | ) | ||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||
| SchnorrTest().main() | SchnorrTest().main() | ||||