@@ -835,8 +835,8 @@ func TestTraceChain(t *testing.T) {
835835 signer := types.HomesteadSigner {}
836836
837837 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
840840 nonce uint64
841841 )
842842 backend := newTestBackend (t , genBlocks , genesis , func (i int , b * core.BlockGen ) {
@@ -849,8 +849,8 @@ func TestTraceChain(t *testing.T) {
849849 nonce += 1
850850 }
851851 })
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 ) }
854854 api := NewAPI (backend )
855855
856856 single := `{"result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}`
@@ -863,7 +863,8 @@ func TestTraceChain(t *testing.T) {
863863 {10 , 20 , nil }, // the middle chain range, blocks [11, 20]
864864 }
865865 for _ , c := range cases {
866- ref , rel = 0 , 0 // clean up the counters
866+ ref .Store (0 )
867+ rel .Store (0 )
867868
868869 from , _ := api .blockByNumber (context .Background (), rpc .BlockNumber (c .start ))
869870 to , _ := api .blockByNumber (context .Background (), rpc .BlockNumber (c .end ))
@@ -888,8 +889,9 @@ func TestTraceChain(t *testing.T) {
888889 if next != c .end + 1 {
889890 t .Error ("Missing tracing block" )
890891 }
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 )
893895 }
894896 }
895897}
0 commit comments