Skip to content

Commit

Permalink
[test] Separate 64B and 63B tx size tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ajtowns committed May 6, 2024
1 parent 5ad0bab commit 06c4a7c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/functional/data/invalid_txs.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get_tx(self):

# The following check prevents exploit of lack of merkle
# tree depth commitment (CVE-2017-12842)
class SizeTooSmall(BadTxTemplate):
class SizeExactly64(BadTxTemplate):
reject_reason = "tx-size-small"
expect_disconnect = False
valid_in_block = True
Expand All @@ -129,6 +129,20 @@ def get_tx(self):
tx.calc_sha256()
return tx

class SizeSub64(BadTxTemplate):
reject_reason = "tx-size-small"
expect_disconnect = False
valid_in_block = True

def get_tx(self):
tx = CTransaction()
tx.vin.append(self.valid_txin)
tx.vout.append(CTxOut(0, CScript([OP_RETURN] + ([OP_0] * (MIN_PADDING - 3)))))
assert len(tx.serialize_without_witness()) == 63
assert MIN_STANDARD_TX_NONWITNESS_SIZE - 1 == 64
tx.calc_sha256()
return tx


class BadInputOutpointIndex(BadTxTemplate):
# Won't be rejected - nonexistent outpoint index is treated as an orphan since the coins
Expand Down

0 comments on commit 06c4a7c

Please sign in to comment.