mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
test: add reason checks for non-standard txs in test_IsStandard
This commit is contained in:
parent
4c1090c882
commit
c1c6c410a6
1 changed files with 16 additions and 0 deletions
|
@ -706,7 +706,9 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||||
BOOST_CHECK_EQUAL(nDustThreshold, 546);
|
BOOST_CHECK_EQUAL(nDustThreshold, 546);
|
||||||
// dust:
|
// dust:
|
||||||
t.vout[0].nValue = nDustThreshold - 1;
|
t.vout[0].nValue = nDustThreshold - 1;
|
||||||
|
reason.clear();
|
||||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||||
|
BOOST_CHECK_EQUAL(reason, "dust");
|
||||||
// not dust:
|
// not dust:
|
||||||
t.vout[0].nValue = nDustThreshold;
|
t.vout[0].nValue = nDustThreshold;
|
||||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||||
|
@ -716,14 +718,18 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||||
dustRelayFee = CFeeRate(3702);
|
dustRelayFee = CFeeRate(3702);
|
||||||
// dust:
|
// dust:
|
||||||
t.vout[0].nValue = 673 - 1;
|
t.vout[0].nValue = 673 - 1;
|
||||||
|
reason.clear();
|
||||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||||
|
BOOST_CHECK_EQUAL(reason, "dust");
|
||||||
// not dust:
|
// not dust:
|
||||||
t.vout[0].nValue = 673;
|
t.vout[0].nValue = 673;
|
||||||
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
BOOST_CHECK(IsStandardTx(CTransaction(t), reason));
|
||||||
dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
|
dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
|
||||||
|
|
||||||
t.vout[0].scriptPubKey = CScript() << OP_1;
|
t.vout[0].scriptPubKey = CScript() << OP_1;
|
||||||
|
reason.clear();
|
||||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||||
|
BOOST_CHECK_EQUAL(reason, "scriptpubkey");
|
||||||
|
|
||||||
// MAX_OP_RETURN_RELAY-byte TX_NULL_DATA (standard)
|
// MAX_OP_RETURN_RELAY-byte TX_NULL_DATA (standard)
|
||||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
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)
|
// MAX_OP_RETURN_RELAY+1-byte TX_NULL_DATA (non-standard)
|
||||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800");
|
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3800");
|
||||||
BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY + 1, t.vout[0].scriptPubKey.size());
|
BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY + 1, t.vout[0].scriptPubKey.size());
|
||||||
|
reason.clear();
|
||||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||||
|
BOOST_CHECK_EQUAL(reason, "scriptpubkey");
|
||||||
|
|
||||||
// Data payload can be encoded in any way...
|
// Data payload can be encoded in any way...
|
||||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("");
|
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
|
// ...so long as it only contains PUSHDATA's
|
||||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_RETURN;
|
t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_RETURN;
|
||||||
|
reason.clear();
|
||||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||||
|
BOOST_CHECK_EQUAL(reason, "scriptpubkey");
|
||||||
|
|
||||||
// TX_NULL_DATA w/o PUSHDATA
|
// TX_NULL_DATA w/o PUSHDATA
|
||||||
t.vout.resize(1);
|
t.vout.resize(1);
|
||||||
|
@ -759,15 +769,21 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
|
||||||
t.vout.resize(2);
|
t.vout.resize(2);
|
||||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||||
t.vout[1].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(!IsStandardTx(CTransaction(t), reason));
|
||||||
|
BOOST_CHECK_EQUAL(reason, "multi-op-return");
|
||||||
|
|
||||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
|
||||||
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
|
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
|
||||||
|
reason.clear();
|
||||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||||
|
BOOST_CHECK_EQUAL(reason, "multi-op-return");
|
||||||
|
|
||||||
t.vout[0].scriptPubKey = CScript() << OP_RETURN;
|
t.vout[0].scriptPubKey = CScript() << OP_RETURN;
|
||||||
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
|
t.vout[1].scriptPubKey = CScript() << OP_RETURN;
|
||||||
|
reason.clear();
|
||||||
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
BOOST_CHECK(!IsStandardTx(CTransaction(t), reason));
|
||||||
|
BOOST_CHECK_EQUAL(reason, "multi-op-return");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
Loading…
Add table
Reference in a new issue