@@ -21,7 +21,7 @@ import (
2121 "fmt"
2222 "math/big"
2323 "reflect"
24- "sort "
24+ "slices "
2525 "testing"
2626
2727 "github.com/XinFinOrg/XDPoSChain/common"
@@ -59,12 +59,6 @@ func accountRangeTest(t *testing.T, trie *state.Trie, statedb *state.StateDB, st
5959 return result
6060}
6161
62- type resultHash []common.Hash
63-
64- func (h resultHash ) Len () int { return len (h ) }
65- func (h resultHash ) Swap (i , j int ) { h [i ], h [j ] = h [j ], h [i ] }
66- func (h resultHash ) Less (i , j int ) bool { return bytes .Compare (h [i ].Bytes (), h [j ].Bytes ()) < 0 }
67-
6862func TestAccountRange (t * testing.T ) {
6963 t .Parallel ()
7064
@@ -98,7 +92,7 @@ func TestAccountRange(t *testing.T) {
9892 firstResult := accountRangeTest (t , & trie , sdb , common.Hash {}, AccountRangeMaxResults , AccountRangeMaxResults )
9993 secondResult := accountRangeTest (t , & trie , sdb , common .BytesToHash (firstResult .Next ), AccountRangeMaxResults , AccountRangeMaxResults )
10094
101- hList := make (resultHash , 0 )
95+ hList := make ([]common. Hash , 0 )
10296 for addr1 := range firstResult .Accounts {
10397 // If address is empty, then it makes no sense to compare
10498 // them as they might be two different accounts.
@@ -112,7 +106,7 @@ func TestAccountRange(t *testing.T) {
112106 }
113107 // Test to see if it's possible to recover from the middle of the previous
114108 // set and get an even split between the first and second sets.
115- sort . Sort (hList )
109+ slices . SortFunc (hList , common . Hash . Cmp )
116110 middleH := hList [AccountRangeMaxResults / 2 ]
117111 middleResult := accountRangeTest (t , & trie , sdb , middleH , AccountRangeMaxResults , AccountRangeMaxResults )
118112 missing , infirst , insecond := 0 , 0 , 0
0 commit comments