diff options
author | Antoine Poinsot <darosior@protonmail.com> | 2023-09-26 09:31:36 +0200 |
---|---|---|
committer | Antoine Poinsot <darosior@protonmail.com> | 2023-10-08 02:43:26 +0200 |
commit | 128bc104ef07e1edaad5378e2ca53e97672a1652 (patch) | |
tree | 95771f83c25156fbcc6e0089571b9533a366bc56 | |
parent | 117927bd5f30c8bf09aaf91e62f5244990788084 (diff) |
qa: bound testing for TapMiniscript
Make sure we can spend a maximum-sized Miniscript under Tapscript
context.
-rwxr-xr-x | test/functional/test_runner.py | 2 | ||||
-rwxr-xr-x | test/functional/wallet_miniscript.py | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 933ea276e7..fbf48a0e4d 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -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', 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() |