Files
pulsard/helpers_test.go
zeekay e47605c1f9 chore: initial commit — pulsard
This tree had a .git directory but ZERO commits, no branch and no remote: the
source existed only as loose files on one disk, where an rm -rf would have
destroyed it with nothing to recover from.

Commits the working tree as-is so the work is in git history. No source was
modified.

NOTE: still has no remote. luxfi/pulsard does not exist on GitHub, so this
is one copy in one place until somebody creates it.
2026-07-26 02:53:27 -07:00

44 lines
1.2 KiB
Go

// Copyright (C) 2019-2026, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package pulsard_test
import (
"testing"
"github.com/luxfi/ids"
"github.com/luxfi/pulsard"
"github.com/luxfi/warp"
)
// testID builds a deterministic ids.ID from a label (left-aligned, zero-padded).
func testID(label string) ids.ID {
var x ids.ID
copy(x[:], label)
return x
}
// testThreshold is a representative stake-weighted quorum (2/3).
var testThreshold = warp.WeightThreshold{Numerator: 2, Denominator: 3}
// subject32 returns a 32-byte subject filled from a label.
func subject32(label string) []byte {
b := make([]byte, pulsard.SubjectLen)
copy(b, label)
return b
}
// newRefSigner builds a reference (trusted-dealer) signer + its era for tests.
// FOOTGUN path — proves the verify integration only.
func newRefSigner(t *testing.T) (*pulsard.Signer, warp.PulsarKeyEra) {
t.Helper()
signer, era, err := pulsard.NewReferenceSigner(
testID("chain"), testID("signer-set"),
7 /*keyEraID*/, 0 /*generation*/, 42 /*pChainHeight*/, testThreshold, nil,
)
if err != nil {
t.Fatalf("NewReferenceSigner: %v", err)
}
return signer, era
}