Skip to content

Commit

Permalink
fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Nov 9, 2023
1 parent c1121b4 commit 3b1d06c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions cmd/es-utils/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TestEncodeDecodeBlob(t *testing.T) {
t.Run("", func(t *testing.T) {
encoded := EncodeBlobs(data)
decoded := DecodeBlob(encoded[0][:])
decoded = decoded[:len(data)]
if !bytes.Equal(data, decoded) {
t.Errorf("data:\n%v\nencoded/decoded:\n%v\n", data, decoded)
}
Expand Down
13 changes: 10 additions & 3 deletions ethstorage/p2p/protocol/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/ethstorage/go-ethstorage/cmd/es-utils/utils"
"github.com/ethstorage/go-ethstorage/ethstorage"
prv "github.com/ethstorage/go-ethstorage/ethstorage/prover"
"github.com/ethstorage/go-ethstorage/ethstorage/rollup"
Expand Down Expand Up @@ -718,15 +719,21 @@ func TestReadWrite(t *testing.T) {
}(files)

sm := ethstorage.ContractToShardManager[contract]
success, err := sm.TryWrite(0, []byte{1}, common.Hash{})

bs := []byte{1}
blobs := utils.EncodeBlobs(bs)
_, _, versionedHashes, err := utils.ComputeBlobs(blobs)
success, err := sm.TryWrite(0, blobs[0][:], versionedHashes[0])
if !success || err != nil {
t.Fatalf("failed to write")
}
rdata, success, err := sm.TryRead(0, 1, common.Hash{})
// blob is 01000...000
rdata, success, err := sm.TryRead(0, 2, versionedHashes[0])
if !success || err != nil {
t.Fatalf("failed to read")
}
if !bytes.Equal([]byte{1}, rdata) {
// data is blob 2 index
if !bytes.Equal([]byte{1}, rdata[1:2]) {
t.Fatalf("failed to compare")
}
}
Expand Down

0 comments on commit 3b1d06c

Please sign in to comment.