Skip to content

Commit

Permalink
test: add createmultisig P2MS encoding test for all n (1..20)
Browse files Browse the repository at this point in the history
  • Loading branch information
theStack committed Jan 22, 2024
1 parent a36ad0c commit d113709
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/functional/rpc_createmultisig.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from test_framework.authproxy import JSONRPCException
from test_framework.descriptors import descsum_create, drop_origins
from test_framework.key import ECPubKey
from test_framework.script_util import keys_to_multisig_script
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_raises_rpc_error,
Expand Down Expand Up @@ -118,6 +119,16 @@ def run_test(self):
# Check that bech32m is currently not allowed
assert_raises_rpc_error(-5, "createmultisig cannot create bech32m multisig addresses", self.nodes[0].createmultisig, 2, self.pub, "bech32m")

self.log.info('Check correct encoding of multisig script for all n (1..20)')
for nkeys in range(1, 20+1):
keys = [self.pub[0]]*nkeys
expected_ms_script = keys_to_multisig_script(keys, k=nkeys) # simply use n-of-n
# note that the 'legacy' address type fails for n values larger than 15
# due to exceeding the P2SH size limit (520 bytes), so we use 'bech32' instead
# (for the purpose of this encoding test, we don't care about the resulting address)
res = self.nodes[0].createmultisig(nrequired=nkeys, keys=keys, address_type='bech32')
assert_equal(res['redeemScript'], expected_ms_script.hex())

def check_addmultisigaddress_errors(self):
if self.options.descriptors:
return
Expand Down

0 comments on commit d113709

Please sign in to comment.