Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unnecessary conversions #3

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
Loading