mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-31 02:02:47 +02:00
Merge #17299: test: add reason checks for non-standard txs in test_IsStandard
c1c6c410a66996b2d60d5172189b5a5ec8100842 test: add reason checks for non-standard txs in test_IsStandard (Sebastian Falbesoner) Pull request description: While taking a look at #17272 I noticed that for some reason the unit test `test_IsStandard` (which was not adapted to the policy change in the referenced PR commits) didn't fail as expected:6a97e8a060/src/test/transaction_tests.cpp (L758-L762)
It turned out that `IsStandardTx()` returned `"dust"` as rejection reason (instead of the expected `"multi-op-return"`), leading to the conclusion that5fe6f052bd
erroneously performs the `IsDust()` check also for TX_NULL_DATA transactions. To avoid cases like this in the future, this PR makes the unit test `test_IsStandard` more strict by also checking for the concrete reason after each occurence of `IsStandardTx()` returning false. ACKs for top commit: instagibbs: utACKc1c6c410a6
Tree-SHA512: c7419884cc52977c73f8f8c476eaebed80ba7bda4d03509d3f46dd977be911389f7b53daefa5ef31d2f7df9402243152e01e83f1b8a9fb300c19d1a0f69a89a9
This commit is contained in:
commit
ecad0a8019
@ -706,7 +706,9 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||
BOOST_CHECK_EQUAL(nDustThreshold, 546);
|
||||
// dust:
|
||||
t.vout[0].nValue = nDustThreshold - 1;
|
||||
reason.clear();
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
BOOST_CHECK_EQUAL(reason, "dust");
|
||||
// not dust:
|
||||
t.vout[0].nValue = nDustThreshold;
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||
@ -716,14 +718,18 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||
dustRelayFee = CFeeRate(3702);
|
||||
// dust:
|
||||
t.vout[0].nValue = 673 - 1;
|
||||
reason.clear();
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
BOOST_CHECK_EQUAL(reason, "dust");
|
||||
// not dust:
|
||||
t.vout[0].nValue = 673;
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||
dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
|
||||
|
||||
t.vout[0].scriptPubKey = CScript() << OP_1;
|
||||
reason.clear();
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
BOOST_CHECK_EQUAL(reason, "scriptpubkey");
|
||||
|
||||
// MAX_OP_RETURN_RELAY-byte TX_NULL_DATA (standard)
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||
@ -733,7 +739,9 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||
// MAX_OP_RETURN_RELAY+1-byte TX_NULL_DATA (non-standard)
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800");
|
||||
BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY + 1, t.vout[0].scriptPubKey.size());
|
||||
reason.clear();
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
BOOST_CHECK_EQUAL(reason, "scriptpubkey");
|
||||
|
||||
// Data payload can be encoded in any way...
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("");
|
||||
@ -748,7 +756,9 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||
|
||||
// ...so long as it only contains PUSHDATA's
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_RETURN;
|
||||
reason.clear();
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
BOOST_CHECK_EQUAL(reason, "scriptpubkey");
|
||||
|
||||
// TX_NULL_DATA w/o PUSHDATA
|
||||
t.vout.resize(1);
|
||||
@ -759,15 +769,21 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||
t.vout.resize(2);
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||
t.vout[1].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||
reason.clear();
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
BOOST_CHECK_EQUAL(reason, "multi-op-return");
|
||||
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
|
||||
reason.clear();
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
BOOST_CHECK_EQUAL(reason, "multi-op-return");
|
||||
|
||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN;
|
||||
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
|
||||
reason.clear();
|
||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||
BOOST_CHECK_EQUAL(reason, "multi-op-return");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
Loading…
x
Reference in New Issue
Block a user