Skip to content

test: add fee timer blocking test coverage#70

Merged
Sjors merged 4 commits intostratum-mining:masterfrom
xyephy:2025/11/fee-timer-test
Apr 20, 2026
Merged

test: add fee timer blocking test coverage#70
Sjors merged 4 commits intostratum-mining:masterfrom
xyephy:2025/11/fee-timer-test

Conversation

@xyephy
Copy link
Copy Markdown
Contributor

@xyephy xyephy commented Nov 27, 2025

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:

  • Fee increases are blocked when the timer hasn't fired
  • Fee increases are allowed after the timer fires

Also adds a TPTester constructor overload to accept custom options, allowing tests to configure is_test and fee_check_interval independently.

Closes #67

@xyephy xyephy marked this pull request as draft November 27, 2025 18:16
TPTester tester{opts};

tester.handshake();
tester.handshake();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me do a clean up and have a much clearer approach

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I have addressed it in ef1a258 . Thank you.

@xyephy xyephy force-pushed the 2025/11/fee-timer-test branch from fffb55b to d54d4b7 Compare November 28, 2025 20:22
@xyephy xyephy marked this pull request as ready for review December 9, 2025 08:11
@Sjors
Copy link
Copy Markdown
Collaborator

Sjors commented Feb 10, 2026

marked with a TODO in template_provider.cpp

Does that mean the TODO can go away?

@xyephy
Copy link
Copy Markdown
Contributor Author

xyephy commented Feb 11, 2026

marked with a TODO in template_provider.cpp

Does that mean the TODO can go away?

yes

@xyephy xyephy force-pushed the 2025/11/fee-timer-test branch from d54d4b7 to ef1a258 Compare February 11, 2026 20:56
}

BOOST_REQUIRE_MESSAGE(seen_prev_hash, std::string("Missing SetNewPrevHash during ") + context);
BOOST_REQUIRE_MESSAGE(seen_new_template, std::string("Missing NewTemplate during ") + context);
Copy link
Copy Markdown
Collaborator

@Sjors Sjors Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you've lost part of this entire test now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've restored the lost bit

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They still seem missing as of 05585cd.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good catch, let me reset and redo. Thank you

@Sjors
Copy link
Copy Markdown
Collaborator

Sjors commented Feb 16, 2026

It's (slightly) easier to review the deduplication commit if you do it first.

@xyephy xyephy force-pushed the 2025/11/fee-timer-test branch from ef1a258 to cfe50cd Compare February 17, 2026 09:17
Comment thread src/sv2/template_provider.cpp Outdated
// -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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

05585cd: nit, this in the wrong commit now (don't worry about it)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me do a better cleanup, thank you.

@xyephy xyephy force-pushed the 2025/11/fee-timer-test branch from cfe50cd to 1d3013e Compare March 31, 2026 14:41
@Sjors
Copy link
Copy Markdown
Collaborator

Sjors commented Apr 15, 2026

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).

@xyephy xyephy force-pushed the 2025/11/fee-timer-test branch from 1d3013e to aa53b10 Compare April 15, 2026 19:21
@xyephy
Copy link
Copy Markdown
Contributor Author

xyephy commented Apr 15, 2026

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).

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.
Copy link
Copy Markdown
Collaborator

@Sjors Sjors Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bd127df: I think this comment was fine?

tester.m_mining_control->Shutdown();
}

// Test fee-based rate limiting timer (-sv2interval flag).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d1a5e03 nit: I merged #90, so this needs a rename

@Sjors
Copy link
Copy Markdown
Collaborator

Sjors commented Apr 17, 2026

Code review ACK aa53b10

But needs a trivial rebase after #90.

xyephy added 4 commits April 17, 2026 19:48
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.
@xyephy xyephy force-pushed the 2025/11/fee-timer-test branch from aa53b10 to 5225964 Compare April 17, 2026 16:53
@xyephy
Copy link
Copy Markdown
Contributor Author

xyephy commented Apr 17, 2026

Code review ACK aa53b10

But needs a trivial rebase after #90.

I've rebased.

@Sjors Sjors merged commit 5225964 into stratum-mining:master Apr 20, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test coverage for fee-based rate limiting timer

2 participants