diff options
author | Anthony Towns <aj@erisian.com.au> | 2023-11-01 22:46:17 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2023-11-16 11:14:13 +1000 |
commit | 1410d300df7e57a895f2697d9849a2201021c973 (patch) | |
tree | cf74f8da1b94c7237bca1162a903b004e2ef62a4 /src/test | |
parent | bf574a75016123309b894da895ab1c7a81731933 (diff) | |
download | bitcoin-1410d300df7e57a895f2697d9849a2201021c973.tar.xz |
serialize: Drop useless version param from GetSerializeSize()
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/flatfile_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/fuzz/miniscript.cpp | 2 | ||||
-rw-r--r-- | src/test/miniscript_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/serialize_tests.cpp | 48 | ||||
-rw-r--r-- | src/test/uint256_tests.cpp | 8 |
5 files changed, 31 insertions, 31 deletions
diff --git a/src/test/flatfile_tests.cpp b/src/test/flatfile_tests.cpp index 3874b38f61..21a36d9d43 100644 --- a/src/test/flatfile_tests.cpp +++ b/src/test/flatfile_tests.cpp @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE(flatfile_open) "lost if a trusted third party is still required to prevent double-spending."); size_t pos1 = 0; - size_t pos2 = pos1 + GetSerializeSize(line1, CLIENT_VERSION); + size_t pos2 = pos1 + GetSerializeSize(line1); // Write first line to file. { diff --git a/src/test/fuzz/miniscript.cpp b/src/test/fuzz/miniscript.cpp index 8c73edfa9d..0d0ee59ab3 100644 --- a/src/test/fuzz/miniscript.cpp +++ b/src/test/fuzz/miniscript.cpp @@ -1121,7 +1121,7 @@ void TestNode(const MsCtx script_ctx, const NodeRef& node, FuzzedDataProvider& p assert(mal_success); assert(stack_nonmal == stack_mal); // Compute witness size (excluding script push, control block, and witness count encoding). - const size_t wit_size = GetSerializeSize(stack_nonmal, PROTOCOL_VERSION) - GetSizeOfCompactSize(stack_nonmal.size()); + const size_t wit_size = GetSerializeSize(stack_nonmal) - GetSizeOfCompactSize(stack_nonmal.size()); assert(wit_size <= *node->GetWitnessSize()); // Test non-malleable satisfaction. diff --git a/src/test/miniscript_tests.cpp b/src/test/miniscript_tests.cpp index 996c379962..1f28e61bc9 100644 --- a/src/test/miniscript_tests.cpp +++ b/src/test/miniscript_tests.cpp @@ -369,7 +369,7 @@ void TestSatisfy(const KeyConverter& converter, const std::string& testcase, con CScriptWitness witness_nonmal; const bool nonmal_success = node->Satisfy(satisfier, witness_nonmal.stack, true) == miniscript::Availability::YES; // Compute witness size (excluding script push, control block, and witness count encoding). - const size_t wit_size = GetSerializeSize(witness_nonmal.stack, PROTOCOL_VERSION) - GetSizeOfCompactSize(witness_nonmal.stack.size()); + const size_t wit_size = GetSerializeSize(witness_nonmal.stack) - GetSizeOfCompactSize(witness_nonmal.stack.size()); SatisfactionToWitness(converter.MsContext(), witness_nonmal, script, builder); if (nonmal_success) { diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index 6d5a14ad9e..d75eb499b4 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -62,31 +62,31 @@ public: BOOST_AUTO_TEST_CASE(sizes) { - BOOST_CHECK_EQUAL(sizeof(unsigned char), GetSerializeSize((unsigned char)0, 0)); - BOOST_CHECK_EQUAL(sizeof(int8_t), GetSerializeSize(int8_t(0), 0)); - BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(uint8_t(0), 0)); - BOOST_CHECK_EQUAL(sizeof(int16_t), GetSerializeSize(int16_t(0), 0)); - BOOST_CHECK_EQUAL(sizeof(uint16_t), GetSerializeSize(uint16_t(0), 0)); - BOOST_CHECK_EQUAL(sizeof(int32_t), GetSerializeSize(int32_t(0), 0)); - BOOST_CHECK_EQUAL(sizeof(uint32_t), GetSerializeSize(uint32_t(0), 0)); - BOOST_CHECK_EQUAL(sizeof(int64_t), GetSerializeSize(int64_t(0), 0)); - BOOST_CHECK_EQUAL(sizeof(uint64_t), GetSerializeSize(uint64_t(0), 0)); + BOOST_CHECK_EQUAL(sizeof(unsigned char), GetSerializeSize((unsigned char)0)); + BOOST_CHECK_EQUAL(sizeof(int8_t), GetSerializeSize(int8_t(0))); + BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(uint8_t(0))); + BOOST_CHECK_EQUAL(sizeof(int16_t), GetSerializeSize(int16_t(0))); + BOOST_CHECK_EQUAL(sizeof(uint16_t), GetSerializeSize(uint16_t(0))); + BOOST_CHECK_EQUAL(sizeof(int32_t), GetSerializeSize(int32_t(0))); + BOOST_CHECK_EQUAL(sizeof(uint32_t), GetSerializeSize(uint32_t(0))); + BOOST_CHECK_EQUAL(sizeof(int64_t), GetSerializeSize(int64_t(0))); + BOOST_CHECK_EQUAL(sizeof(uint64_t), GetSerializeSize(uint64_t(0))); // Bool is serialized as uint8_t - BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(bool(0), 0)); + BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(bool(0))); // Sanity-check GetSerializeSize and c++ type matching - BOOST_CHECK_EQUAL(GetSerializeSize((unsigned char)0, 0), 1U); - BOOST_CHECK_EQUAL(GetSerializeSize(int8_t(0), 0), 1U); - BOOST_CHECK_EQUAL(GetSerializeSize(uint8_t(0), 0), 1U); - BOOST_CHECK_EQUAL(GetSerializeSize(int16_t(0), 0), 2U); - BOOST_CHECK_EQUAL(GetSerializeSize(uint16_t(0), 0), 2U); - BOOST_CHECK_EQUAL(GetSerializeSize(int32_t(0), 0), 4U); - BOOST_CHECK_EQUAL(GetSerializeSize(uint32_t(0), 0), 4U); - BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0), 0), 8U); - BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0), 0), 8U); - BOOST_CHECK_EQUAL(GetSerializeSize(bool(0), 0), 1U); - BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 1>{0}, 0), 1U); - BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 2>{0, 0}, 0), 2U); + BOOST_CHECK_EQUAL(GetSerializeSize((unsigned char)0), 1U); + BOOST_CHECK_EQUAL(GetSerializeSize(int8_t(0)), 1U); + BOOST_CHECK_EQUAL(GetSerializeSize(uint8_t(0)), 1U); + BOOST_CHECK_EQUAL(GetSerializeSize(int16_t(0)), 2U); + BOOST_CHECK_EQUAL(GetSerializeSize(uint16_t(0)), 2U); + BOOST_CHECK_EQUAL(GetSerializeSize(int32_t(0)), 4U); + BOOST_CHECK_EQUAL(GetSerializeSize(uint32_t(0)), 4U); + BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0)), 8U); + BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0)), 8U); + BOOST_CHECK_EQUAL(GetSerializeSize(bool(0)), 1U); + BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 1>{0}), 1U); + BOOST_CHECK_EQUAL(GetSerializeSize(std::array<uint8_t, 2>{0, 0}), 2U); } BOOST_AUTO_TEST_CASE(varints) @@ -97,13 +97,13 @@ BOOST_AUTO_TEST_CASE(varints) DataStream::size_type size = 0; for (int i = 0; i < 100000; i++) { ss << VARINT_MODE(i, VarIntMode::NONNEGATIVE_SIGNED); - size += ::GetSerializeSize(VARINT_MODE(i, VarIntMode::NONNEGATIVE_SIGNED), 0); + size += ::GetSerializeSize(VARINT_MODE(i, VarIntMode::NONNEGATIVE_SIGNED)); BOOST_CHECK(size == ss.size()); } for (uint64_t i = 0; i < 100000000000ULL; i += 999999937) { ss << VARINT(i); - size += ::GetSerializeSize(VARINT(i), 0); + size += ::GetSerializeSize(VARINT(i)); BOOST_CHECK(size == ss.size()); } diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp index 9caefe43e2..933988dd7a 100644 --- a/src/test/uint256_tests.cpp +++ b/src/test/uint256_tests.cpp @@ -184,8 +184,8 @@ BOOST_AUTO_TEST_CASE( methods ) // GetHex SetHex begin() end() size() GetLow64 G BOOST_CHECK(OneL.begin() + 32 == OneL.end()); BOOST_CHECK(MaxL.begin() + 32 == MaxL.end()); BOOST_CHECK(TmpL.begin() + 32 == TmpL.end()); - BOOST_CHECK(GetSerializeSize(R1L, PROTOCOL_VERSION) == 32); - BOOST_CHECK(GetSerializeSize(ZeroL, PROTOCOL_VERSION) == 32); + BOOST_CHECK(GetSerializeSize(R1L) == 32); + BOOST_CHECK(GetSerializeSize(ZeroL) == 32); DataStream ss{}; ss << R1L; @@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE( methods ) // GetHex SetHex begin() end() size() GetLow64 G BOOST_CHECK(OneS.begin() + 20 == OneS.end()); BOOST_CHECK(MaxS.begin() + 20 == MaxS.end()); BOOST_CHECK(TmpS.begin() + 20 == TmpS.end()); - BOOST_CHECK(GetSerializeSize(R1S, PROTOCOL_VERSION) == 20); - BOOST_CHECK(GetSerializeSize(ZeroS, PROTOCOL_VERSION) == 20); + BOOST_CHECK(GetSerializeSize(R1S) == 20); + BOOST_CHECK(GetSerializeSize(ZeroS) == 20); ss << R1S; BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+20)); |