From 7dfabdcf860c529772a54b0e8fa235cbb4a78b4d Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Sat, 19 Aug 2023 13:01:14 +1000 Subject: [PATCH 1/2] tests: test both settings for permitbaremultisig in p2sh tests --- src/test/script_p2sh_tests.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/test/script_p2sh_tests.cpp b/src/test/script_p2sh_tests.cpp index 739ab75de3..54dcc218b9 100644 --- a/src/test/script_p2sh_tests.cpp +++ b/src/test/script_p2sh_tests.cpp @@ -18,9 +18,15 @@ #include // Helpers: +static bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, std::string& reason) +{ + return IsStandardTx(tx, std::nullopt, permit_bare_multisig, CFeeRate{DUST_RELAY_TX_FEE}, reason); +} + static bool IsStandardTx(const CTransaction& tx, std::string& reason) { - return IsStandardTx(tx, std::nullopt, DEFAULT_PERMIT_BAREMULTISIG, CFeeRate{DUST_RELAY_TX_FEE}, reason); + return IsStandardTx(tx, std::nullopt, /*permit_bare_multisig=*/true, CFeeRate{DUST_RELAY_TX_FEE}, reason) && + IsStandardTx(tx, std::nullopt, /*permit_bare_multisig=*/false, CFeeRate{DUST_RELAY_TX_FEE}, reason); } static std::vector Serialize(const CScript& s) @@ -201,7 +207,9 @@ BOOST_AUTO_TEST_CASE(set) { SignatureData empty; BOOST_CHECK_MESSAGE(SignSignature(keystore, CTransaction(txFrom), txTo[i], 0, SIGHASH_ALL, empty), strprintf("SignSignature %d", i)); - BOOST_CHECK_MESSAGE(IsStandardTx(CTransaction(txTo[i]), reason), strprintf("txTo[%d].IsStandard", i)); + BOOST_CHECK_MESSAGE(IsStandardTx(CTransaction(txTo[i]), /*permit_bare_multisig=*/true, reason), strprintf("txTo[%d].IsStandard", i)); + bool no_pbms_is_std = IsStandardTx(CTransaction(txTo[i]), /*permit_bare_multisig=*/false, reason); + BOOST_CHECK_MESSAGE((i == 0 ? no_pbms_is_std : !no_pbms_is_std), strprintf("txTo[%d].IsStandard(permbaremulti=false)", i)); } } From 7b45744df33c6a4759eae1a3984f389cbac837c2 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Fri, 15 Dec 2023 16:11:11 +1000 Subject: [PATCH 2/2] tests: ensure functional tests set permitbaremultisig=1 when needed The mempool_dust and mempool_sigoplimits functional tests both use bare multisig txs, so ensure they're allowed by policy. --- test/functional/mempool_dust.py | 3 ++- test/functional/mempool_sigoplimit.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/functional/mempool_dust.py b/test/functional/mempool_dust.py index f4e385a112..e0c026207a 100755 --- a/test/functional/mempool_dust.py +++ b/test/functional/mempool_dust.py @@ -40,6 +40,7 @@ class DustRelayFeeTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 + self.extra_args = [['-permitbaremultisig']] def test_dust_output(self, node: TestNode, dust_relay_fee: Decimal, output_script: CScript, type_desc: str) -> None: @@ -101,7 +102,7 @@ def run_test(self): else: dust_parameter = f"-dustrelayfee={dustfee_btc_kvb:.8f}" self.log.info(f"Test dust limit setting {dust_parameter} ({dustfee_sat_kvb} sat/kvB)...") - self.restart_node(0, extra_args=[dust_parameter]) + self.restart_node(0, extra_args=[dust_parameter, "-permitbaremultisig"]) for output_script, description in output_scripts: self.test_dust_output(self.nodes[0], dustfee_btc_kvb, output_script, description) diff --git a/test/functional/mempool_sigoplimit.py b/test/functional/mempool_sigoplimit.py index fbec6d0dc8..d1e8ed0c64 100755 --- a/test/functional/mempool_sigoplimit.py +++ b/test/functional/mempool_sigoplimit.py @@ -140,7 +140,7 @@ def test_sigops_package(self): self.log.info("Test a overly-large sigops-vbyte hits package limits") # Make a 2-transaction package which fails vbyte checks even though # separately they would work. - self.restart_node(0, extra_args=["-bytespersigop=5000"] + self.extra_args[0]) + self.restart_node(0, extra_args=["-bytespersigop=5000","-permitbaremultisig=1"] + self.extra_args[0]) def create_bare_multisig_tx(utxo_to_spend=None): _, pubkey = generate_keypair()