@@ -19,6 +19,7 @@ package trie
19
19
import (
20
20
"bytes"
21
21
"fmt"
22
+ "maps"
22
23
"math/rand"
23
24
"testing"
24
25
@@ -837,13 +838,6 @@ func testPivotMove(t *testing.T, scheme string, tiny bool) {
837
838
tr .Update (key , val )
838
839
states [string (key )] = common .CopyBytes (val )
839
840
}
840
- copyStates = func (states map [string ][]byte ) map [string ][]byte {
841
- cpy := make (map [string ][]byte )
842
- for k , v := range states {
843
- cpy [k ] = v
844
- }
845
- return cpy
846
- }
847
841
)
848
842
stateA := make (map [string ][]byte )
849
843
writeFn ([]byte {0x01 , 0x23 }, nil , srcTrie , stateA )
@@ -866,7 +860,7 @@ func testPivotMove(t *testing.T, scheme string, tiny bool) {
866
860
checkTrieContents (t , destDisk , scheme , srcTrie .Hash ().Bytes (), stateA , true )
867
861
868
862
// Delete element to collapse trie
869
- stateB := copyStates (stateA )
863
+ stateB := maps . Clone (stateA )
870
864
srcTrie , _ = New (TrieID (rootA ), srcTrieDB )
871
865
deleteFn ([]byte {0x02 , 0x34 }, srcTrie , stateB )
872
866
deleteFn ([]byte {0x13 , 0x44 }, srcTrie , stateB )
@@ -883,7 +877,7 @@ func testPivotMove(t *testing.T, scheme string, tiny bool) {
883
877
checkTrieContents (t , destDisk , scheme , srcTrie .Hash ().Bytes (), stateB , true )
884
878
885
879
// Add elements to expand trie
886
- stateC := copyStates (stateB )
880
+ stateC := maps . Clone (stateB )
887
881
srcTrie , _ = New (TrieID (rootB ), srcTrieDB )
888
882
889
883
writeFn ([]byte {0x01 , 0x24 }, stateA [string ([]byte {0x01 , 0x24 })], srcTrie , stateC )
@@ -941,13 +935,6 @@ func testSyncAbort(t *testing.T, scheme string) {
941
935
tr .Update (key , val )
942
936
states [string (key )] = common .CopyBytes (val )
943
937
}
944
- copyStates = func (states map [string ][]byte ) map [string ][]byte {
945
- cpy := make (map [string ][]byte )
946
- for k , v := range states {
947
- cpy [k ] = v
948
- }
949
- return cpy
950
- }
951
938
)
952
939
var (
953
940
stateA = make (map [string ][]byte )
@@ -972,7 +959,7 @@ func testSyncAbort(t *testing.T, scheme string) {
972
959
checkTrieContents (t , destDisk , scheme , srcTrie .Hash ().Bytes (), stateA , true )
973
960
974
961
// Delete the element from the trie
975
- stateB := copyStates (stateA )
962
+ stateB := maps . Clone (stateA )
976
963
srcTrie , _ = New (TrieID (rootA ), srcTrieDB )
977
964
deleteFn (key , srcTrie , stateB )
978
965
@@ -999,7 +986,7 @@ func testSyncAbort(t *testing.T, scheme string) {
999
986
}})
1000
987
1001
988
// Add elements to expand trie
1002
- stateC := copyStates (stateB )
989
+ stateC := maps . Clone (stateB )
1003
990
srcTrie , _ = New (TrieID (rootB ), srcTrieDB )
1004
991
1005
992
writeFn (key , val , srcTrie , stateC )
0 commit comments