test(pulsar): alias-surface tests for ParamsFor + Sign/VerifyCtx round-trip#23
Open
abhicris wants to merge 1 commit into
Open
test(pulsar): alias-surface tests for ParamsFor + Sign/VerifyCtx round-trip#23abhicris wants to merge 1 commit into
abhicris wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
protocols/pulsar/had no_test.goeven though the surface is whatluxfi/consensusimports (per the alias-layering comment at the top ofpulsar.go). The siblingprotocols/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 paramsParamsFor(P44 / P65 / P87)→ returns the pre-builtParamsXX *Paramssingleton by pointer equality (the cache-keying contract documented inpulsar.go)MustParamsFor(ModeUnspecified)panicsMustParamsFor(ModeP65)returns theParamsP65singletonGenerateIdentity/NewIdentityDirectory(3 tests)GenerateIdentity(rand.Reader)returns non-nil*IdentityKeyNewIdentityDirectory({})does not panic on empty input (alias contract)Single-party FIPS 204 round-trip (5 tests)
GenerateKey(ParamsP65, rand.Reader)returns non-nil*PrivateKeySign+VerifyCtxhappy pathVerifyCtxrejects a tampered messageVerifyCtxrejects a wrong context and still verifies the right oneThe
VerifyCtxtests use a small test-local helperpublicKeyFromPrivatethat callssk.Public()through a runtime interface assertion (type publicer interface { Public() *PublicKey }), so the test stays stable if the kernel reshapes thePrivateKeyAPI.Verification
No changes to non-test files. No regression in the existing suite (there was no pulsar test coverage to regress).
Notes
luxfi/pulsar/ref/go/pkg/pulsar). It pins what the consensus layer relies on through the alias path.