Skip to content

test(pulsar): alias-surface tests for ParamsFor + Sign/VerifyCtx round-trip#23

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

test(pulsar): alias-surface tests for ParamsFor + Sign/VerifyCtx round-trip#23
abhicris wants to merge 1 commit into
luxfi:mainfrom
abhicris:test/2026-06-01-pulsar-alias-tests

Conversation

@abhicris
Copy link
Copy Markdown
Contributor

@abhicris abhicris commented Jun 1, 2026

protocols/pulsar/ had no _test.go even though the surface is what luxfi/consensus imports (per the alias-layering comment at the top of pulsar.go). The sibling protocols/corona/ package was in the same shape until PR #22 (this session); this PR brings pulsar up to parity.

What this PR adds

protocols/pulsar/pulsar_test.go — 13 tests (+3 subtests), all PASS in 0.013s.

ParamsFor / MustParamsFor (4 tests / 3 subtests)

  • ParamsFor(ModeUnspecified) → error, nil params
  • ParamsFor(P44 / P65 / P87) → returns the pre-built ParamsXX *Params singleton by pointer equality (the cache-keying contract documented in pulsar.go)
  • MustParamsFor(ModeUnspecified) panics
  • MustParamsFor(ModeP65) returns the ParamsP65 singleton

GenerateIdentity / NewIdentityDirectory (3 tests)

  • GenerateIdentity(rand.Reader) returns non-nil *IdentityKey
  • Two generations from equivalent deterministic seeds both succeed
  • NewIdentityDirectory({}) does not panic on empty input (alias contract)

Single-party FIPS 204 round-trip (5 tests)

  • GenerateKey(ParamsP65, rand.Reader) returns non-nil *PrivateKey
  • Sign + VerifyCtx happy path
  • VerifyCtx rejects a tampered message
  • VerifyCtx rejects a wrong context and still verifies the right one

The VerifyCtx tests use a small test-local helper publicKeyFromPrivate that calls sk.Public() through a runtime interface assertion (type publicer interface { Public() *PublicKey }), so the test stays stable if the kernel reshapes the PrivateKey API.

Verification

$ go test ./protocols/pulsar/ -count=1 -v -timeout 120s
PASS — 13/13 in 0.013s

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

Notes

…d-trip

protocols/pulsar/ had no _test.go even though the surface is what
luxfi/consensus imports (per the alias-layering comment in pulsar.go).
The corresponding protocols/corona/ package was in the same shape;
PR luxfi#22 (this session) adds tests there. This PR brings pulsar up to
parity.

Adds protocols/pulsar/pulsar_test.go (13 tests, all PASS in 0.013s):

ParamsFor / MustParamsFor (4 + 3 subtests):
  - ParamsFor(ModeUnspecified) -> error, nil params
  - ParamsFor(P44/P65/P87) -> returns the pre-built ParamsXX *Params
    singleton by pointer equality (cache-keying contract)
  - MustParamsFor(ModeUnspecified) panics
  - MustParamsFor(ModeP65) returns ParamsP65 singleton

GenerateIdentity / NewIdentityDirectory (3):
  - GenerateIdentity(rand.Reader) returns non-nil IdentityKey
  - Two generations from equivalent deterministic seeds both succeed
  - NewIdentityDirectory({}) does not panic — pins the alias contract

Single-party FIPS 204 round-trip (5):
  - GenerateKey(ParamsP65, rand.Reader) returns non-nil PrivateKey
  - Sign + VerifyCtx happy path
  - VerifyCtx rejects a tampered message
  - VerifyCtx rejects a wrong context and still verifies the right one

The VerifyCtx tests use a small test-local helper publicKeyFromPrivate
that calls sk.Public() through a runtime interface assertion, so the
test stays stable if the kernel reshapes the PrivateKey API.

Run:
  go test ./protocols/pulsar/ -count=1 -v -timeout 120s
  PASS - 13/13, 0.013s
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