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

Function TestHttpServer_IntegrationTests

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

Source from the content-addressed store, hash-verified

3114 })
3115}
3116func TestHttpServer_IntegrationTests(t *testing.T) {
3117 t.Run("SuccessRequestWithNoParams", func(t *testing.T) {
3118 cfg := &common.Config{
3119 Server: &common.ServerConfig{
3120 MaxTimeout: common.Duration(5 * time.Second).Ptr(),
3121 },
3122 Projects: []*common.ProjectConfig{
3123 {
3124 Id: "test_project",
3125 CORS: &common.CORSConfig{
3126 AllowedOrigins: []string{"https://erpc.cloud"},
3127 AllowedMethods: []string{"POST"},
3128 },
3129 Networks: []*common.NetworkConfig{
3130 {
3131 Architecture: common.ArchitectureEvm,
3132 Evm: &common.EvmNetworkConfig{
3133 ChainId: 123,
3134 },
3135 },
3136 },
3137 Upstreams: []*common.UpstreamConfig{
3138 {
3139 Id: "rpc1",
3140 Type: common.UpstreamTypeEvm,
3141 Endpoint: "http://rpc1.localhost",
3142 Evm: &common.EvmUpstreamConfig{
3143 ChainId: 123,
3144 },
3145 },
3146 },
3147 },
3148 },
3149 RateLimiters: &common.RateLimiterConfig{},
3150 }
3151
3152 util.ResetGock()
3153 defer util.ResetGock()
3154 util.SetupMocksForEvmStatePoller()
3155 defer util.AssertNoPendingMocks(t, 0)
3156
3157 gock.New("http://rpc1.localhost").
3158 Post("/").
3159 Filter(func(request *http.Request) bool {
3160 body := util.SafeReadBody(request)
3161 return strings.Contains(string(body), "trace_transaction")
3162 }).
3163 Reply(200).
3164 JSON(map[string]interface{}{
3165 "jsonrpc": "2.0",
3166 "id": 111,
3167 "result": "0x1111111",
3168 })
3169
3170 sendRequest, _, _, shutdown, _ := createServerTestFixtures(cfg, t)
3171 defer shutdown()
3172
3173 time.Sleep(3000 * time.Millisecond)

Callers

nothing calls this directly

Calls 9

DurationTypeAlias · 0.92
ResetGockFunction · 0.92
AssertNoPendingMocksFunction · 0.92
SafeReadBodyFunction · 0.92
createServerTestFixturesFunction · 0.85
PtrMethod · 0.80
NameMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected