Skip to content

Commit d2e3b42

Browse files
committed
test: use constant for SV2_NEW_TEMPLATE_MESSAGE_SIZE
1 parent e255fb1 commit d2e3b42

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/test/sv2_template_provider_tests.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
BOOST_FIXTURE_TEST_SUITE(sv2_template_provider_tests, TestChain100Setup)
2020

21+
static constexpr size_t SV2_NEW_TEMPLATE_MESSAGE_SIZE{91};
22+
2123
/**
2224
* A class for testing the Template Provider. Each TPTester encapsulates a
2325
* Sv2TemplateProvider (the one being tested) as well as a Sv2Cipher
@@ -167,7 +169,7 @@ BOOST_AUTO_TEST_CASE(client_tests)
167169
node::Sv2NetMsg msg{node::Sv2MsgType::COINBASE_OUTPUT_CONSTRAINTS, std::move(coinbase_output_constraint_bytes)};
168170
tester.receiveMessage(msg);
169171
BOOST_TEST_MESSAGE("The reply should be NewTemplate and SetNewPrevHash");
170-
BOOST_REQUIRE_EQUAL(tester.PeerReceiveBytes(), 2 * SV2_HEADER_ENCRYPTED_SIZE + 91 + 80 + 2 * Poly1305::TAGLEN);
172+
BOOST_REQUIRE_EQUAL(tester.PeerReceiveBytes(), 2 * SV2_HEADER_ENCRYPTED_SIZE + SV2_NEW_TEMPLATE_MESSAGE_SIZE + 80 + 2 * Poly1305::TAGLEN);
171173

172174
// There should now be one template
173175
BOOST_REQUIRE_EQUAL(tester.GetBlockTemplateCount(), 1);
@@ -208,7 +210,7 @@ BOOST_AUTO_TEST_CASE(client_tests)
208210

209211
// Expect our peer to receive a NewTemplate message
210212
// This time it should contain the 32 byte prevhash (unchanged)
211-
constexpr size_t expected_len = SV2_HEADER_ENCRYPTED_SIZE + 91 + 32 + Poly1305::TAGLEN;
213+
constexpr size_t expected_len = SV2_HEADER_ENCRYPTED_SIZE + SV2_NEW_TEMPLATE_MESSAGE_SIZE + 32 + Poly1305::TAGLEN;
212214
BOOST_TEST_MESSAGE("Receive NewTemplate");
213215
BOOST_REQUIRE_EQUAL(tester.PeerReceiveBytes(), expected_len);
214216

@@ -265,7 +267,7 @@ BOOST_AUTO_TEST_CASE(client_tests)
265267
UninterruptibleSleep(std::chrono::milliseconds{1000});
266268

267269
// Expect our peer to receive a NewTemplate message
268-
BOOST_REQUIRE_EQUAL(tester.PeerReceiveBytes(), SV2_HEADER_ENCRYPTED_SIZE + 91 + 32 + Poly1305::TAGLEN);
270+
BOOST_REQUIRE_EQUAL(tester.PeerReceiveBytes(), SV2_HEADER_ENCRYPTED_SIZE + SV2_NEW_TEMPLATE_MESSAGE_SIZE + 32 + Poly1305::TAGLEN);
269271

270272
// Check that there's a new template
271273
BOOST_REQUIRE_EQUAL(tester.GetBlockTemplateCount(), 3);
@@ -284,7 +286,7 @@ BOOST_AUTO_TEST_CASE(client_tests)
284286

285287
// We should send out another NewTemplate and SetNewPrevHash
286288
// The new template contains the new prevhash.
287-
BOOST_REQUIRE_EQUAL(tester.PeerReceiveBytes(), 2 * SV2_HEADER_ENCRYPTED_SIZE + 91 + 32 + 80 + 2 * Poly1305::TAGLEN);
289+
BOOST_REQUIRE_EQUAL(tester.PeerReceiveBytes(), 2 * SV2_HEADER_ENCRYPTED_SIZE + SV2_NEW_TEMPLATE_MESSAGE_SIZE + 32 + 80 + 2 * Poly1305::TAGLEN);
288290
// The SetNewPrevHash message is redundant
289291
// TODO: don't send it?
290292
// Background: in the future we want to send an empty or optimistic template

0 commit comments

Comments
 (0)