diff --git a/client.go b/client.go index 040f0ec..7f18d31 100644 --- a/client.go +++ b/client.go @@ -55,6 +55,10 @@ func (c *Client) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, return c.ethClient.EstimateGas(ctx, msg) } +func (c *Client) GetBlockNumber(ctx context.Context) (uint64, error) { + return c.ethClient.BlockNumber(ctx) +} + func (c *Client) R() *Request { r := &Request{ client: c, diff --git a/ethrpc_test.go b/ethrpc_test.go index 9e193e8..40ed0fc 100644 --- a/ethrpc_test.go +++ b/ethrpc_test.go @@ -1,6 +1,7 @@ package ethrpc import ( + "context" "fmt" "math/big" "testing" @@ -23,6 +24,13 @@ func (ts *RPCTestSuite) SetupTest() { ts.client = rpcClient } +func (ts *RPCTestSuite) TestGetBlockNumber() { + blockNumber, err := ts.client.GetBlockNumber(context.Background()) + + ts.Require().NoError(err) + ts.Require().NotEqual(0, blockNumber) +} + func (ts *RPCTestSuite) TestTryAggregate() { type TradeInfo struct { Reserve0 *big.Int