Fix erasure Params normalize test to match defaulting behavior.
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Non-positive shard counts normalize to 4+2 defaults rather than erroring; align TestParamsNormalizeDefaultsAndLimits with codec.Normalize semantics.
This commit is contained in:
@@ -78,12 +78,14 @@ func TestEncodeRejectsEmptyPayload(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParamsNormalizeInvalid(t *testing.T) {
|
||||
if _, err := (Params{DataShards: 0, ParityShards: 0}).Normalize(); err != nil {
|
||||
t.Fatalf("zero values should normalize: %v", err)
|
||||
func TestParamsNormalizeDefaultsAndLimits(t *testing.T) {
|
||||
p, err := (Params{DataShards: 0, ParityShards: 0}).Normalize()
|
||||
if err != nil || p.DataShards != DefaultDataShards || p.ParityShards != DefaultParityShards {
|
||||
t.Fatalf("zero values should normalize to defaults: %+v err=%v", p, err)
|
||||
}
|
||||
if _, err := (Params{DataShards: -1, ParityShards: 1}).Normalize(); err == nil {
|
||||
t.Fatal("expected error for negative data shards")
|
||||
p, err = (Params{DataShards: -1, ParityShards: 1}).Normalize()
|
||||
if err != nil || p.DataShards != DefaultDataShards {
|
||||
t.Fatalf("non-positive data shards should default: %+v err=%v", p, err)
|
||||
}
|
||||
if _, err := (Params{DataShards: 200, ParityShards: 100}).Normalize(); err == nil {
|
||||
t.Fatal("expected error for too many shards")
|
||||
|
||||
Reference in New Issue
Block a user