Skip to content

Commit

Permalink
Convert blockencodings_tests to new serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa committed Mar 30, 2020
1 parent 73747af commit 2b1f85e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/blockencodings.h
Expand Up @@ -92,12 +92,13 @@ class CBlockHeaderAndShortTxIDs {

friend class PartiallyDownloadedBlock;

static const int SHORTTXIDS_LENGTH = 6;
protected:
std::vector<uint64_t> shorttxids;
std::vector<PrefilledTransaction> prefilledtxn;

public:
static constexpr int SHORTTXIDS_LENGTH = 6;

CBlockHeader header;

// Dummy for deserialization
Expand Down
19 changes: 1 addition & 18 deletions src/test/blockencodings_tests.cpp
Expand Up @@ -132,24 +132,7 @@ class TestHeaderAndShortIDs {
return base.GetShortID(txhash);
}

ADD_SERIALIZE_METHODS;

template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action) {
READWRITE(header);
READWRITE(nonce);
size_t shorttxids_size = shorttxids.size();
READWRITE(VARINT(shorttxids_size));
shorttxids.resize(shorttxids_size);
for (size_t i = 0; i < shorttxids.size(); i++) {
uint32_t lsb = shorttxids[i] & 0xffffffff;
uint16_t msb = (shorttxids[i] >> 32) & 0xffff;
READWRITE(lsb);
READWRITE(msb);
shorttxids[i] = (uint64_t(msb) << 32) | uint64_t(lsb);
}
READWRITE(prefilledtxn);
}
SERIALIZE_METHODS(TestHeaderAndShortIDs, obj) { READWRITE(obj.header, obj.nonce, Using<VectorFormatter<CustomUintFormatter<CBlockHeaderAndShortTxIDs::SHORTTXIDS_LENGTH>>>(obj.shorttxids), obj.prefilledtxn); }
};

BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
Expand Down

0 comments on commit 2b1f85e

Please sign in to comment.