Skip to content

Commit

Permalink
test: Add anchor mempool acceptance test
Browse files Browse the repository at this point in the history
  • Loading branch information
instagibbs committed Jun 27, 2024
1 parent 4edbfae commit 99e9d3c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/functional/mempool_accept.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,36 @@ def run_test(self):
maxfeerate=0,
)

self.log.info('OP_1 <0x4e73> is able to be created and spent')
true_tx = self.wallet.create_self_transfer(sequence=SEQUENCE_FINAL)['tx']
true_tx.vout[0].scriptPubKey = bytes(CScript([OP_TRUE, bytes.fromhex("4e73")]))
true_tx.rehash()
self.generateblock(node, self.wallet.get_address(), [true_tx.serialize().hex()])

# First spend has non-empty witness, will be rejected to prevent third party wtxid malleability
true_tx_spend = CTransaction()
true_tx_spend.vin.append(CTxIn(COutPoint(true_tx.sha256, 0), b""))
true_tx_spend.vout.append(CTxOut(true_tx.vout[0].nValue - int(fee*COIN), script_to_p2wsh_script(CScript([OP_TRUE]))))
true_tx_spend.wit.vtxinwit.append(CTxInWitness())
true_tx_spend.wit.vtxinwit[0].scriptWitness.stack.append(b"f")
true_tx_spend.rehash()

self.check_mempool_result(
result_expected=[{'txid': true_tx_spend.rehash(), 'allowed': False, 'reject-reason': 'bad-witness-nonstandard'}],
rawtxs=[true_tx_spend.serialize().hex()],
maxfeerate=0,
)

# Clear witness stuffing
true_tx_spend.wit.vtxinwit[0].scriptWitness.stack = []
true_tx_spend.rehash()

self.check_mempool_result(
result_expected=[{'txid': true_tx_spend.rehash(), 'allowed': True, 'vsize': true_tx_spend.get_vsize(), 'fees': { 'base': Decimal('0.00000700')}}],
rawtxs=[true_tx_spend.serialize().hex()],
maxfeerate=0,
)

self.log.info('Spending a confirmed bare multisig is okay')
address = self.wallet.get_address()
tx = tx_from_hex(raw_tx_reference)
Expand Down

0 comments on commit 99e9d3c

Please sign in to comment.