mirror of
https://github.com/luxfi/threshold.git
synced 2026-10-30 15:15:53 +00:00
round.Helper was the canonical anti-pattern: a bare-noun
qualifier-name that told you nothing about what the type does. The
type is the embeddable Session implementation that protocol round
structs anchor on — its VALUE is "the base every round builds on".
Rename it to that.
type Helper struct { ... } → type Base struct { ... }
func (h *Helper) ... → func (h *Base) ...
func NewSession(...) (*Helper, error) → (*Base, error)
Output { *Helper } → Output { *Base }
Abort { *Helper } → Abort { *Base }
round.Helper → round.Base (18 files)
Helper: helper → Base: helper (struct literal init)
r.Helper.X / r.Helper → r.Base.X / r.Base (field access)
internal/round/helper.go → base.go
internal/round/helper_test.go → base_test.go
Forward-only — no type alias, no deprecation. The Go FAQ pointer-
receiver consistency landed in the prior commit (f7b1365) so the
method set is already aligned; this commit only renames the type.
Build + vet clean; round / CMP keygen smoke / FROST keygen all
PASS unchanged.
117 lines
1.8 KiB
Go
117 lines
1.8 KiB
Go
package round_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/luxfi/threshold/internal/round"
|
|
"github.com/luxfi/threshold/internal/test"
|
|
"github.com/luxfi/threshold/pkg/math/curve"
|
|
"github.com/luxfi/threshold/pkg/party"
|
|
)
|
|
|
|
func TestNewSession(t *testing.T) {
|
|
RNumber := round.Number(5)
|
|
T := 20
|
|
N := 26
|
|
partyIDs := test.PartyIDs(N)
|
|
selfID := partyIDs[0]
|
|
tests := []struct {
|
|
name string
|
|
roundNumber round.Number
|
|
selfID party.ID
|
|
partyIDs []party.ID
|
|
threshold int
|
|
group curve.Curve
|
|
wantErr bool
|
|
}{
|
|
{
|
|
"-1 t",
|
|
RNumber,
|
|
selfID,
|
|
partyIDs,
|
|
-1,
|
|
curve.Secp256k1{},
|
|
true,
|
|
},
|
|
{
|
|
"invalid selfID",
|
|
RNumber,
|
|
"",
|
|
partyIDs,
|
|
T,
|
|
curve.Secp256k1{},
|
|
true,
|
|
},
|
|
{
|
|
"duplicate selfID",
|
|
RNumber,
|
|
selfID,
|
|
append(partyIDs, selfID),
|
|
T,
|
|
curve.Secp256k1{},
|
|
true,
|
|
},
|
|
{
|
|
"duplicate second ID",
|
|
RNumber,
|
|
selfID,
|
|
append(partyIDs, partyIDs[1]),
|
|
T,
|
|
curve.Secp256k1{},
|
|
true,
|
|
},
|
|
{
|
|
"duplicate partyIDs",
|
|
RNumber,
|
|
selfID,
|
|
append(partyIDs, partyIDs...),
|
|
T,
|
|
curve.Secp256k1{},
|
|
true,
|
|
},
|
|
{
|
|
"threshold N",
|
|
RNumber,
|
|
selfID,
|
|
partyIDs,
|
|
N,
|
|
curve.Secp256k1{},
|
|
true,
|
|
},
|
|
{
|
|
"threshold T with T parties",
|
|
RNumber,
|
|
selfID,
|
|
partyIDs[:T],
|
|
T,
|
|
curve.Secp256k1{},
|
|
true,
|
|
},
|
|
{
|
|
"no group",
|
|
RNumber,
|
|
selfID,
|
|
partyIDs,
|
|
T,
|
|
curve.Secp256k1{},
|
|
false,
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
info := round.Info{
|
|
ProtocolID: "TEST",
|
|
FinalRoundNumber: tt.roundNumber,
|
|
SelfID: tt.selfID,
|
|
PartyIDs: tt.partyIDs,
|
|
Threshold: tt.threshold,
|
|
Group: tt.group,
|
|
}
|
|
_, err := round.NewSession(info, nil, nil)
|
|
if tt.wantErr == (err == nil) {
|
|
t.Error(err)
|
|
}
|
|
})
|
|
}
|
|
}
|