Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Manav-Aggarwal committed May 18, 2023
1 parent 792841d commit b802fa0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/shares/compact_shares_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestParseOutOfContextShares(t *testing.T) {
require.NoError(t, err)

for i := 0; i < 1000; i++ {
start, length := testfactory.GetRandomSlice(len(txShares))
start, length := testfactory.GetRandomSubSlice(len(txShares))

resTxs, err := ParseTxs(txShares[start : start+length])
require.NoError(t, err)
Expand Down
6 changes: 4 additions & 2 deletions pkg/shares/shares.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,16 @@ func (s *Share) RawDataUsingReserved() (rawData []byte, err error) {
return s.data[rawDataStartIndexUsingReserved:], nil
}

// rawDataStartIndexUsingReserved returns the start index of raw data while accounting for
// reserved bytes, if it exists in the share.
func (s *Share) rawDataStartIndexUsingReserved() (int, error) {
isStart, err := s.IsSequenceStart()
if err != nil {
panic(err)
return 0, err
}
isCompact, err := s.IsCompactShare()
if err != nil {
panic(err)
return 0, err
}

index := appconsts.NamespaceSize + appconsts.ShareInfoBytes
Expand Down
3 changes: 2 additions & 1 deletion test/util/testfactory/txs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func GenerateRandomTxs(count, size int) types.Txs {
return txs
}

func GetRandomSlice(size int) (start int, length int) {
// GetRandomSubSlice returns two integers representing a randomly sized range in the interval [0, size]
func GetRandomSubSlice(size int) (start int, length int) {
length = rand.Intn(size + 1)
start = rand.Intn(size - length + 1)
return start, length
Expand Down

0 comments on commit b802fa0

Please sign in to comment.