From 41859814b15d6c087d174fa9fd5c37d07f0f7234 Mon Sep 17 00:00:00 2001 From: Marcin Wolny Date: Tue, 20 Feb 2024 11:29:19 +0100 Subject: [PATCH] Clean up obsolete code --- internal/rpcgateway/rpcgateway_test.go | 15 +++++---------- internal/rpcgateway/test_utils.go | 23 ----------------------- 2 files changed, 5 insertions(+), 33 deletions(-) delete mode 100644 internal/rpcgateway/test_utils.go diff --git a/internal/rpcgateway/rpcgateway_test.go b/internal/rpcgateway/rpcgateway_test.go index e6f58cf..f214451 100644 --- a/internal/rpcgateway/rpcgateway_test.go +++ b/internal/rpcgateway/rpcgateway_test.go @@ -3,7 +3,6 @@ package rpcgateway import ( "bytes" "context" - "fmt" "html/template" "io" "net/http" @@ -58,15 +57,11 @@ type TestURL struct { func TestRpcGatewayFailover(t *testing.T) { prometheus.DefaultRegisterer = prometheus.NewRegistry() - // RPC backends setup - onReq := func(r *http.Request) { - fmt.Println("got request") - } - rpcBackend := &responder{ - value: []byte(`{"jsonrpc":"2.0","id":1,"result":"0xd8d7df"}`), - onRequest: onReq, - } - ts := httptest.NewServer(rpcBackend) + ts := httptest.NewServer( + http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte(`{"jsonrpc":"2.0","id":1,"result":"0xd8d7df"}`)) + w.WriteHeader(http.StatusOK) + })) defer ts.Close() // Toxic Proxy setup diff --git a/internal/rpcgateway/test_utils.go b/internal/rpcgateway/test_utils.go deleted file mode 100644 index b43a68c..0000000 --- a/internal/rpcgateway/test_utils.go +++ /dev/null @@ -1,23 +0,0 @@ -package rpcgateway - -import ( - "net/http" -) - -type responder struct { - value []byte - onRequest func(*http.Request) -} - -func (r *responder) SetValue(value []byte) { - r.value = value -} - -func (r *responder) OnRequest(function func(*http.Request)) { - r.onRequest = function -} - -func (r *responder) ServeHTTP(w http.ResponseWriter, req *http.Request) { - r.onRequest(req) - w.Write(r.value) -}