diff options
author | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-01-03 13:21:44 +0100 |
---|---|---|
committer | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-01-26 10:44:05 +0100 |
commit | fa29e73cdab82f98682821322cda89b1084ba887 (patch) | |
tree | fd765bb960156a69445818bdd6dfd6930cf733ae /src/test | |
parent | fa9becfe1cea5040e7cea36324d1b0789cbbd25d (diff) |
Use DataStream where possible
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/blockencodings_tests.cpp | 6 | ||||
-rw-r--r-- | src/test/blockfilter_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/bloom_tests.cpp | 8 | ||||
-rw-r--r-- | src/test/coins_tests.cpp | 12 | ||||
-rw-r--r-- | src/test/crypto_tests.cpp | 4 | ||||
-rw-r--r-- | src/test/fuzz/integer.cpp | 6 | ||||
-rw-r--r-- | src/test/fuzz/key.cpp | 2 | ||||
-rw-r--r-- | src/test/fuzz/prevector.cpp | 4 | ||||
-rw-r--r-- | src/test/fuzz/rpc.cpp | 2 | ||||
-rw-r--r-- | src/test/fuzz/string.cpp | 4 | ||||
-rw-r--r-- | src/test/fuzz/tx_in.cpp | 5 | ||||
-rw-r--r-- | src/test/fuzz/tx_out.cpp | 5 | ||||
-rw-r--r-- | src/test/key_tests.cpp | 4 | ||||
-rw-r--r-- | src/test/pmt_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/prevector_tests.cpp | 4 | ||||
-rw-r--r-- | src/test/serfloat_tests.cpp | 2 | ||||
-rw-r--r-- | src/test/serialize_tests.cpp | 10 | ||||
-rw-r--r-- | src/test/streams_tests.cpp | 14 | ||||
-rw-r--r-- | src/test/uint256_tests.cpp | 2 |
19 files changed, 46 insertions, 52 deletions
diff --git a/src/test/blockencodings_tests.cpp b/src/test/blockencodings_tests.cpp index e1dafc6bac..e23b7228e7 100644 --- a/src/test/blockencodings_tests.cpp +++ b/src/test/blockencodings_tests.cpp @@ -310,7 +310,7 @@ BOOST_AUTO_TEST_CASE(TransactionsRequestSerializationTest) { req1.indexes[2] = 3; req1.indexes[3] = 4; - CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); + DataStream stream{}; stream << req1; BlockTransactionsRequest req2; @@ -330,7 +330,7 @@ BOOST_AUTO_TEST_CASE(TransactionsRequestDeserializationMaxTest) { req0.blockhash = InsecureRand256(); req0.indexes.resize(1); req0.indexes[0] = 0xffff; - CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); + DataStream stream{}; stream << req0; BlockTransactionsRequest req1; @@ -350,7 +350,7 @@ BOOST_AUTO_TEST_CASE(TransactionsRequestDeserializationOverflowTest) { req0.indexes[0] = 0x7000; req0.indexes[1] = 0x10000 - 0x7000 - 2; req0.indexes[2] = 0; - CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); + DataStream stream{}; stream << req0.blockhash; WriteCompactSize(stream, req0.indexes.size()); WriteCompactSize(stream, req0.indexes[0]); diff --git a/src/test/blockfilter_tests.cpp b/src/test/blockfilter_tests.cpp index 43dca57217..9388b4c96a 100644 --- a/src/test/blockfilter_tests.cpp +++ b/src/test/blockfilter_tests.cpp @@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(blockfilter_basic_test) // Test serialization/unserialization. BlockFilter block_filter2; - CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); + DataStream stream{}; stream << block_filter; stream >> block_filter2; diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp index 3d6e103c9f..4888041204 100644 --- a/src/test/bloom_tests.cpp +++ b/src/test/bloom_tests.cpp @@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize) filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")); BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")), "Bloom filter doesn't contain just-inserted object (3)!"); - CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); + DataStream stream{}; stream << filter; std::vector<uint8_t> expected = ParseHex("03614e9b050000000000000001"); @@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak) filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")); BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")), "Bloom filter doesn't contain just-inserted object (3)!"); - CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); + DataStream stream{}; stream << filter; std::vector<uint8_t> expected = ParseHex("03ce4299050000000100008001"); @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_key) uint160 hash = pubkey.GetID(); filter.insert(hash); - CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); + DataStream stream{}; stream << filter; std::vector<unsigned char> expected = ParseHex("038fc16b080000000000000001"); @@ -340,7 +340,7 @@ BOOST_AUTO_TEST_CASE(merkle_block_3_and_serialize) for (unsigned int i = 0; i < vMatched.size(); i++) BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); - CDataStream merkleStream(SER_NETWORK, PROTOCOL_VERSION); + DataStream merkleStream{}; merkleStream << merkleBlock; std::vector<uint8_t> expected = ParseHex("0100000079cda856b143d9db2c1caff01d1aecc8630d30625d10e8b4b8b0000000000000b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f196367291b4d4c86041b8fa45d630100000001b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f19630101"); diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index b5f961a239..31d437081a 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -498,7 +498,7 @@ BOOST_AUTO_TEST_CASE(updatecoins_simulation_test) BOOST_AUTO_TEST_CASE(ccoins_serialization) { // Good example - CDataStream ss1(ParseHex("97f23c835800816115944e077fe7c803cfa57f29b36bf87c1d35"), SER_DISK, CLIENT_VERSION); + DataStream ss1{ParseHex("97f23c835800816115944e077fe7c803cfa57f29b36bf87c1d35")}; Coin cc1; ss1 >> cc1; BOOST_CHECK_EQUAL(cc1.fCoinBase, false); @@ -507,7 +507,7 @@ BOOST_AUTO_TEST_CASE(ccoins_serialization) BOOST_CHECK_EQUAL(HexStr(cc1.out.scriptPubKey), HexStr(GetScriptForDestination(PKHash(uint160(ParseHex("816115944e077fe7c803cfa57f29b36bf87c1d35")))))); // Good example - CDataStream ss2(ParseHex("8ddf77bbd123008c988f1a4a4de2161e0f50aac7f17e7f9555caa4"), SER_DISK, CLIENT_VERSION); + DataStream ss2{ParseHex("8ddf77bbd123008c988f1a4a4de2161e0f50aac7f17e7f9555caa4")}; Coin cc2; ss2 >> cc2; BOOST_CHECK_EQUAL(cc2.fCoinBase, true); @@ -516,7 +516,7 @@ BOOST_AUTO_TEST_CASE(ccoins_serialization) BOOST_CHECK_EQUAL(HexStr(cc2.out.scriptPubKey), HexStr(GetScriptForDestination(PKHash(uint160(ParseHex("8c988f1a4a4de2161e0f50aac7f17e7f9555caa4")))))); // Smallest possible example - CDataStream ss3(ParseHex("000006"), SER_DISK, CLIENT_VERSION); + DataStream ss3{ParseHex("000006")}; Coin cc3; ss3 >> cc3; BOOST_CHECK_EQUAL(cc3.fCoinBase, false); @@ -525,7 +525,7 @@ BOOST_AUTO_TEST_CASE(ccoins_serialization) BOOST_CHECK_EQUAL(cc3.out.scriptPubKey.size(), 0U); // scriptPubKey that ends beyond the end of the stream - CDataStream ss4(ParseHex("000007"), SER_DISK, CLIENT_VERSION); + DataStream ss4{ParseHex("000007")}; try { Coin cc4; ss4 >> cc4; @@ -534,11 +534,11 @@ BOOST_AUTO_TEST_CASE(ccoins_serialization) } // Very large scriptPubKey (3*10^9 bytes) past the end of the stream - CDataStream tmp(SER_DISK, CLIENT_VERSION); + DataStream tmp{}; uint64_t x = 3000000000ULL; tmp << VARINT(x); BOOST_CHECK_EQUAL(HexStr(tmp), "8a95c0bb00"); - CDataStream ss5(ParseHex("00008a95c0bb00"), SER_DISK, CLIENT_VERSION); + DataStream ss5{ParseHex("00008a95c0bb00")}; try { Coin cc5; ss5 >> cc5; diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp index 9b369a5c50..d3eef7beb7 100644 --- a/src/test/crypto_tests.cpp +++ b/src/test/crypto_tests.cpp @@ -925,7 +925,7 @@ BOOST_AUTO_TEST_CASE(muhash_tests) // Test MuHash3072 serialization MuHash3072 serchk = FromInt(1); serchk *= FromInt(2); std::string ser_exp = "1fa093295ea30a6a3acdc7b3f770fa538eff537528e990e2910e40bbcfd7f6696b1256901929094694b56316de342f593303dd12ac43e06dce1be1ff8301c845beb15468fff0ef002dbf80c29f26e6452bccc91b5cb9437ad410d2a67ea847887fa3c6a6553309946880fe20db2c73fe0641adbd4e86edfee0d9f8cd0ee1230898873dc13ed8ddcaf045c80faa082774279007a2253f8922ee3ef361d378a6af3ddaf180b190ac97e556888c36b3d1fb1c85aab9ccd46e3deaeb7b7cf5db067a7e9ff86b658cf3acd6662bbcce37232daa753c48b794356c020090c831a8304416e2aa7ad633c0ddb2f11be1be316a81be7f7e472071c042cb68faef549c221ebff209273638b741aba5a81675c45a5fa92fea4ca821d7a324cb1e1a2ccd3b76c4228ec8066dad2a5df6e1bd0de45c7dd5de8070bdb46db6c554cf9aefc9b7b2bbf9f75b1864d9f95005314593905c0109b71f703d49944ae94477b51dac10a816bb6d1c700bafabc8bd86fac8df24be519a2f2836b16392e18036cb13e48c5c010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - CDataStream ss_chk(SER_DISK, PROTOCOL_VERSION); + DataStream ss_chk{}; ss_chk << serchk; BOOST_CHECK_EQUAL(ser_exp, HexStr(ss_chk.str())); @@ -938,7 +938,7 @@ BOOST_AUTO_TEST_CASE(muhash_tests) BOOST_CHECK_EQUAL(HexStr(out), HexStr(out3)); // Test MuHash3072 overflow, meaning the internal data is larger than the modulus. - CDataStream ss_max(ParseHex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"), SER_DISK, PROTOCOL_VERSION); + DataStream ss_max{ParseHex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")}; MuHash3072 overflowchk; ss_max >> overflowchk; diff --git a/src/test/fuzz/integer.cpp b/src/test/fuzz/integer.cpp index 7965f90dc7..c0aefe6067 100644 --- a/src/test/fuzz/integer.cpp +++ b/src/test/fuzz/integer.cpp @@ -152,7 +152,7 @@ FUZZ_TARGET_INIT(integer, initialize_integer) const CScriptID script_id{u160}; { - CDataStream stream(SER_NETWORK, INIT_PROTO_VERSION); + DataStream stream{}; uint256 deserialized_u256; stream << u256; @@ -217,7 +217,7 @@ FUZZ_TARGET_INIT(integer, initialize_integer) } { - CDataStream stream(SER_NETWORK, INIT_PROTO_VERSION); + DataStream stream{}; ser_writedata64(stream, u64); const uint64_t deserialized_u64 = ser_readdata64(stream); @@ -245,7 +245,7 @@ FUZZ_TARGET_INIT(integer, initialize_integer) } { - CDataStream stream(SER_NETWORK, INIT_PROTO_VERSION); + DataStream stream{}; WriteCompactSize(stream, u64); try { diff --git a/src/test/fuzz/key.cpp b/src/test/fuzz/key.cpp index e83606f032..ea6883c08d 100644 --- a/src/test/fuzz/key.cpp +++ b/src/test/fuzz/key.cpp @@ -111,7 +111,7 @@ FUZZ_TARGET_INIT(key, initialize_key) } { - CDataStream data_stream{SER_NETWORK, INIT_PROTO_VERSION}; + DataStream data_stream{}; pubkey.Serialize(data_stream); CPubKey pubkey_deserialized; diff --git a/src/test/fuzz/prevector.cpp b/src/test/fuzz/prevector.cpp index c8fd9aca30..9cea32e304 100644 --- a/src/test/fuzz/prevector.cpp +++ b/src/test/fuzz/prevector.cpp @@ -59,8 +59,8 @@ public: --pos; assert(v == real_vector[pos]); } - CDataStream ss1(SER_DISK, 0); - CDataStream ss2(SER_DISK, 0); + DataStream ss1{}; + DataStream ss2{}; ss1 << real_vector; ss2 << pre_vector; assert(ss1.size() == ss2.size()); diff --git a/src/test/fuzz/rpc.cpp b/src/test/fuzz/rpc.cpp index 361cfa6cb6..2578137471 100644 --- a/src/test/fuzz/rpc.cpp +++ b/src/test/fuzz/rpc.cpp @@ -253,7 +253,7 @@ std::string ConsumeScalarRPCArgument(FuzzedDataProvider& fuzzed_data_provider) if (!opt_block_header) { return; } - CDataStream data_stream{SER_NETWORK, PROTOCOL_VERSION}; + DataStream data_stream{}; data_stream << *opt_block_header; r = HexStr(data_stream); }, diff --git a/src/test/fuzz/string.cpp b/src/test/fuzz/string.cpp index 3c427b9bef..9890e4c0e5 100644 --- a/src/test/fuzz/string.cpp +++ b/src/test/fuzz/string.cpp @@ -196,7 +196,7 @@ FUZZ_TARGET(string) } { - CDataStream data_stream{SER_NETWORK, INIT_PROTO_VERSION}; + DataStream data_stream{}; std::string s; auto limited_string = LIMITED_STRING(s, 10); data_stream << random_string_1; @@ -212,7 +212,7 @@ FUZZ_TARGET(string) } } { - CDataStream data_stream{SER_NETWORK, INIT_PROTO_VERSION}; + DataStream data_stream{}; const auto limited_string = LIMITED_STRING(random_string_1, 10); data_stream << limited_string; std::string deserialized_string; diff --git a/src/test/fuzz/tx_in.cpp b/src/test/fuzz/tx_in.cpp index f8247c1fa4..fc16f80cde 100644 --- a/src/test/fuzz/tx_in.cpp +++ b/src/test/fuzz/tx_in.cpp @@ -14,12 +14,9 @@ FUZZ_TARGET(tx_in) { - CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION); + DataStream ds{buffer}; CTxIn tx_in; try { - int version; - ds >> version; - ds.SetVersion(version); ds >> tx_in; } catch (const std::ios_base::failure&) { return; diff --git a/src/test/fuzz/tx_out.cpp b/src/test/fuzz/tx_out.cpp index 337b8e2771..806216fbf5 100644 --- a/src/test/fuzz/tx_out.cpp +++ b/src/test/fuzz/tx_out.cpp @@ -13,12 +13,9 @@ FUZZ_TARGET(tx_out) { - CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION); + DataStream ds{buffer}; CTxOut tx_out; try { - int version; - ds >> version; - ds.SetVersion(version); ds >> tx_out; } catch (const std::ios_base::failure&) { return; diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index 21ed2f1080..d14fda7351 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -233,7 +233,7 @@ BOOST_AUTO_TEST_CASE(key_key_negation) static CPubKey UnserializePubkey(const std::vector<uint8_t>& data) { - CDataStream stream{SER_NETWORK, INIT_PROTO_VERSION}; + DataStream stream{}; stream << data; CPubKey pubkey; stream >> pubkey; @@ -251,7 +251,7 @@ static unsigned int GetLen(unsigned char chHeader) static void CmpSerializationPubkey(const CPubKey& pubkey) { - CDataStream stream{SER_NETWORK, INIT_PROTO_VERSION}; + DataStream stream{}; stream << pubkey; CPubKey pubkey2; stream >> pubkey2; diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp index d6aee472a8..21e0dd2fc5 100644 --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(pmt_test1) CPartialMerkleTree pmt1(vTxid, vMatch); // serialize - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + DataStream ss{}; ss << pmt1; // verify CPartialMerkleTree's size guarantees diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index 4068775cfa..5f4d307048 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -66,8 +66,8 @@ class prevector_tester { for (const T& v : reverse_iterate(const_pre_vector)) { local_check(v == real_vector[--pos]); } - CDataStream ss1(SER_DISK, 0); - CDataStream ss2(SER_DISK, 0); + DataStream ss1{}; + DataStream ss2{}; ss1 << real_vector; ss2 << pre_vector; local_check_equal(ss1.size(), ss2.size()); diff --git a/src/test/serfloat_tests.cpp b/src/test/serfloat_tests.cpp index ed1f081913..f6af32cf6c 100644 --- a/src/test/serfloat_tests.cpp +++ b/src/test/serfloat_tests.cpp @@ -111,7 +111,7 @@ Python code to generate the below hashes: */ BOOST_AUTO_TEST_CASE(doubles) { - CDataStream ss(SER_DISK, 0); + DataStream ss{}; // encode for (int i = 0; i < 1000; i++) { ss << EncodeDouble(i); diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index c90ae38ae8..f583109e16 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -90,8 +90,8 @@ BOOST_AUTO_TEST_CASE(varints) { // encode - CDataStream ss(SER_DISK, 0); - CDataStream::size_type size = 0; + DataStream ss{}; + 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); @@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(varints) BOOST_AUTO_TEST_CASE(varints_bitpatterns) { - CDataStream ss(SER_DISK, 0); + DataStream ss{}; ss << VARINT_MODE(0, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "00"); ss.clear(); ss << VARINT_MODE(0x7f, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "7f"); ss.clear(); ss << VARINT_MODE(int8_t{0x7f}, VarIntMode::NONNEGATIVE_SIGNED); BOOST_CHECK_EQUAL(HexStr(ss), "7f"); ss.clear(); @@ -141,7 +141,7 @@ BOOST_AUTO_TEST_CASE(varints_bitpatterns) BOOST_AUTO_TEST_CASE(compactsize) { - CDataStream ss(SER_DISK, 0); + DataStream ss{}; std::vector<char>::size_type i, j; for (i = 1; i <= MAX_SIZE; i *= 2) @@ -182,7 +182,7 @@ BOOST_AUTO_TEST_CASE(noncanonical) { // Write some non-canonical CompactSize encodings, and // make sure an exception is thrown when read back. - CDataStream ss(SER_DISK, 0); + DataStream ss{}; std::vector<char>::size_type n; // zero encoded with three bytes: diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp index 03117f76ae..b7c1ce5066 100644 --- a/src/test/streams_tests.cpp +++ b/src/test/streams_tests.cpp @@ -128,9 +128,9 @@ BOOST_AUTO_TEST_CASE(streams_vector_reader_rvalue) BOOST_AUTO_TEST_CASE(bitstream_reader_writer) { - CDataStream data(SER_NETWORK, INIT_PROTO_VERSION); + DataStream data{}; - BitStreamWriter<CDataStream> bit_writer(data); + BitStreamWriter bit_writer{data}; bit_writer.Write(0, 1); bit_writer.Write(2, 2); bit_writer.Write(6, 3); @@ -141,7 +141,7 @@ BOOST_AUTO_TEST_CASE(bitstream_reader_writer) bit_writer.Write(30497, 16); bit_writer.Flush(); - CDataStream data_copy(data); + DataStream data_copy{data}; uint32_t serialized_int1; data >> serialized_int1; BOOST_CHECK_EQUAL(serialized_int1, uint32_t{0x7700C35A}); // NOTE: Serialized as LE @@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(bitstream_reader_writer) data >> serialized_int2; BOOST_CHECK_EQUAL(serialized_int2, uint16_t{0x1072}); // NOTE: Serialized as LE - BitStreamReader<CDataStream> bit_reader(data_copy); + BitStreamReader bit_reader{data_copy}; BOOST_CHECK_EQUAL(bit_reader.Read(1), 0U); BOOST_CHECK_EQUAL(bit_reader.Read(2), 2U); BOOST_CHECK_EQUAL(bit_reader.Read(3), 6U); @@ -167,7 +167,7 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) // Degenerate case { - CDataStream ds{in, 0, 0}; + DataStream ds{in}; ds.Xor({0x00, 0x00}); BOOST_CHECK_EQUAL(""s, ds.str()); } @@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) // Single character key { - CDataStream ds{in, 0, 0}; + DataStream ds{in}; ds.Xor({0xff}); BOOST_CHECK_EQUAL("\xf0\x0f"s, ds.str()); } @@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) in.push_back(std::byte{0x0f}); { - CDataStream ds{in, 0, 0}; + DataStream ds{in}; ds.Xor({0xff, 0x0f}); BOOST_CHECK_EQUAL("\x0f\x00"s, ds.str()); } diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp index bc206fc945..9caefe43e2 100644 --- a/src/test/uint256_tests.cpp +++ b/src/test/uint256_tests.cpp @@ -187,7 +187,7 @@ BOOST_AUTO_TEST_CASE( methods ) // GetHex SetHex begin() end() size() GetLow64 G BOOST_CHECK(GetSerializeSize(R1L, PROTOCOL_VERSION) == 32); BOOST_CHECK(GetSerializeSize(ZeroL, PROTOCOL_VERSION) == 32); - CDataStream ss(0, PROTOCOL_VERSION); + DataStream ss{}; ss << R1L; BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+32)); ss >> TmpL; |