Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-schnorrmultisig.py
| Show First 20 Lines • Show All 86 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, | ||||
| expect_disconnect=True, | |||||
| reject_reason=reject_reason, | reject_reason=reject_reason, | ||||
| ) | ) | ||||
| 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 86 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
| self.build_block(tip, [ecdsa1tx]), ECDSA_NULLDUMMY_ERROR | self.build_block(tip, [ecdsa1tx]), ECDSA_NULLDUMMY_ERROR | ||||
| ) | ) | ||||
| self.log.info( | self.log.info( | ||||
| "If we try to submit it by mempool or RPC, it is rejected and we are banned" | "If we try to submit it by mempool or RPC, it is rejected and we are banned" | ||||
| ) | ) | ||||
| assert_raises_rpc_error( | assert_raises_rpc_error( | ||||
| -26, ECDSA_NULLDUMMY_ERROR, node.sendrawtransaction, ToHex(ecdsa1tx) | -26, ECDSA_NULLDUMMY_ERROR, node.sendrawtransaction, ToHex(ecdsa1tx) | ||||
| ) | ) | ||||
| self.check_for_ban_on_rejected_tx(ecdsa1tx, ECDSA_NULLDUMMY_ERROR) | self.check_for_reason_on_rejected_tx(ecdsa1tx, ECDSA_NULLDUMMY_ERROR) | ||||
| self.log.info("Submitting a Schnorr-multisig via net, and mining it in a block") | self.log.info("Submitting a Schnorr-multisig via net, and mining it in a block") | ||||
| node.p2ps[0].send_txs_and_test([schnorr1tx], node) | node.p2ps[0].send_txs_and_test([schnorr1tx], node) | ||||
| assert_equal( | assert_equal( | ||||
| set(node.getrawmempool()), {ecdsa0tx.txid_hex, schnorr1tx.txid_hex} | set(node.getrawmempool()), {ecdsa0tx.txid_hex, schnorr1tx.txid_hex} | ||||
| ) | ) | ||||
| tip = self.build_block(tip, [schnorr1tx]) | tip = self.build_block(tip, [schnorr1tx]) | ||||
| node.p2ps[0].send_blocks_and_test([tip], node) | node.p2ps[0].send_blocks_and_test([tip], node) | ||||
| self.log.info("That legacy ECDSA multisig is still in mempool, let's mine it") | self.log.info("That legacy ECDSA multisig is still in mempool, let's mine it") | ||||
| assert_equal(node.getrawmempool(), [ecdsa0tx.txid_hex]) | assert_equal(node.getrawmempool(), [ecdsa0tx.txid_hex]) | ||||
| tip = self.build_block(tip, [ecdsa0tx]) | tip = self.build_block(tip, [ecdsa0tx]) | ||||
| node.p2ps[0].send_blocks_and_test([tip], node) | node.p2ps[0].send_blocks_and_test([tip], node) | ||||
| assert_equal(node.getrawmempool(), []) | assert_equal(node.getrawmempool(), []) | ||||
| self.log.info("Trying Schnorr in legacy multisig is invalid and banworthy.") | self.log.info("Trying Schnorr in legacy multisig is invalid and banworthy.") | ||||
| self.check_for_ban_on_rejected_tx(schnorr0tx, SCHNORR_LEGACY_MULTISIG_ERROR) | self.check_for_reason_on_rejected_tx(schnorr0tx, SCHNORR_LEGACY_MULTISIG_ERROR) | ||||
| self.check_for_ban_on_rejected_block( | self.check_for_ban_on_rejected_block( | ||||
| self.build_block(tip, [schnorr0tx]), SCHNORR_LEGACY_MULTISIG_ERROR | self.build_block(tip, [schnorr0tx]), SCHNORR_LEGACY_MULTISIG_ERROR | ||||
| ) | ) | ||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||
| SchnorrMultisigTest().main() | SchnorrMultisigTest().main() | ||||