Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-schnorr.py
Show First 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
class SchnorrTest(BitcoinTestFramework): | class SchnorrTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.block_heights = {} | self.block_heights = {} | ||||
def skip_test_if_missing_module(self): | |||||
self.skip_if_no_wallet() | |||||
def bootstrap_p2p(self, *, num_connections=1): | def bootstrap_p2p(self, *, num_connections=1): | ||||
"""Add a P2P connection to the node. | """Add a P2P connection to the node. | ||||
Helper to connect and wait for version handshake.""" | Helper to connect and wait for version handshake.""" | ||||
for _ in range(num_connections): | for _ in range(num_connections): | ||||
self.nodes[0].add_p2p_connection(P2PDataStore()) | self.nodes[0].add_p2p_connection(P2PDataStore()) | ||||
def reconnect_p2p(self, **kwargs): | def reconnect_p2p(self, **kwargs): | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
blocks = [] | blocks = [] | ||||
for _ in range(10): | for _ in range(10): | ||||
tip = self.build_block(tip) | tip = self.build_block(tip) | ||||
blocks.append(tip) | blocks.append(tip) | ||||
node.p2p.send_blocks_and_test(blocks, node, success=True) | node.p2p.send_blocks_and_test(blocks, node, success=True) | ||||
spendable_outputs = [block.vtx[0] for block in blocks] | spendable_outputs = [block.vtx[0] for block in blocks] | ||||
self.log.info("Mature the blocks and get out of IBD.") | self.log.info("Mature the blocks and get out of IBD.") | ||||
node.generate(100) | node.generatetoaddress(100, node.get_deterministic_priv_key().address) | ||||
tip = self.getbestblock(node) | tip = self.getbestblock(node) | ||||
self.log.info("Setting up spends to test and mining the fundings.") | self.log.info("Setting up spends to test and mining the fundings.") | ||||
fundings = [] | fundings = [] | ||||
# Generate a key pair | # Generate a key pair | ||||
privkeybytes = b"Schnorr!" * 4 | privkeybytes = b"Schnorr!" * 4 | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
sig64multisigtx = create_fund_and_spend_tx(multi=True, sig=sig64) | sig64multisigtx = create_fund_and_spend_tx(multi=True, sig=sig64) | ||||
tip = self.build_block(tip, fundings) | tip = self.build_block(tip, fundings) | ||||
node.p2p.send_blocks_and_test([tip], node) | node.p2p.send_blocks_and_test([tip], node) | ||||
self.log.info("Typical ECDSA and Schnorr CHECKSIG are valid.") | self.log.info("Typical ECDSA and Schnorr CHECKSIG are valid.") | ||||
node.p2p.send_txs_and_test([schnorrchecksigtx, ecdsachecksigtx], node) | node.p2p.send_txs_and_test([schnorrchecksigtx, ecdsachecksigtx], node) | ||||
# They get mined as usual. | # They get mined as usual. | ||||
node.generate(1) | node.generatetoaddress(1, node.get_deterministic_priv_key().address) | ||||
tip = self.getbestblock(node) | tip = self.getbestblock(node) | ||||
# Make sure they are in the block, and mempool is now empty. | # Make sure they are in the block, and mempool is now empty. | ||||
txhashes = set([schnorrchecksigtx.hash, ecdsachecksigtx.hash]) | txhashes = set([schnorrchecksigtx.hash, ecdsachecksigtx.hash]) | ||||
assert txhashes.issubset(tx.rehash() for tx in tip.vtx) | assert txhashes.issubset(tx.rehash() for tx in tip.vtx) | ||||
assert not node.getrawmempool() | assert not node.getrawmempool() | ||||
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(-26, SCHNORR_MULTISIG_ERROR, | assert_raises_rpc_error(-26, SCHNORR_MULTISIG_ERROR, | ||||
Show All 28 Lines |