aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_miniscript.py
diff options
context:
space:
mode:
authorAntoine Poinsot <darosior@protonmail.com>2023-09-26 09:31:36 +0200
committerAntoine Poinsot <darosior@protonmail.com>2023-10-08 02:43:26 +0200
commit128bc104ef07e1edaad5378e2ca53e97672a1652 (patch)
tree95771f83c25156fbcc6e0089571b9533a366bc56 /test/functional/wallet_miniscript.py
parent117927bd5f30c8bf09aaf91e62f5244990788084 (diff)
downloadbitcoin-128bc104ef07e1edaad5378e2ca53e97672a1652.tar.xz
qa: bound testing for TapMiniscript
Make sure we can spend a maximum-sized Miniscript under Tapscript context.
Diffstat (limited to 'test/functional/wallet_miniscript.py')
-rwxr-xr-xtest/functional/wallet_miniscript.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/functional/wallet_miniscript.py b/test/functional/wallet_miniscript.py
index 28418e5974..d174b525b3 100755
--- a/test/functional/wallet_miniscript.py
+++ b/test/functional/wallet_miniscript.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()