diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-08-03 16:28:03 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2020-08-03 17:27:49 +0200 |
commit | 34eb2362581d4d8f0bfd3baa12ba750afaf85c62 (patch) | |
tree | e5d9f566382c037ca003da73dc3b5b6eabd43496 /src/test/key_tests.cpp | |
parent | 14ceddd29085b6cd9327892de4cd22ae2f3e0095 (diff) | |
parent | 77c507358bda9bd6c496f33e0f4418c0603bb08d (diff) |
Merge #19326: Simplify hash.h interface using Spans
77c507358bda9bd6c496f33e0f4418c0603bb08d Make Hash[160] consume range-like objects (Pieter Wuille)
02c4cc5c5ddf61f98ee366a4bea8abc26de492bd Make CHash256/CHash160 output to Span (Pieter Wuille)
0ef97b1b103231db54e04a64bbdb5dcc3f34f482 Make MurmurHash3 consume Spans (Pieter Wuille)
e549bf8a9afae42fcda805e216a1cde62df195a6 Make CHash256 and CHash160 consume Spans (Pieter Wuille)
2a2182c387f607cd8284f33890bd285a81077b7f Make script/standard's BaseHash Span-convertible (Pieter Wuille)
e63dcc3a6752e7d406e7a650c2d6c2e95cd39aab Add MakeUCharSpan, to help constructing Span<[const] unsigned char> (Pieter Wuille)
567825049fb0e47e698dcaad9caa65693a6b42d3 Make uint256 Span-convertible by adding ::data() (Pieter Wuille)
131a2f0337f5c396739a47b60bb856ed84ec8937 scripted-diff: rename base_blob::data to m_data (Pieter Wuille)
Pull request description:
This makes use of the implicit constructions and conversions to Span introduced in #18468 to simplify the hash.h interface:
* All functions that take a pointer and a length are changed to take a Span instead.
* The Hash() and Hash160() functions are changed to take in "range" objects instead of begin/end iterators.
ACKs for top commit:
laanwj:
re-ACK 77c507358bda9bd6c496f33e0f4418c0603bb08d
jonatack:
Code review re-ACK 77c5073 per `git range-diff 14ceddd 49fc016 77c5073`
Tree-SHA512: 9ec929891b1ddcf30eb14b946ee1bf142eca1442b9de0067ad6a3c181e0c7ea0c99c0e291e7f6e7a18bd7bdf78fe94ee3d5de66e167401674caf91e026269771
Diffstat (limited to 'src/test/key_tests.cpp')
-rw-r--r-- | src/test/key_tests.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index fd35537c77..4e4c44266a 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(key_test1) for (int n=0; n<16; n++) { std::string strMsg = strprintf("Very secret message %i: 11", n); - uint256 hashMsg = Hash(strMsg.begin(), strMsg.end()); + uint256 hashMsg = Hash(strMsg); // normal signatures @@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(key_test1) std::vector<unsigned char> detsig, detsigc; std::string strMsg = "Very deterministic message"; - uint256 hashMsg = Hash(strMsg.begin(), strMsg.end()); + uint256 hashMsg = Hash(strMsg); BOOST_CHECK(key1.Sign(hashMsg, detsig)); BOOST_CHECK(key1C.Sign(hashMsg, detsigc)); BOOST_CHECK(detsig == detsigc); @@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(key_signature_tests) // When entropy is specified, we should see at least one high R signature within 20 signatures CKey key = DecodeSecret(strSecret1); std::string msg = "A message to be signed"; - uint256 msg_hash = Hash(msg.begin(), msg.end()); + uint256 msg_hash = Hash(msg); std::vector<unsigned char> sig; bool found = false; @@ -179,7 +179,7 @@ BOOST_AUTO_TEST_CASE(key_signature_tests) for (int i = 0; i < 256; ++i) { sig.clear(); std::string msg = "A message to be signed" + ToString(i); - msg_hash = Hash(msg.begin(), msg.end()); + msg_hash = Hash(msg); BOOST_CHECK(key.Sign(msg_hash, sig)); found = sig[3] == 0x20; BOOST_CHECK(sig.size() <= 70); @@ -196,7 +196,7 @@ BOOST_AUTO_TEST_CASE(key_key_negation) std::string str = "Bitcoin key verification\n"; GetRandBytes(rnd, sizeof(rnd)); uint256 hash; - CHash256().Write((unsigned char*)str.data(), str.size()).Write(rnd, sizeof(rnd)).Finalize(hash.begin()); + CHash256().Write(MakeUCharSpan(str)).Write(rnd).Finalize(hash); // import the static test key CKey key = DecodeSecret(strSecret1C); |