mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 02:33:24 -03:00
qa: bound testing for TapMiniscript
Make sure we can spend a maximum-sized Miniscript under Tapscript context.
This commit is contained in:
parent
117927bd5f
commit
128bc104ef
2 changed files with 27 additions and 1 deletions
|
@ -105,6 +105,7 @@ BASE_SCRIPTS = [
|
|||
'feature_maxuploadtarget.py',
|
||||
'mempool_updatefromblock.py',
|
||||
'mempool_persist.py --descriptors',
|
||||
'wallet_miniscript.py --descriptors',
|
||||
# vv Tests less than 60s vv
|
||||
'rpc_psbt.py --legacy-wallet',
|
||||
'rpc_psbt.py --descriptors',
|
||||
|
@ -242,7 +243,6 @@ BASE_SCRIPTS = [
|
|||
'wallet_keypool.py --legacy-wallet',
|
||||
'wallet_keypool.py --descriptors',
|
||||
'wallet_descriptor.py --descriptors',
|
||||
'wallet_miniscript.py --descriptors',
|
||||
'p2p_nobloomfilter_messages.py',
|
||||
'p2p_filter.py',
|
||||
'rpc_setban.py',
|
||||
|
|
|
@ -205,6 +205,7 @@ DESCS_PRIV = [
|
|||
class WalletMiniscriptTest(BitcoinTestFramework):
|
||||
def add_options(self, parser):
|
||||
self.add_wallet_options(parser, legacy=False)
|
||||
self.rpc_timeout = 480
|
||||
|
||||
def set_test_params(self):
|
||||
self.num_nodes = 1
|
||||
|
@ -373,6 +374,31 @@ class WalletMiniscriptTest(BitcoinTestFramework):
|
|||
desc.get("sha256_preimages"),
|
||||
)
|
||||
|
||||
# Test we can sign for a max-size TapMiniscript. Recompute the maximum accepted size
|
||||
# for a TapMiniscript (see cpp file for details). Then pad a simple pubkey check up
|
||||
# to the maximum size. Make sure we can import and spend this script.
|
||||
leeway_weight = (4 + 4 + 1 + 36 + 4 + 1 + 1 + 8 + 1 + 1 + 33) * 4 + 2
|
||||
max_tapmini_size = 400_000 - 3 - (1 + 65) * 1_000 - 3 - (33 + 32 * 128) - leeway_weight - 5
|
||||
padding = max_tapmini_size - 33 - 1
|
||||
ms = f"pk({TPRVS[0]}/*)"
|
||||
ms = "n" * padding + ":" + ms
|
||||
desc = f"tr({PUBKEYS[0]},{ms})"
|
||||
self.signing_test(desc, None, None, 1, 3, None)
|
||||
# This was really the maximum size, one more byte and we can't import it.
|
||||
ms = "n" + ms
|
||||
desc = f"tr({PUBKEYS[0]},{ms})"
|
||||
res = self.ms_wo_wallet.importdescriptors(
|
||||
[
|
||||
{
|
||||
"desc": descsum_create(desc),
|
||||
"active": False,
|
||||
"timestamp": "now",
|
||||
}
|
||||
]
|
||||
)[0]
|
||||
assert not res["success"]
|
||||
assert "is not a valid descriptor function" in res["error"]["message"]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
WalletMiniscriptTest().main()
|
||||
|
|
Loading…
Add table
Reference in a new issue