Skip to content

Commit 1bb5d51

Browse files
committed
test: add unit test for non-standard bare multisig txs
The function IsStandardTx() returns rejection reason "bare-multisig" if the transaction has a bare multisig output and the policy flag fIsBareMultisigStd is false (set by the boolean command-line argument "-permitbaremultisig" -- for the unit test, we simply set the global flag variable directly).
1 parent 7dbc33f commit 1bb5d51

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test/transaction_tests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,17 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
797797
reason.clear();
798798
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
799799
BOOST_CHECK_EQUAL(reason, "scriptsig-size");
800+
801+
// Check bare multisig (standard if policy flag fIsBareMultisigStd is set)
802+
fIsBareMultisigStd = true;
803+
t.vout[0].scriptPubKey = GetScriptForMultisig(1, {key.GetPubKey()}); // simple 1-of-1
804+
t.vin[0].scriptSig = CScript() << std::vector<unsigned char>(65, 0);
805+
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
806+
807+
fIsBareMultisigStd = false;
808+
reason.clear();
809+
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
810+
BOOST_CHECK_EQUAL(reason, "bare-multisig");
800811
}
801812

802813
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)