test: add fee timer blocking test coverage#70
Conversation
| TPTester tester{opts}; | ||
|
|
||
| tester.handshake(); | ||
| tester.handshake(); |
There was a problem hiding this comment.
I don't know why the original has two handshake calls, that might be a bug.
It would be good to reduce the amount of duplicated test code, that also makes it more clear how each test case is different.
There was a problem hiding this comment.
let me do a clean up and have a much clearer approach
There was a problem hiding this comment.
d54d4b7 is better, but the code between coinbase_output_constraint_bytes and BOOST_REQUIRE_EQUAL(initial_bytes, expected_pair_bytes) is still duplicated. Can you extract that into one or more helpers?
There was a problem hiding this comment.
yes, I have addressed it in ef1a258 . Thank you.
fffb55b to
d54d4b7
Compare
Does that mean the TODO can go away? |
yes |
d54d4b7 to
ef1a258
Compare
| } | ||
|
|
||
| BOOST_REQUIRE_MESSAGE(seen_prev_hash, std::string("Missing SetNewPrevHash during ") + context); | ||
| BOOST_REQUIRE_MESSAGE(seen_new_template, std::string("Missing NewTemplate during ") + context); |
There was a problem hiding this comment.
Looks like you've lost part of this entire test now?
There was a problem hiding this comment.
I've restored the lost bit
There was a problem hiding this comment.
that's a good catch, let me reset and redo. Thank you
|
It's (slightly) easier to review the deduplication commit if you do it first. |
ef1a258 to
cfe50cd
Compare
| // -sv2interval=N requires that we don't send fee updates until at least | ||
| // N seconds have gone by. So we first call waitNext() without a fee | ||
| // threshold, and then on the next while iteration we set it. | ||
| // TODO: add test coverage |
There was a problem hiding this comment.
05585cd: nit, this in the wrong commit now (don't worry about it)
There was a problem hiding this comment.
let me do a better cleanup, thank you.
cfe50cd to
1d3013e
Compare
|
The first commit still seems to be doing a lot more than "deduplicate". It's difficult to review that way. Try having commit per change (or make fewer changes, if possible). |
1d3013e to
aa53b10
Compare
Thanks for pointing that out, I've broken them down to 4 commits to make it easier to review. |
| tester.handshake(); | ||
|
|
||
| // After the handshake the client must send a SetupConnection message to the | ||
| // Template Provider. |
| tester.m_mining_control->Shutdown(); | ||
| } | ||
|
|
||
| // Test fee-based rate limiting timer (-sv2interval flag). |
The client_tests test case called tester.handshake() twice in succession. The second call overwrites all state from the first, making the first a no-op. Remove it.
Extract SendSetupConnection(), SendCoinbaseOutputConstraints() and ReceiveTemplatePair() into TPTester so the setup sequence is not repeated inline. Move the SV2 message size constants into the TPTester header for reuse.
Add a TPTester constructor overload that accepts custom options, allowing tests to set is_test=false and a short fee_check_interval. The new fee_timer_blocking_test verifies that fee-based template updates are blocked until the -sv2interval timer fires. Closes stratum-mining#67
A new block should always produce a template immediately, even when the -sv2interval fee timer has not yet elapsed. This completes the three test scenarios requested in stratum-mining#67.
aa53b10 to
5225964
Compare
Add test coverage for the fee-based rate limiting timer that was marked with a TODO in template_provider.cpp. The timer blocks fee-based template updates until fee_check_interval seconds have passed (-sv2interval flag).
The test uses is_test=false to exercise the actual timer logic that is normally bypassed in tests. It verifies:
Also adds a TPTester constructor overload to accept custom options, allowing tests to configure is_test and fee_check_interval independently.
Closes #67