mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
Expose eth_simulateV1 RPC method via ethclient
This commit is contained in:
parent
11208553dd
commit
053f58f966
2 changed files with 32 additions and 0 deletions
|
|
@ -36,6 +36,13 @@ type Client struct {
|
|||
c *rpc.Client
|
||||
}
|
||||
|
||||
// SimulateV1 calls the eth_simulateV1 RPC method.
|
||||
func (ec *Client) SimulateV1(ctx context.Context, opts map[string]interface{}, blockParam string) (map[string]interface{}, error) {
|
||||
var result map[string]interface{}
|
||||
err := ec.c.CallContext(ctx, &result, "eth_simulateV1", opts, blockParam)
|
||||
return result, err
|
||||
}
|
||||
|
||||
// Dial connects a client to the given URL.
|
||||
func Dial(rawurl string) (*Client, error) {
|
||||
return DialContext(context.Background(), rawurl)
|
||||
|
|
|
|||
|
|
@ -754,3 +754,28 @@ func ExampleRevertErrorData() {
|
|||
// revert: 08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000a75736572206572726f72
|
||||
// message: user error
|
||||
}
|
||||
|
||||
// Test for SimulateV1
|
||||
func TestSimulateV1(t *testing.T) {
|
||||
client := ethclient.NewClient(rpc.DialContext)
|
||||
opts := map[string]interface{}{
|
||||
"traceTransfers": true,
|
||||
"validation": true,
|
||||
"blockStateCalls": []interface{}{
|
||||
map[string]interface{}{
|
||||
"calls": []interface{}{
|
||||
map[string]interface{}{
|
||||
"from": "0x...",
|
||||
"to": "0x...",
|
||||
"data": "0x...",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
resp, err := client.SimulateV1(context.Background(), opts, "latest")
|
||||
if err != nil {
|
||||
t.Fatalf("SimulateV1 failed: %v", err)
|
||||
}
|
||||
t.Logf("Response: %+v", resp)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue