Skip to content

Commit

Permalink
addresses reviewers feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
staheri14 committed Jul 10, 2023
1 parent a525e49 commit 2dcfb41
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions extendeddatacrossword_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,20 +346,20 @@ func createTestEds(codec Codec, shareSize int) *ExtendedDataSquare {
return eds
}

func TestCorruptedEdsReturnsErrByzantineData_UorderedShares(t *testing.T) {
shareSize := 64
func TestCorruptedEdsReturnsErrByzantineData_UnorderedShares(t *testing.T) {
shareSize := 512
namespaceSize := 1
one := bytes.Repeat([]byte{1}, shareSize)
two := bytes.Repeat([]byte{2}, shareSize)
three := bytes.Repeat([]byte{3}, shareSize)
sharesValue := []int{1, 2, 3, 4}
tests := []struct {
name string
coords [][]uint
values [][]byte
wantErr bool
corruptedAxis Axis
corruptedInd uint
name string
coords [][]uint
values [][]byte
wantErr bool
corruptedAxis Axis
corruptedIndex uint
}{
{
name: "no corruption",
Expand Down Expand Up @@ -392,7 +392,7 @@ func TestCorruptedEdsReturnsErrByzantineData_UorderedShares(t *testing.T) {
nil, nil, nil, nil,
nil, nil, nil, nil,
},
corruptedInd: 0,
corruptedIndex: 0,
},
{
// disturbs the order of shares in the first column, erases the rest of the eds
Expand Down Expand Up @@ -421,7 +421,7 @@ func TestCorruptedEdsReturnsErrByzantineData_UorderedShares(t *testing.T) {
nil, nil, nil,
nil, nil, nil,
},
corruptedInd: 0,
corruptedIndex: 0,
},
}

Expand All @@ -439,7 +439,7 @@ func TestCorruptedEdsReturnsErrByzantineData_UorderedShares(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
// create an eds with the given shares
corruptEds := createTestEdsWithNMT(t, codec, shareSize, namespaceSize, sharesValue...)
assert.NotNil(t, eds)
assert.NotNil(t, corruptEds)
// corrupt it by setting the values at the given coordinates
for i, coords := range test.coords {
x := coords[0]
Expand All @@ -454,7 +454,7 @@ func TestCorruptedEdsReturnsErrByzantineData_UorderedShares(t *testing.T) {
assert.ErrorAs(t, err, &byzErr)
errors.As(err, &byzErr)
assert.Equal(t, byzErr.Axis, test.corruptedAxis)
assert.Equal(t, byzErr.Index, test.corruptedInd)
assert.Equal(t, byzErr.Index, test.corruptedIndex)
}
})
}
Expand All @@ -479,9 +479,7 @@ func createTestEdsWithNMT(t *testing.T, codec Codec, shareSize, namespaceSize in
odsWidth := edsWidth / 2 // number of shares per row/column in the original data square

eds, err := ComputeExtendedDataSquare(shares, codec, newConstructor(uint64(odsWidth), nmt.NamespaceIDSize(namespaceSize)))
if err != nil {
panic(err)
}
require.NoError(t, err)

return eds
}

0 comments on commit 2dcfb41

Please sign in to comment.