diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-07-17 03:33:13 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2023-07-17 13:27:46 +0200 |
commit | 7d92b1430a6fd42c4438810640576830d0ff8d13 (patch) | |
tree | 32be45317bee88287fd0b2fa19af2e3b327395a5 /src/test | |
parent | 57b8336dfed6312003cf34cd5ae7099f77115e73 (diff) |
refactor: use Span for SipHash::Write
Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/addrman.cpp | 4 | ||||
-rw-r--r-- | src/test/fuzz/crypto.cpp | 2 | ||||
-rw-r--r-- | src/test/fuzz/golomb_rice.cpp | 2 | ||||
-rw-r--r-- | src/test/hash_tests.cpp | 16 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/test/fuzz/addrman.cpp b/src/test/fuzz/addrman.cpp index 10e5053e6d..d0c58ff885 100644 --- a/src/test/fuzz/addrman.cpp +++ b/src/test/fuzz/addrman.cpp @@ -171,8 +171,8 @@ public: hasher.Write(a.source.GetNetwork()); hasher.Write(addr_key.size()); hasher.Write(source_key.size()); - hasher.Write(addr_key.data(), addr_key.size()); - hasher.Write(source_key.data(), source_key.size()); + hasher.Write(addr_key); + hasher.Write(source_key); return (size_t)hasher.Finalize(); }; diff --git a/src/test/fuzz/crypto.cpp b/src/test/fuzz/crypto.cpp index 84b95117e2..ca8c1cd033 100644 --- a/src/test/fuzz/crypto.cpp +++ b/src/test/fuzz/crypto.cpp @@ -57,7 +57,7 @@ FUZZ_TARGET(crypto) (void)sha256.Write(data.data(), data.size()); (void)sha3.Write(data); (void)sha512.Write(data.data(), data.size()); - (void)sip_hasher.Write(data.data(), data.size()); + (void)sip_hasher.Write(data); (void)Hash(data); (void)Hash160(data); diff --git a/src/test/fuzz/golomb_rice.cpp b/src/test/fuzz/golomb_rice.cpp index 1a1225b635..e006653ca9 100644 --- a/src/test/fuzz/golomb_rice.cpp +++ b/src/test/fuzz/golomb_rice.cpp @@ -23,7 +23,7 @@ namespace { uint64_t HashToRange(const std::vector<uint8_t>& element, const uint64_t f) { const uint64_t hash = CSipHasher(0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL) - .Write(element.data(), element.size()) + .Write(element) .Finalize(); return FastRange64(hash, f); } diff --git a/src/test/hash_tests.cpp b/src/test/hash_tests.cpp index f1f435591b..a990797ca7 100644 --- a/src/test/hash_tests.cpp +++ b/src/test/hash_tests.cpp @@ -83,21 +83,21 @@ BOOST_AUTO_TEST_CASE(siphash) CSipHasher hasher(0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL); BOOST_CHECK_EQUAL(hasher.Finalize(), 0x726fdb47dd0e0e31ull); static const unsigned char t0[1] = {0}; - hasher.Write(t0, 1); + hasher.Write(t0); BOOST_CHECK_EQUAL(hasher.Finalize(), 0x74f839c593dc67fdull); static const unsigned char t1[7] = {1,2,3,4,5,6,7}; - hasher.Write(t1, 7); + hasher.Write(t1); BOOST_CHECK_EQUAL(hasher.Finalize(), 0x93f5f5799a932462ull); hasher.Write(0x0F0E0D0C0B0A0908ULL); BOOST_CHECK_EQUAL(hasher.Finalize(), 0x3f2acc7f57c29bdbull); static const unsigned char t2[2] = {16,17}; - hasher.Write(t2, 2); + hasher.Write(t2); BOOST_CHECK_EQUAL(hasher.Finalize(), 0x4bc1b3f0968dd39cull); static const unsigned char t3[9] = {18,19,20,21,22,23,24,25,26}; - hasher.Write(t3, 9); + hasher.Write(t3); BOOST_CHECK_EQUAL(hasher.Finalize(), 0x2f2e6163076bcfadull); static const unsigned char t4[5] = {27,28,29,30,31}; - hasher.Write(t4, 5); + hasher.Write(t4); BOOST_CHECK_EQUAL(hasher.Finalize(), 0x7127512f72f27cceull); hasher.Write(0x2726252423222120ULL); BOOST_CHECK_EQUAL(hasher.Finalize(), 0x0e3ea96b5304a7d0ull); @@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(siphash) for (uint8_t x=0; x<std::size(siphash_4_2_testvec); ++x) { BOOST_CHECK_EQUAL(hasher2.Finalize(), siphash_4_2_testvec[x]); - hasher2.Write(&x, 1); + hasher2.Write(Span{&x, 1}); } // Check test vectors from spec, eight bytes at a time CSipHasher hasher3(0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL); @@ -140,9 +140,9 @@ BOOST_AUTO_TEST_CASE(siphash) uint8_t nb[4]; WriteLE32(nb, n); CSipHasher sip256(k1, k2); - sip256.Write(x.begin(), 32); + sip256.Write(x); CSipHasher sip288 = sip256; - sip288.Write(nb, 4); + sip288.Write(nb); BOOST_CHECK_EQUAL(SipHashUint256(k1, k2, x), sip256.Finalize()); BOOST_CHECK_EQUAL(SipHashUint256Extra(k1, k2, x, n), sip288.Finalize()); } |