Skip to content

test: cover Election.clear pending consensus reset - #407

Merged
rotilho merged 1 commit into
attocash:mainfrom
pactrover:test/election-clear-pending-consensus
Sep 27, 2026
Merged

rotilho merged 1 commit into
attocash:mainfrom
pactrover:test/election-clear-pending-consensus

Conversation

@pactrover

@pactrover pactrover commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add one regression test for Election.clear() resetting pending consensus state
  • verify that a second transaction at the same public-key height can start after clear()
  • keep the contribution test-only; production code is unchanged

Closes #406

Verification

Passed locally with Temurin OpenJDK 25.0.4.1 and Gradle 9.7.1:

  • ./gradlew test --tests 'cash.atto.node.election.ElectionTest.should clear pending consensus state' --rerun-tasks --offline --no-daemon --console=plain --stacktrace --no-scan — 1 test, 0 failures
  • ./gradlew test --tests 'cash.atto.node.election.ElectionTest' --rerun-tasks --offline --no-daemon --console=plain --stacktrace --no-scan — 13 tests, 0 failures

A full ./gradlew test --rerun-tasks --offline --no-daemon --console=plain --stacktrace --no-scan --fail-fast run was also attempted. It stopped in the first Cucumber bootstrap suite because Testcontainers could not find a Docker environment (/var/run/docker.sock was unavailable): 3 bootstrap feature failures and 1 skipped test. The remaining full suite was therefore not executed locally.

The focused test had previously been sensitivity-checked against a controlled copy differing only by removal of pendingConsensus.clear(); that focused run failed because transaction B did not publish ElectionStarted. This is regression-test sensitivity evidence, not a production-defect or correctness claim.

Scope

  • one file changed
  • 24 test lines added
  • no production code, configuration, dependencies, secrets, or repository settings changed
  • no live-node behavior was tested

atto://abn2pmx6dc2e43vi5zaatuhor4j6qioztqcdr2vgxivxtcw3vbgwsrztx5rtc

@pactrover
pactrover requested a review from a team as a code owner September 27, 2026 12:03
@rotilho

rotilho commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

This is pretty interesting, and I'm honestly impressed that you identified this gap and opened the issue/PR yourself. I'm happy to merge it.

That said, this isn't exactly how I usually approach testing. clear() is exercised in a very specific path, during shutdown, so a potential regression here would have fairly limited impact. This path is also already exercised by the integration tests, so it's not really 100% untested. A regression could break those tests, although a focused test like this would definitely make finding the cause easier, especially after several commits.

So I do see the value in this test and I'm happy to have it. Just keep in mind that I don't generally aim for exhaustive unit coverage. I prefer adding focused tests when the risk or likelihood of regression justifies them.

@rotilho rotilho added the contribution-tweak Quick optimizations or UI updates label Sep 27, 2026
@atto-reward-bot

Copy link
Copy Markdown

Thank you for your contribution! 🎉 This PR is eligible for an contribution-tweak reward as a token of our appreciation. If you'd like to receive it, please add your address to the description of this PR. 🙏

@atto-reward-bot

Copy link
Copy Markdown

Thank you for your contribution! 🎉 This PR is eligible for an contribution-tweak reward as a token of our appreciation and will be sent to atto://abn2pmx6dc2e43vi5zaatuhor4j6qioztqcdr2vgxivxtcw3vbgwsrztx5rtc once merged. Please note that rewards are not payments but our way of saying thank you. 🙏

@atto-reward-bot atto-reward-bot Bot added the reward-informed Contributor has been informed about their reward. label Sep 27, 2026
@rotilho
rotilho merged commit d879c33 into attocash:main Sep 27, 2026
1 check passed
@atto-reward-bot atto-reward-bot Bot added reward-started Reward processing has started. reward-sent Reward has been sent to the contributor. labels Sep 27, 2026
@atto-reward-bot

Copy link
Copy Markdown

The contribution-tweak reward was sent to atto://abn2pmx6dc2e43vi5zaatuhor4j6qioztqcdr2vgxivxtcw3vbgwsrztx5rtc in the block A321E31C10300A6FCF937E15C49274BC8867216D558B570C0F2835C20B381E80. Thank you again for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution-tweak Quick optimizations or UI updates reward-informed Contributor has been informed about their reward. reward-sent Reward has been sent to the contributor. reward-started Reward processing has started.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test coverage: Election.clear() resets pending consensus state

2 participants