@@ -835,8 +835,8 @@ func TestTraceChain(t *testing.T) {
835
835
signer := types.HomesteadSigner {}
836
836
837
837
var (
838
- ref uint32 // total refs has made
839
- rel uint32 // total rels has made
838
+ ref atomic. Uint32 // total refs has made
839
+ rel atomic. Uint32 // total rels has made
840
840
nonce uint64
841
841
)
842
842
backend := newTestBackend (t , genBlocks , genesis , func (i int , b * core.BlockGen ) {
@@ -849,8 +849,8 @@ func TestTraceChain(t *testing.T) {
849
849
nonce += 1
850
850
}
851
851
})
852
- backend .refHook = func () { atomic . AddUint32 ( & ref , 1 ) }
853
- backend .relHook = func () { atomic . AddUint32 ( & rel , 1 ) }
852
+ backend .refHook = func () { ref . Add ( 1 ) }
853
+ backend .relHook = func () { rel . Add ( 1 ) }
854
854
api := NewAPI (backend )
855
855
856
856
single := `{"result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}`
@@ -863,7 +863,8 @@ func TestTraceChain(t *testing.T) {
863
863
{10 , 20 , nil }, // the middle chain range, blocks [11, 20]
864
864
}
865
865
for _ , c := range cases {
866
- ref , rel = 0 , 0 // clean up the counters
866
+ ref .Store (0 )
867
+ rel .Store (0 )
867
868
868
869
from , _ := api .blockByNumber (context .Background (), rpc .BlockNumber (c .start ))
869
870
to , _ := api .blockByNumber (context .Background (), rpc .BlockNumber (c .end ))
@@ -888,8 +889,9 @@ func TestTraceChain(t *testing.T) {
888
889
if next != c .end + 1 {
889
890
t .Error ("Missing tracing block" )
890
891
}
891
- if ref != rel {
892
- t .Errorf ("Ref and deref actions are not equal, ref %d rel %d" , ref , rel )
892
+
893
+ if nref , nrel := ref .Load (), rel .Load (); nref != nrel {
894
+ t .Errorf ("Ref and deref actions are not equal, ref %d rel %d" , nref , nrel )
893
895
}
894
896
}
895
897
}
0 commit comments