MCPcopy Create free account
hub / github.com/erpc/erpc / TestHttpServer_EvmGetBlockByNumber

Function TestHttpServer_EvmGetBlockByNumber

erpc/http_server_test.go:5531–7765  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5529}
5530
5531func TestHttpServer_EvmGetBlockByNumber(t *testing.T) {
5532 util.ResetGock()
5533 defer util.ResetGock()
5534
5535 t.Run("FallbackToHighestBlockIfUpstreamReturnsOlderBlock", func(t *testing.T) {
5536 // 1. Reset gock, set up poller mocks, etc.
5537 util.ResetGock()
5538 defer util.ResetGock()
5539 util.SetupMocksForEvmStatePoller()
5540
5541 // 2. Create a config with 2 upstreams and enforce highest block
5542 cfg := &common.Config{
5543 Server: &common.ServerConfig{
5544 MaxTimeout: common.Duration(5 * time.Second).Ptr(),
5545 },
5546 Projects: []*common.ProjectConfig{
5547 {
5548 Id: "test_project",
5549 Networks: []*common.NetworkConfig{
5550 {
5551 Architecture: "evm",
5552 Evm: &common.EvmNetworkConfig{
5553 ChainId: 123,
5554 Integrity: &common.EvmIntegrityConfig{
5555 EnforceHighestBlock: util.BoolPtr(true),
5556 },
5557 },
5558 },
5559 },
5560 Upstreams: []*common.UpstreamConfig{
5561 {
5562 Id: "rpc1",
5563 Endpoint: "http://rpc1.localhost",
5564 Type: common.UpstreamTypeEvm,
5565 Evm: &common.EvmUpstreamConfig{
5566 ChainId: 123,
5567 StatePollerInterval: common.Duration(10 * time.Second),
5568 },
5569 },
5570 {
5571 Id: "rpc2",
5572 Endpoint: "http://rpc2.localhost",
5573 Type: common.UpstreamTypeEvm,
5574 Evm: &common.EvmUpstreamConfig{
5575 ChainId: 123,
5576 StatePollerInterval: common.Duration(10 * time.Second),
5577 },
5578 },
5579 },
5580 },
5581 },
5582 }
5583
5584 // 3. Request: eth_getBlockByNumber("latest", true)
5585 requestBody := `{
5586 "jsonrpc": "2.0",
5587 "id": 1,
5588 "method": "eth_getBlockByNumber",

Callers

nothing calls this directly

Calls 11

ResetGockFunction · 0.92
DurationTypeAlias · 0.92
BoolPtrFunction · 0.92
OverrideAllForTestFunction · 0.92
AssertNoPendingMocksFunction · 0.92
SafeReadBodyFunction · 0.92
createServerTestFixturesFunction · 0.85
PtrMethod · 0.80
RunMethod · 0.65
GetProjectMethod · 0.45

Tested by

no test coverage detected