Skip to content

Commit 2b1f85e

Browse files
committed
Convert blockencodings_tests to new serialization
1 parent 73747af commit 2b1f85e

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

src/blockencodings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,13 @@ class CBlockHeaderAndShortTxIDs {
9292

9393
friend class PartiallyDownloadedBlock;
9494

95-
static const int SHORTTXIDS_LENGTH = 6;
9695
protected:
9796
std::vector<uint64_t> shorttxids;
9897
std::vector<PrefilledTransaction> prefilledtxn;
9998

10099
public:
100+
static constexpr int SHORTTXIDS_LENGTH = 6;
101+
101102
CBlockHeader header;
102103

103104
// Dummy for deserialization

src/test/blockencodings_tests.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,24 +132,7 @@ class TestHeaderAndShortIDs {
132132
return base.GetShortID(txhash);
133133
}
134134

135-
ADD_SERIALIZE_METHODS;
136-
137-
template <typename Stream, typename Operation>
138-
inline void SerializationOp(Stream& s, Operation ser_action) {
139-
READWRITE(header);
140-
READWRITE(nonce);
141-
size_t shorttxids_size = shorttxids.size();
142-
READWRITE(VARINT(shorttxids_size));
143-
shorttxids.resize(shorttxids_size);
144-
for (size_t i = 0; i < shorttxids.size(); i++) {
145-
uint32_t lsb = shorttxids[i] & 0xffffffff;
146-
uint16_t msb = (shorttxids[i] >> 32) & 0xffff;
147-
READWRITE(lsb);
148-
READWRITE(msb);
149-
shorttxids[i] = (uint64_t(msb) << 32) | uint64_t(lsb);
150-
}
151-
READWRITE(prefilledtxn);
152-
}
135+
SERIALIZE_METHODS(TestHeaderAndShortIDs, obj) { READWRITE(obj.header, obj.nonce, Using<VectorFormatter<CustomUintFormatter<CBlockHeaderAndShortTxIDs::SHORTTXIDS_LENGTH>>>(obj.shorttxids), obj.prefilledtxn); }
153136
};
154137

155138
BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)

0 commit comments

Comments
 (0)