Skip to content

Commit

Permalink
fix(lib/erasure): Move test assertion to non-error condition (#3371)
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardmack authored and kishansagathiya committed Jan 24, 2024
1 parent 47aa0fe commit dec23c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/erasure/erasure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var missing5Chunks = [][]byte{{}, {}, {}, {115, 116, 32, 111},
{88, 245, 245, 220}, {59, 208, 165, 70}, {127, 213, 208, 179}}

func TestObtainChunks(t *testing.T) {
t.Parallel()
type args struct {
validatorsQty int
data []byte
Expand Down Expand Up @@ -59,7 +60,9 @@ func TestObtainChunks(t *testing.T) {
},
}
for name, tt := range tests {
tt := tt
t.Run(name, func(t *testing.T) {
t.Parallel()
got, err := ObtainChunks(tt.args.validatorsQty, tt.args.data)
expectedThreshold, _ := recoveryThreshold(tt.args.validatorsQty)
if tt.expectedError != nil {
Expand All @@ -74,6 +77,7 @@ func TestObtainChunks(t *testing.T) {
}

func TestReconstruct(t *testing.T) {
t.Parallel()
type args struct {
validatorsQty int
chunks [][]byte
Expand Down Expand Up @@ -118,15 +122,17 @@ func TestReconstruct(t *testing.T) {
},
}
for name, tt := range tests {
tt := tt
t.Run(name, func(t *testing.T) {
t.Parallel()
data, err := Reconstruct(tt.args.validatorsQty, len(testData), tt.args.chunks)
if tt.expectedError != nil {
assert.EqualError(t, err, tt.expectedError.Error())
} else {
assert.NoError(t, err)
assert.Equal(t, tt.expectedChunks, tt.args.chunks)
}
assert.Equal(t, tt.expectedData, data)
assert.Equal(t, tt.expectedChunks, tt.args.chunks)
})
}
}

0 comments on commit dec23c9

Please sign in to comment.