mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
add test cases and optimize
This commit is contained in:
parent
f2972eeb44
commit
e270b23766
2 changed files with 16 additions and 3 deletions
|
|
@ -234,8 +234,8 @@ func (ec *Client) TraceTransaction(ctx context.Context, hash common.Hash, config
|
|||
return result, err
|
||||
}
|
||||
|
||||
// TraceChain TraceChaiin subscribes to chain, receiving results from channel BlockTraceResult
|
||||
func (ec *Client) TraceChain(ctx context.Context, ch chan<- BlockTraceResult, start, end rpc.BlockNumber, config *tracers.TraceConfig) (*rpc.ClientSubscription, error) {
|
||||
// TraceChain subscribes to chain, receiving results from channel BlockTraceResult
|
||||
func (ec *Client) TraceChain(ctx context.Context, ch chan<- *BlockTraceResult, start, end rpc.BlockNumber, config *tracers.TraceConfig) (*rpc.ClientSubscription, error) {
|
||||
return ec.c.Subscribe(ctx, "debug", ch, "traceChain", start, end, config)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -598,6 +598,19 @@ func testTraceTransaction(t *testing.T, client *rpc.Client) {
|
|||
"structLogs": nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
txHash: testTransactionHash,
|
||||
config: &tracers.TraceConfig{
|
||||
TracerConfig: json.RawMessage(`{"tracer":"callTracer"}`),
|
||||
},
|
||||
expectErr: nil,
|
||||
expect: map[string]interface{}{
|
||||
"gas": 21000,
|
||||
"failed": false,
|
||||
"returnValue": "",
|
||||
"structLogs": nil,
|
||||
},
|
||||
},
|
||||
}
|
||||
for i, testspec := range testSuite {
|
||||
result, err := ec.TraceTransaction(context.Background(), testspec.txHash, testspec.config)
|
||||
|
|
@ -691,7 +704,7 @@ func testTraceCall(t *testing.T, client *rpc.Client) {
|
|||
func testTraceChain(t *testing.T, client *rpc.Client) {
|
||||
ec := New(client)
|
||||
|
||||
ch := make(chan BlockTraceResult)
|
||||
ch := make(chan *BlockTraceResult)
|
||||
_, err := ec.TraceChain(context.Background(), ch, 0, 1, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("testTraceChain error: %v", err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue