aboutsummaryrefslogtreecommitdiff
path: root/src/test/script_standard_tests.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-08-25 19:55:52 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2017-09-28 16:24:30 -0700
commitc091b99379b97cb314c9fa123beabdbc324cf7a4 (patch)
treef1cc720f195b18842831f964a3dd1fc71d29a4ff /src/test/script_standard_tests.cpp
parentbd355b8db9ffaacaafd10eb14f6b74cf00d8fc06 (diff)
Implement BIP173 addresses and tests
Diffstat (limited to 'src/test/script_standard_tests.cpp')
-rw-r--r--src/test/script_standard_tests.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/test/script_standard_tests.cpp b/src/test/script_standard_tests.cpp
index 3d17a0dbb6..bd2d9ed115 100644
--- a/src/test/script_standard_tests.cpp
+++ b/src/test/script_standard_tests.cpp
@@ -170,11 +170,6 @@ BOOST_AUTO_TEST_CASE(script_standard_Solver_failure)
s << OP_RETURN << std::vector<unsigned char>({75}) << OP_ADD;
BOOST_CHECK(!Solver(s, whichType, solutions));
- // TX_WITNESS with unknown version
- s.clear();
- s << OP_1 << ToByteVector(pubkey);
- BOOST_CHECK(!Solver(s, whichType, solutions));
-
// TX_WITNESS with incorrect program size
s.clear();
s << OP_0 << std::vector<unsigned char>(19, 0x01);
@@ -225,13 +220,29 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestination)
// TX_WITNESS_V0_KEYHASH
s.clear();
- s << OP_0 << ToByteVector(pubkey);
- BOOST_CHECK(!ExtractDestination(s, address));
+ s << OP_0 << ToByteVector(pubkey.GetID());
+ BOOST_CHECK(ExtractDestination(s, address));
+ WitnessV0KeyHash keyhash;
+ CHash160().Write(pubkey.begin(), pubkey.size()).Finalize(keyhash.begin());
+ BOOST_CHECK(boost::get<WitnessV0KeyHash>(&address) && *boost::get<WitnessV0KeyHash>(&address) == keyhash);
// TX_WITNESS_V0_SCRIPTHASH
s.clear();
- s << OP_0 << ToByteVector(CScriptID(redeemScript));
- BOOST_CHECK(!ExtractDestination(s, address));
+ WitnessV0ScriptHash scripthash;
+ CSHA256().Write(redeemScript.data(), redeemScript.size()).Finalize(scripthash.begin());
+ s << OP_0 << ToByteVector(scripthash);
+ BOOST_CHECK(ExtractDestination(s, address));
+ BOOST_CHECK(boost::get<WitnessV0ScriptHash>(&address) && *boost::get<WitnessV0ScriptHash>(&address) == scripthash);
+
+ // TX_WITNESS with unknown version
+ s.clear();
+ s << OP_1 << ToByteVector(pubkey);
+ BOOST_CHECK(ExtractDestination(s, address));
+ WitnessUnknown unk;
+ unk.length = 33;
+ unk.version = 1;
+ std::copy(pubkey.begin(), pubkey.end(), unk.program);
+ BOOST_CHECK(boost::get<WitnessUnknown>(&address) && *boost::get<WitnessUnknown>(&address) == unk);
}
BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
@@ -298,16 +309,6 @@ BOOST_AUTO_TEST_CASE(script_standard_ExtractDestinations)
s.clear();
s << OP_RETURN << std::vector<unsigned char>({75});
BOOST_CHECK(!ExtractDestinations(s, whichType, addresses, nRequired));
-
- // TX_WITNESS_V0_KEYHASH
- s.clear();
- s << OP_0 << ToByteVector(pubkeys[0].GetID());
- BOOST_CHECK(!ExtractDestinations(s, whichType, addresses, nRequired));
-
- // TX_WITNESS_V0_SCRIPTHASH
- s.clear();
- s << OP_0 << ToByteVector(CScriptID(redeemScript));
- BOOST_CHECK(!ExtractDestinations(s, whichType, addresses, nRequired));
}
BOOST_AUTO_TEST_CASE(script_standard_GetScriptFor_)