@ -835,8 +835,8 @@ func TestTraceChain(t *testing.T) {
signer := types . HomesteadSigner { }
signer := types . HomesteadSigner { }
var (
var (
ref u int32 // total refs has made
ref atomic . U int32 // total refs has made
rel u int32 // total rels has made
rel atomic . U int32 // total rels has made
nonce uint64
nonce uint64
)
)
backend := newTestBackend ( t , genBlocks , genesis , func ( i int , b * core . BlockGen ) {
backend := newTestBackend ( t , genBlocks , genesis , func ( i int , b * core . BlockGen ) {
@ -849,8 +849,8 @@ func TestTraceChain(t *testing.T) {
nonce += 1
nonce += 1
}
}
} )
} )
backend . refHook = func ( ) { atomic . AddUint32 ( & ref , 1 ) }
backend . refHook = func ( ) { ref . Add ( 1 ) }
backend . relHook = func ( ) { atomic . AddUint32 ( & rel , 1 ) }
backend . relHook = func ( ) { rel . Add ( 1 ) }
api := NewAPI ( backend )
api := NewAPI ( backend )
single := ` { "result": { "gas":21000,"failed":false,"returnValue":"","structLogs":[]}} `
single := ` { "result": { "gas":21000,"failed":false,"returnValue":"","structLogs":[]}} `
@ -863,7 +863,8 @@ func TestTraceChain(t *testing.T) {
{ 10 , 20 , nil } , // the middle chain range, blocks [11, 20]
{ 10 , 20 , nil } , // the middle chain range, blocks [11, 20]
}
}
for _ , c := range cases {
for _ , c := range cases {
ref , rel = 0 , 0 // clean up the counters
ref . Store ( 0 )
rel . Store ( 0 )
from , _ := api . blockByNumber ( context . Background ( ) , rpc . BlockNumber ( c . start ) )
from , _ := api . blockByNumber ( context . Background ( ) , rpc . BlockNumber ( c . start ) )
to , _ := api . blockByNumber ( context . Background ( ) , rpc . BlockNumber ( c . end ) )
to , _ := api . blockByNumber ( context . Background ( ) , rpc . BlockNumber ( c . end ) )
@ -888,8 +889,9 @@ func TestTraceChain(t *testing.T) {
if next != c . end + 1 {
if next != c . end + 1 {
t . Error ( "Missing tracing block" )
t . Error ( "Missing tracing block" )
}
}
if ref != rel {
t . Errorf ( "Ref and deref actions are not equal, ref %d rel %d" , ref , rel )
if nref , nrel := ref . Load ( ) , rel . Load ( ) ; nref != nrel {
t . Errorf ( "Ref and deref actions are not equal, ref %d rel %d" , nref , nrel )
}
}
}
}
}
}