when i write a testing for testing ethclient method based on go-ethereum codebase, i can't easily mock a ethclient, anyone can do me a favor? https://github.com/ethereum/go-ethereum/pull/18422/files

func TestClient_StorageAt(t *testing.T) {
var client *rpc.Client
type fields struct {
    c *rpc.Client
type args struct {
    ctx         context.Context
    account     common.Address
    key         common.Hash
    blockNumber *big.Int
tests := []struct {
    name    string
    fields  fields
    args    args
    want    []byte
    wantErr bool
        "call StorageAt at future block",
for _, tt := range tests {
    t.Run(tt.name, func(t *testing.T) {
        ec := &Client{
            c: tt.fields.c,
        got, err := ec.StorageAt(tt.args.ctx, tt.args.account, tt.args.key, tt.args.blockNumber)
        if (err != nil) != tt.wantErr {
            t.Errorf("Client.StorageAt() error = %v, wantErr %v", err, tt.wantErr)
        if !reflect.DeepEqual(got, tt.want) {
            t.Errorf("Client.StorageAt() = %v, want %v", got, tt.want)


i have try some methods in rpc module, but can't success.

This question had a bounty worth +50 reputation from xds2000 that ended 9 hours ago. Grace period ends in 14 hours

Looking for an answer drawing from credible and/or official sources.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.