aboutsummaryrefslogtreecommitdiff
path: root/src/test/script_standard_tests.cpp
diff options
context:
space:
mode:
authorGreg Sanders <gsanders87@gmail.com>2023-11-08 14:07:49 -0500
committerGreg Sanders <gsanders87@gmail.com>2024-07-30 14:06:58 -0400
commit455fca86cfada1823aa28615b5683f9dc73dbb9a (patch)
tree5d87a5a2520bf891297f01481bdb475a9b15e012 /src/test/script_standard_tests.cpp
parent8754d055c65e11fd2afa59f9e5de7c60a9e0ec23 (diff)
policy: Add OP_1 <0x4e73> as a standard output type
These outputs are called anchors, and allow key-less anchor spends which are vsize-minimized versus keyed anchors which require larger outputs when creating and inputs when spending.
Diffstat (limited to 'src/test/script_standard_tests.cpp')
-rw-r--r--src/test/script_standard_tests.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/test/script_standard_tests.cpp b/src/test/script_standard_tests.cpp
index 29e2d4a569..cd4c6ba3ba 100644
--- a/src/test/script_standard_tests.cpp
+++ b/src/test/script_standard_tests.cpp
@@ -128,6 +128,20 @@ BOOST_AUTO_TEST_CASE(script_standard_Solver_success)
BOOST_CHECK(solutions[0] == std::vector<unsigned char>{16});
BOOST_CHECK(solutions[1] == ToByteVector(uint256::ONE));
+ // TxoutType::ANCHOR
+ std::vector<unsigned char> anchor_bytes{0x4e, 0x73};
+ s.clear();
+ s << OP_1 << anchor_bytes;
+ BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::ANCHOR);
+ BOOST_CHECK(solutions.empty());
+
+ // Sanity-check IsPayToAnchor
+ int version{-1};
+ std::vector<unsigned char> witness_program;
+ BOOST_CHECK(s.IsPayToAnchor());
+ BOOST_CHECK(s.IsWitnessProgram(version, witness_program));
+ BOOST_CHECK(CScript::IsPayToAnchor(version, witness_program));
+
// TxoutType::NONSTANDARD
s.clear();
s << OP_9 << OP_ADD << OP_11 << OP_EQUAL;
@@ -186,6 +200,18 @@ BOOST_AUTO_TEST_CASE(script_standard_Solver_failure)
s.clear();
s << OP_0 << std::vector<unsigned char>(19, 0x01);
BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::NONSTANDARD);
+
+ // TxoutType::ANCHOR but wrong witness version
+ s.clear();
+ s << OP_2 << std::vector<unsigned char>{0x4e, 0x73};
+ BOOST_CHECK(!s.IsPayToAnchor());
+ BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::WITNESS_UNKNOWN);
+
+ // TxoutType::ANCHOR but wrong 2-byte data push
+ s.clear();
+ s << OP_1 << std::vector<unsigned char>{0xff, 0xff};
+ BOOST_CHECK(!s.IsPayToAnchor());
+ BOOST_CHECK_EQUAL(Solver(s, solutions), TxoutType::WITNESS_UNKNOWN);
}
BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)