Page MenuHomePhabricator

D17933.id53496.diff
No OneTemporary

D17933.id53496.diff

diff --git a/test/functional/test_framework/txtools.py b/test/functional/test_framework/txtools.py
--- a/test/functional/test_framework/txtools.py
+++ b/test/functional/test_framework/txtools.py
@@ -9,7 +9,7 @@
VOUT_VALUE_SIZE = 8
-def pad_tx(tx: CTransaction, pad_to_size: int = MIN_TX_SIZE):
+def pad_tx(tx: CTransaction, pad_to_size: int = MIN_TX_SIZE, deterministic=False):
"""
Pad a transaction with op_return junk data until it is at least pad_to_size,
or leave it alone if it's already bigger than that.
@@ -61,18 +61,21 @@
required_padding -= data_size + VOUT_VALUE_SIZE + 3
- tx.vout.append(CTxOut(0, CScript([OP_RETURN, random.randbytes(data_size)])))
+ # Note that this deterministic data affect the assumeutxo/dumptxoutset hash
+ # used in feature_assumeutxo.py and set in CRegTestParams::m_assumeutxo_data
+ data = b"\x00" * data_size if deterministic else random.randbytes(data_size)
+ tx.vout.append(CTxOut(0, CScript([OP_RETURN, data])))
tx.rehash()
-def pad_raw_tx(rawtx_hex, min_size=MIN_TX_SIZE):
+def pad_raw_tx(rawtx_hex, min_size=MIN_TX_SIZE, deterministic=False):
"""
Pad a raw transaction with OP_RETURN data until it reaches at least min_size
"""
tx = CTransaction()
FromHex(tx, rawtx_hex)
- pad_tx(tx, min_size)
+ pad_tx(tx, min_size, deterministic)
return ToHex(tx)
@@ -89,9 +92,11 @@
return len(bytes.fromhex(rawtx))
def test_size(requested_size, expected_size):
- self.assertEqual(
- rawtx_length(pad_raw_tx(raw_tx, requested_size)), expected_size
- )
+ for deterministic in (True, False):
+ self.assertEqual(
+ rawtx_length(pad_raw_tx(raw_tx, requested_size, deterministic)),
+ expected_size,
+ )
self.assertEqual(rawtx_length(raw_tx), 85)
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -350,7 +350,7 @@
),
)
- pad_tx(tx, target_size or 100)
+ pad_tx(tx, target_size or 100, deterministic=True)
txid = tx.rehash()
return {

File Metadata

Mime Type
text/plain
Expires
Tue, May 20, 21:32 (17 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5863297
Default Alt Text
D17933.id53496.diff (2 KB)

Event Timeline