mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-24 08:49:29 +00:00
trie: fix flaky test (#33711)
This commit is contained in:
parent
2513feddf8
commit
7046e63244
1 changed files with 6 additions and 5 deletions
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
|
|
@ -248,7 +249,7 @@ func TestNodeDifference(t *testing.T) {
|
||||||
old: nil, new: testrand.Bytes(32), expErr: true,
|
old: nil, new: testrand.Bytes(32), expErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
old: testrand.Bytes(32), new: testrand.Bytes(32), expErr: true,
|
old: bytes.Repeat([]byte{0x1}, 32), new: bytes.Repeat([]byte{0x2}, 32), expErr: true,
|
||||||
},
|
},
|
||||||
// Different node type
|
// Different node type
|
||||||
{
|
{
|
||||||
|
|
@ -276,19 +277,19 @@ func TestNodeDifference(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for i, test := range tests {
|
||||||
_, indices, values, err := NodeDifference(test.old, test.new)
|
_, indices, values, err := NodeDifference(test.old, test.new)
|
||||||
if test.expErr && err == nil {
|
if test.expErr && err == nil {
|
||||||
t.Fatal("Expect error, got nil")
|
t.Fatalf("Expect error, got nil %d", i)
|
||||||
}
|
}
|
||||||
if !test.expErr && err != nil {
|
if !test.expErr && err != nil {
|
||||||
t.Fatalf("Unexpect error, %v", err)
|
t.Fatalf("Unexpect error, %v", err)
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if !reflect.DeepEqual(indices, test.expIndices) {
|
if !slices.Equal(indices, test.expIndices) {
|
||||||
t.Fatalf("Unexpected indices, want: %v, got: %v", test.expIndices, indices)
|
t.Fatalf("Unexpected indices, want: %v, got: %v", test.expIndices, indices)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(values, test.expValues) {
|
if !slices.EqualFunc(values, test.expValues, bytes.Equal) {
|
||||||
t.Fatalf("Unexpected values, want: %v, got: %v", test.expValues, values)
|
t.Fatalf("Unexpected values, want: %v, got: %v", test.expValues, values)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue