(t *testing.T)
| 38 | ) |
| 39 | |
| 40 | func TestHttpServer_RaceTimeouts(t *testing.T) { |
| 41 | t.Run("ConcurrentRequestsWithTimeouts", func(t *testing.T) { |
| 42 | util.ResetGock() |
| 43 | defer util.ResetGock() |
| 44 | gock.EnableNetworking() |
| 45 | gock.NetworkingFilter(func(req *http.Request) bool { |
| 46 | shouldMakeRealCall := strings.Split(req.URL.Host, ":")[0] == "localhost" |
| 47 | return shouldMakeRealCall |
| 48 | }) |
| 49 | util.SetupMocksForEvmStatePoller() |
| 50 | defer util.AssertNoPendingMocks(t, 0) |
| 51 | |
| 52 | gock.New("http://rpc1.localhost"). |
| 53 | Post("/"). |
| 54 | Times(50). |
| 55 | Reply(200). |
| 56 | Delay(2000 * time.Millisecond). // Delay longer than the server timeout |
| 57 | JSON(map[string]interface{}{ |
| 58 | "jsonrpc": "2.0", |
| 59 | "id": 1, |
| 60 | "result": "0x222222", |
| 61 | }) |
| 62 | |
| 63 | // Setup |
| 64 | logger := log.Logger |
| 65 | ctx, cancel := context.WithCancel(context.Background()) |
| 66 | defer cancel() |
| 67 | |
| 68 | cfg := &common.Config{ |
| 69 | Server: &common.ServerConfig{ |
| 70 | MaxTimeout: common.Duration(500 * time.Millisecond).Ptr(), // Set a very short timeout for testing |
| 71 | ListenV4: util.BoolPtr(true), // Explicitly enable IPv4 for test |
| 72 | }, |
| 73 | Projects: []*common.ProjectConfig{ |
| 74 | { |
| 75 | Id: "test_project", |
| 76 | Networks: []*common.NetworkConfig{ |
| 77 | { |
| 78 | Architecture: common.ArchitectureEvm, |
| 79 | Evm: &common.EvmNetworkConfig{ |
| 80 | ChainId: 123, |
| 81 | }, |
| 82 | }, |
| 83 | }, |
| 84 | Upstreams: []*common.UpstreamConfig{ |
| 85 | { |
| 86 | Type: common.UpstreamTypeEvm, |
| 87 | Endpoint: "http://rpc1.localhost", |
| 88 | Evm: &common.EvmUpstreamConfig{ |
| 89 | ChainId: 123, |
| 90 | }, |
| 91 | }, |
| 92 | }, |
| 93 | }, |
| 94 | }, |
| 95 | RateLimiters: &common.RateLimiterConfig{}, |
| 96 | } |
| 97 |
nothing calls this directly
no test coverage detected