diff --git a/test/e2e/docker/Dockerfile b/test/e2e/docker/Dockerfile index 6f0f337cf2..c81db55fc8 100644 --- a/test/e2e/docker/Dockerfile +++ b/test/e2e/docker/Dockerfile @@ -1,7 +1,7 @@ # We need to build in a Linux environment to support C libraries, e.g. RocksDB. # We use Debian instead of Alpine, so that we can use binary database packages # instead of spending time compiling them. -FROM golang:1.19 +FROM golang:1.20-bullseye RUN apt-get -qq update -y && apt-get -qq upgrade -y >/dev/null RUN apt-get -qq install -y libleveldb-dev librocksdb-dev >/dev/null diff --git a/types/block.go b/types/block.go index 0d9d167d3d..858969852f 100644 --- a/types/block.go +++ b/types/block.go @@ -1036,26 +1036,6 @@ func (data *Data) Hash() cmtbytes.HexBytes { return data.hash } -// BlobsByNamespace implements sort.Interface for Blob -type BlobsByNamespace []Blob - -func (b BlobsByNamespace) Len() int { - return len(b) -} - -func (b BlobsByNamespace) Swap(i, j int) { - b[i], b[j] = b[j], b[i] -} - -func (b BlobsByNamespace) Less(i, j int) bool { - // The following comparison is `<` and not `<=` because bytes.Compare returns 0 for if a == b. - // We want this comparison to return `false` if a == b because: - // If both Less(i, j) and Less(j, i) are false, - // then the elements at index i and j are considered equal. - // See https://pkg.go.dev/sort#Interface - return bytes.Compare(b[i].NamespaceID, b[j].NamespaceID) < 0 -} - type Blob struct { // NamespaceVersion is the version of the namespace. Used in conjunction // with NamespaceID to determine the namespace of this blob. diff --git a/types/block_test.go b/types/block_test.go index bd6c05f374..b20986137b 100644 --- a/types/block_test.go +++ b/types/block_test.go @@ -9,7 +9,6 @@ import ( "math" "os" "reflect" - "sort" "testing" "time" @@ -857,55 +856,3 @@ func TestBlockIDEquals(t *testing.T) { assert.True(t, blockIDEmpty.Equals(blockIDEmpty)) assert.False(t, blockIDEmpty.Equals(blockIDDifferent)) } - -func TestBlobsByNamespaceIsSorted(t *testing.T) { - sortedBlobs := []Blob{ - { - NamespaceID: []byte{1, 2, 3, 4, 5, 6, 7, 8}, - Data: stdbytes.Repeat([]byte{1}, 100), - }, - { - NamespaceID: []byte{8, 7, 6, 5, 4, 3, 2, 1}, - Data: stdbytes.Repeat([]byte{2}, 100), - }, - } - sameNamespacedBlobs := []Blob{ - { - NamespaceID: []byte{1, 2, 3, 4, 5, 6, 7, 8}, - Data: stdbytes.Repeat([]byte{1}, 100), - }, - { - NamespaceID: []byte{1, 2, 3, 4, 5, 6, 7, 8}, - Data: stdbytes.Repeat([]byte{2}, 100), - }, - } - unsortedBlobs := []Blob{ - { - NamespaceID: []byte{8, 7, 6, 5, 4, 3, 2, 1}, - Data: stdbytes.Repeat([]byte{1}, 100), - }, - { - NamespaceID: []byte{1, 2, 3, 4, 5, 6, 7, 8}, - Data: stdbytes.Repeat([]byte{2}, 100), - }, - } - - type testCase struct { - description string - blobs []Blob - want bool - } - - tests := []testCase{ - {"sorted blobs", sortedBlobs, true}, - {"same namespace blobs", sameNamespacedBlobs, true}, - {"unsorted blobs", unsortedBlobs, false}, - } - - for _, tc := range tests { - t.Run(tc.description, func(t *testing.T) { - bs := tc.blobs - assert.Equal(t, tc.want, sort.IsSorted(BlobsByNamespace(bs))) - }) - } -}