Skip to content

test(corona): argument-validation tests for Bootstrap/Reshare/Reanchor + alias surface#22

Open
abhicris wants to merge 1 commit into
luxfi:mainfrom
abhicris:test/2026-06-01-corona-validation-tests
Open

test(corona): argument-validation tests for Bootstrap/Reshare/Reanchor + alias surface#22
abhicris wants to merge 1 commit into
luxfi:mainfrom
abhicris:test/2026-06-01-corona-validation-tests

Conversation

@abhicris
Copy link
Copy Markdown
Contributor

@abhicris abhicris commented Jun 1, 2026

protocols/corona/ shipped without a dedicated _test.go file. The alias surface (Bootstrap, Reshare, Reanchor, ShareForParty, GenerateKeys, NewParams, validatorIDs) does real argument validation before delegating to the luxfi/corona kernel, but none of those guards were pinned by tests. Corona is the R-LWE primitive in the Polaris triple-PQ profile (BLS ‖ Pulsar ‖ Corona ‖ Magnetar) — the alias surface here is what luxfi/consensus imports, so its validation contracts are part of the chain-facing API.

What this PR adds

protocols/corona/corona_test.go — 17 tests, all PASS in 0.018s.

Bootstrap (4)

  • empty validators → ErrEmptyValidators
  • t=0 → ErrInvalidThreshold
  • t > n → ErrInvalidThreshold
  • nil entropy does not panic (falls back to crypto/rand.Reader)

Reshare (3)

  • nil KeyEra → error mentioning "nil key era"
  • nil-era + nil validators (guard-order check)
  • nil-era + threshold > n=1

Reanchor (3)

  • empty validators → ErrEmptyValidators
  • t=0 → ErrInvalidThreshold
  • t > n → ErrInvalidThreshold

ShareForParty (3)

  • nil state → error mentioning nil-share-state
  • party not in set → ErrPartyNotInSet (error mentions the missing id)
  • happy path returns the exact same *KeyShare pointer

Alias surface (2)

  • NewParams returns non-nil *Params with no error
  • GenerateKeys (2-of-3 trusted-dealer) returns 3 non-nil shares + non-nil *GroupKey from a deterministic seed

validatorIDs unexported helper (2)

  • preserves order and length for non-empty input
  • returns non-nil empty slice for nil input

Verification

$ go test ./protocols/corona/ -count=1 -v -timeout 120s
PASS — 17/17 in 0.018s

No changes to non-test files. No regression in the existing suite (there was no corona test coverage to regress).

Notes

  • Tests live in package corona (not corona_test) so the unexported validatorIDs helper can be reached. The two failing-case tests for Reshare use nil KeyEra instead of constructing a synthetic one — building a real *KeyEra for failure paths is out of scope; the nil-era guard covers the validation surface for those branches.
  • The Bootstrap_NilEntropyDefaultsToCryptoRand test logs (not fails) when the kernel returns an unrelated error in the constrained CI env — the contract being pinned is no panic on nil entropy.

…r + alias surface

protocols/corona/ shipped without a dedicated _test.go file. The
alias surface (Bootstrap, Reshare, Reanchor, ShareForParty,
GenerateKeys, NewParams, validatorIDs) does real argument validation
before delegating to luxfi/corona kernel, but none of those guards
were pinned by tests.

Adds protocols/corona/corona_test.go (17 tests, all PASS in 0.018s):

Bootstrap (4):
  - rejects empty validators -> ErrEmptyValidators
  - rejects t=0 -> ErrInvalidThreshold
  - rejects t>n -> ErrInvalidThreshold
  - nil entropy does NOT panic (falls back to crypto/rand.Reader)

Reshare (3):
  - rejects nil KeyEra
  - rejects nil-era + nil validators
  - rejects nil-era + threshold > n=1

Reanchor (3):
  - rejects empty validators -> ErrEmptyValidators
  - rejects t=0 -> ErrInvalidThreshold
  - rejects t>n -> ErrInvalidThreshold

ShareForParty (3):
  - nil state -> error mentioning nil-share-state
  - party not in set -> ErrPartyNotInSet (error mentions the missing id)
  - happy path returns the exact same KeyShare pointer

Alias surface (2):
  - NewParams returns non-nil Params with no error
  - GenerateKeys (2-of-3 trusted-dealer) returns 3 non-nil shares
    plus a non-nil GroupKey from a deterministic seed

validatorIDs unexported helper (2):
  - preserves order and length for non-empty input
  - returns non-nil empty slice for nil input

Run:
  go test ./protocols/corona/ -count=1 -v -timeout 120s
  PASS - 17/17, 0.018s

No changes to non-test files; no regression in the existing suite
(which had no corona tests to regress).
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.

1 participant