mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
client: ethclient_test.go
test case for checking the features which i've implemented.
This commit is contained in:
parent
8ee73c749f
commit
c3477e8e74
1 changed files with 59 additions and 0 deletions
|
|
@ -39,6 +39,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
"github.com/ethereum/go-ethereum/eth/tracers"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Verify that Client implements the ethereum interfaces.
|
// Verify that Client implements the ethereum interfaces.
|
||||||
|
|
@ -685,3 +686,61 @@ func ExampleRevertErrorData() {
|
||||||
// revert: 08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a75736572206572726f72
|
// revert: 08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a75736572206572726f72
|
||||||
// message: user error
|
// message: user error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTracing(t *testing.T) {
|
||||||
|
rpcClient := getRPCClient(t)
|
||||||
|
client := NewClient(rpcClient)
|
||||||
|
|
||||||
|
t.Run("TraceTransaction", func(t *testing.T) {
|
||||||
|
txHash := testTx1.Hash()
|
||||||
|
|
||||||
|
result, err := client.TraceTransaction(context.Background(), txHash.Hex())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to trace transaction: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.NotNil(t, result, "Trace result should not be nil")
|
||||||
|
t.Logf("Trace Transaction Result: %+v", result)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("TraceCall", func(t *testing.T) {
|
||||||
|
callArgs := map[string]interface{}{
|
||||||
|
"from": testAddr,
|
||||||
|
"to": revertContractAddr,
|
||||||
|
"data": revertCode,
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := client.TraceCall(context.Background(), callArgs)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to trace call: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.NotNil(t, result, "Trace result should not be nil")
|
||||||
|
t.Logf("Trace Call Result: %+v", result)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("TraceBlock", func(t *testing.T) {
|
||||||
|
blockHash := common.HexToHash(testKey)
|
||||||
|
|
||||||
|
result, err := client.TraceBlock(context.Background(), blockHash.Hex())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to trace block: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.NotNil(t, result, "Trace result should not be nil")
|
||||||
|
t.Logf("Trace Block Result: %+v", result)
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("TraceChain", func(t *testing.T) {
|
||||||
|
blockHash := common.HexToHash(testKey)
|
||||||
|
count := 10
|
||||||
|
|
||||||
|
result, err := client.TraceChain(context.Background(), blockHash.Hex(), count)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to trace chain: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.NotNil(t, result, "Trace result should not be nil")
|
||||||
|
t.Logf("Trace Chain Result: %+v", result)
|
||||||
|
})
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue