Skip to content

Add unit tests for Configuration.Validate, types and WAL view loading - #722

Merged
pfi79 merged 1 commit into
hyperledger:mainfrom
HagarMeir:test/config-validate-and-state-load
Oct 22, 2026
Merged

pfi79 merged 1 commit into
hyperledger:mainfrom
HagarMeir:test/config-validate-and-state-load

Conversation

@HagarMeir

Copy link
Copy Markdown
Contributor

Written by Claude (Anthropic's AI assistant) on behalf of Hagar Meir.

pkg/types had no tests, and PersistedState.LoadNewViewIfApplicable and LoadViewChangeIfApplicable had no unit tests.

Changes (test only)

  • pkg/types/config_test.go: a table test for every check in Configuration.Validate. Each case starts from DefaultConfig and breaks one field, including the cross-field rules: forward ≤ complain ≤ auto-remove timeouts, the batch size limits, and leader rotation vs DecisionsPerLeader.
  • pkg/types/types_test.go: tests for Proposal.Digest (stable, and changes with each field), Checkpoint Get/Set, and RequestInfo.String.
  • internal/bft/state_test.go: TestStateLoadIfApplicable covers an empty WAL, a malformed last entry, and a last entry that is a proposal, a new view or a view change.

Coverage

  • pkg/types: 0% → 98.6% (Validate at 100%).
  • LoadNewViewIfApplicable / LoadViewChangeIfApplicable: 0% → 100%.

Testing

  • golangci-lint run ./...: 0 issues.
  • go vet, gofmt, go test -race ./internal/bft/ ./pkg/types/ pass.
  • The full test integration package passes.

🤖 Generated with Claude Code

pkg/types had no tests. Cover every check in Configuration.Validate with
a table test that starts from DefaultConfig and breaks one field at a
time, and cover Proposal.Digest, Checkpoint and RequestInfo.String.

Also cover PersistedState.LoadNewViewIfApplicable and
LoadViewChangeIfApplicable, which had no unit tests: an empty WAL, a
malformed last entry, and a last entry that is a proposal, a new view
or a view change.

Test-only change. Written by Claude (AI assistant) on behalf of Hagar Meir.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Hagar Meir <hagar.meir@ibm.com>
@pfi79
pfi79 force-pushed the test/config-validate-and-state-load branch from 34cece7 to 139427d Compare October 22, 2026 08:56
@pfi79
pfi79 merged commit 0771a63 into hyperledger:main Oct 22, 2026
6 checks passed
@HagarMeir
HagarMeir deleted the test/config-validate-and-state-load branch October 22, 2026 09:20
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.

2 participants