Skip to content

Commit

Permalink
chore: remove unnecessary conversions (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
estensen authored Jan 10, 2024
1 parent 4cfe0de commit 2baf10f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/shares/compact_shares_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func Test_processCompactShares(t *testing.T) {

// check that the data parsed is identical
for i := 0; i < len(txs); i++ {
assert.Equal(t, []byte(txs[i]), parsedTxs[i])
assert.Equal(t, txs[i], parsedTxs[i])
}
})

Expand All @@ -103,7 +103,7 @@ func Test_processCompactShares(t *testing.T) {

// check that the data parsed is identical to the original
for i := 0; i < len(txs); i++ {
assert.Equal(t, []byte(txs[i]), parsedTxs[i])
assert.Equal(t, txs[i], parsedTxs[i])
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/shares/info_byte.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ func (i InfoByte) IsSequenceStart() bool {

func ParseInfoByte(i byte) (InfoByte, error) {
isSequenceStart := i%2 == 1
version := uint8(i) >> 1
version := i >> 1
return NewInfoByte(version, isSequenceStart)
}
2 changes: 1 addition & 1 deletion pkg/shares/share_splitting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func TestSplitTxs(t *testing.T) {
),
}

largeTx := []byte(bytes.Repeat([]byte{0xc}, ShareSize)) // spans two shares
largeTx := bytes.Repeat([]byte{0xc}, ShareSize) // spans two shares
largeTxShares := []Share{
fillShare(Share{
data: append(namespace.TxNamespace.Bytes(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/shares/shares.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (s *Share) rawDataStartIndexUsingReserved() (int, error) {
func ToBytes(shares []Share) (bytes [][]byte) {
bytes = make([][]byte, len(shares))
for i, share := range shares {
bytes[i] = []byte(share.data)
bytes[i] = share.data
}
return bytes
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/shares/split_compact_shares_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ func TestExport(t *testing.T) {
}

txOne := []byte{0x1}
txTwo := []byte(bytes.Repeat([]byte{2}, 600))
txThree := []byte(bytes.Repeat([]byte{3}, 1000))
exactlyOneShare := []byte(bytes.Repeat([]byte{4}, RawTxSize(FirstCompactShareContentSize)))
exactlyTwoShares := []byte(bytes.Repeat([]byte{5}, RawTxSize(FirstCompactShareContentSize+ContinuationCompactShareContentSize)))
txTwo := bytes.Repeat([]byte{2}, 600)
txThree := bytes.Repeat([]byte{3}, 1000)
exactlyOneShare := bytes.Repeat([]byte{4}, RawTxSize(FirstCompactShareContentSize))
exactlyTwoShares := bytes.Repeat([]byte{5}, RawTxSize(FirstCompactShareContentSize+ContinuationCompactShareContentSize))

testCases := []testCase{
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/shares/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func CheckSubArray(txList [][]byte, subTxList [][]byte) bool {
for j = 0; j < len(subTxList); j++ {
tx := txList[i+j]
subTx := subTxList[j]
if !bytes.Equal([]byte(tx), []byte(subTx)) {
if !bytes.Equal(tx, subTx) {
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/shares/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ func TestParseDelimiter(t *testing.T) {
panic(err)
}
assert.Equal(t, i, txLen)
assert.Equal(t, []byte(tx), res)
assert.Equal(t, tx, res)
}
}

0 comments on commit 2baf10f

Please sign in to comment.