Skip to content

Commit 128bc10

Browse files
committed
qa: bound testing for TapMiniscript
Make sure we can spend a maximum-sized Miniscript under Tapscript context.
1 parent 117927b commit 128bc10

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

test/functional/test_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
'feature_maxuploadtarget.py',
106106
'mempool_updatefromblock.py',
107107
'mempool_persist.py --descriptors',
108+
'wallet_miniscript.py --descriptors',
108109
# vv Tests less than 60s vv
109110
'rpc_psbt.py --legacy-wallet',
110111
'rpc_psbt.py --descriptors',
@@ -242,7 +243,6 @@
242243
'wallet_keypool.py --legacy-wallet',
243244
'wallet_keypool.py --descriptors',
244245
'wallet_descriptor.py --descriptors',
245-
'wallet_miniscript.py --descriptors',
246246
'p2p_nobloomfilter_messages.py',
247247
'p2p_filter.py',
248248
'rpc_setban.py',

test/functional/wallet_miniscript.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
class WalletMiniscriptTest(BitcoinTestFramework):
206206
def add_options(self, parser):
207207
self.add_wallet_options(parser, legacy=False)
208+
self.rpc_timeout = 480
208209

209210
def set_test_params(self):
210211
self.num_nodes = 1
@@ -373,6 +374,31 @@ def run_test(self):
373374
desc.get("sha256_preimages"),
374375
)
375376

377+
# Test we can sign for a max-size TapMiniscript. Recompute the maximum accepted size
378+
# for a TapMiniscript (see cpp file for details). Then pad a simple pubkey check up
379+
# to the maximum size. Make sure we can import and spend this script.
380+
leeway_weight = (4 + 4 + 1 + 36 + 4 + 1 + 1 + 8 + 1 + 1 + 33) * 4 + 2
381+
max_tapmini_size = 400_000 - 3 - (1 + 65) * 1_000 - 3 - (33 + 32 * 128) - leeway_weight - 5
382+
padding = max_tapmini_size - 33 - 1
383+
ms = f"pk({TPRVS[0]}/*)"
384+
ms = "n" * padding + ":" + ms
385+
desc = f"tr({PUBKEYS[0]},{ms})"
386+
self.signing_test(desc, None, None, 1, 3, None)
387+
# This was really the maximum size, one more byte and we can't import it.
388+
ms = "n" + ms
389+
desc = f"tr({PUBKEYS[0]},{ms})"
390+
res = self.ms_wo_wallet.importdescriptors(
391+
[
392+
{
393+
"desc": descsum_create(desc),
394+
"active": False,
395+
"timestamp": "now",
396+
}
397+
]
398+
)[0]
399+
assert not res["success"]
400+
assert "is not a valid descriptor function" in res["error"]["message"]
401+
376402

377403
if __name__ == "__main__":
378404
WalletMiniscriptTest().main()

0 commit comments

Comments
 (0)