From a3093628ae8235cf5e9e5a152fbedd7c8a805857 Mon Sep 17 00:00:00 2001 From: Will Winder Date: Wed, 21 Jun 2023 15:12:23 -0400 Subject: [PATCH 1/6] Disable body limit middleware for admin endpoints. --- daemon/algod/api/server/router.go | 28 +++++++------ daemon/algod/api/server/router_test.go | 57 ++++++++++++++++---------- 2 files changed, 52 insertions(+), 33 deletions(-) diff --git a/daemon/algod/api/server/router.go b/daemon/algod/api/server/router.go index 6797bd988c..c2f72b01b7 100644 --- a/daemon/algod/api/server/router.go +++ b/daemon/algod/api/server/router.go @@ -79,8 +79,13 @@ func NewRouter(logger logging.Logger, node APINodeInterface, shutdown <-chan str if err := tokens.ValidateAPIToken(adminAPIToken); err != nil { logger.Errorf("Invalid adminAPIToken was passed to NewRouter ('%s'): %v", adminAPIToken, err) } - adminAuthenticator := middlewares.MakeAuth(TokenHeader, []string{adminAPIToken}) - apiAuthenticator := middlewares.MakeAuth(TokenHeader, []string{adminAPIToken, apiToken}) + adminMiddleware := []echo.MiddlewareFunc{ + middlewares.MakeAuth(TokenHeader, []string{adminAPIToken}), + } + publicMiddleware := []echo.MiddlewareFunc{ + middleware.BodyLimit(maxRequestBodyBytes), + middlewares.MakeAuth(TokenHeader, []string{adminAPIToken, apiToken}), + } e := echo.New() @@ -93,7 +98,6 @@ func NewRouter(logger logging.Logger, node APINodeInterface, shutdown <-chan str e.Use( middlewares.MakeLogger(logger), middlewares.MakeCORS(TokenHeader), - middleware.BodyLimit(maxRequestBodyBytes), ) // Request Context @@ -104,14 +108,14 @@ func NewRouter(logger logging.Logger, node APINodeInterface, shutdown <-chan str // Route pprof requests to DefaultServeMux. // The auth middleware removes /urlAuth/:token so that it can be routed correctly. if node.Config().EnableProfiler { - e.GET("/debug/pprof/*", echo.WrapHandler(http.DefaultServeMux), adminAuthenticator) - e.GET(fmt.Sprintf("%s/debug/pprof/*", middlewares.URLAuthPrefix), echo.WrapHandler(http.DefaultServeMux), adminAuthenticator) + e.GET("/debug/pprof/*", echo.WrapHandler(http.DefaultServeMux), adminMiddleware...) + e.GET(fmt.Sprintf("%s/debug/pprof/*", middlewares.URLAuthPrefix), echo.WrapHandler(http.DefaultServeMux), adminMiddleware...) } // Registering common routes (no auth) registerHandlers(e, "", common.Routes, ctx) // Registering v1 routes - registerHandlers(e, apiV1Tag, routes.V1Routes, ctx, apiAuthenticator) + registerHandlers(e, apiV1Tag, routes.V1Routes, ctx, publicMiddleware...) // Registering v2 routes v2Handler := v2.Handlers{ @@ -119,17 +123,17 @@ func NewRouter(logger logging.Logger, node APINodeInterface, shutdown <-chan str Log: logger, Shutdown: shutdown, } - nppublic.RegisterHandlers(e, &v2Handler, apiAuthenticator) - npprivate.RegisterHandlers(e, &v2Handler, adminAuthenticator) - ppublic.RegisterHandlers(e, &v2Handler, apiAuthenticator) - pprivate.RegisterHandlers(e, &v2Handler, adminAuthenticator) + nppublic.RegisterHandlers(e, &v2Handler, publicMiddleware...) + npprivate.RegisterHandlers(e, &v2Handler, adminMiddleware...) + ppublic.RegisterHandlers(e, &v2Handler, publicMiddleware...) + pprivate.RegisterHandlers(e, &v2Handler, adminMiddleware...) if node.Config().EnableFollowMode { - data.RegisterHandlers(e, &v2Handler, apiAuthenticator) + data.RegisterHandlers(e, &v2Handler, publicMiddleware...) } if node.Config().EnableExperimentalAPI { - experimental.RegisterHandlers(e, &v2Handler, apiAuthenticator) + experimental.RegisterHandlers(e, &v2Handler, publicMiddleware...) } return e diff --git a/daemon/algod/api/server/router_test.go b/daemon/algod/api/server/router_test.go index 98e772f276..5905070ba5 100644 --- a/daemon/algod/api/server/router_test.go +++ b/daemon/algod/api/server/router_test.go @@ -16,28 +16,23 @@ package server import ( + "fmt" "net/http" "net/http/httptest" + "strings" "testing" - "github.com/labstack/echo/v4" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/suite" - "github.com/algorand/go-algorand/daemon/algod/api/server/lib" "github.com/algorand/go-algorand/daemon/algod/api/server/v1/routes" + "github.com/labstack/echo/v4" + "github.com/stretchr/testify/assert" "github.com/algorand/go-algorand/logging" "github.com/algorand/go-algorand/test/partitiontest" ) -type TestSuite struct { - suite.Suite - e *echo.Echo -} - -func (s *TestSuite) SetupSuite() { - s.e = echo.New() +func setupRouter() *echo.Echo { + e := echo.New() // Make a deep copy of the routes array with handlers. v1RoutesCopy := make([]lib.Route, len(routes.V1Routes)) for _, route := range routes.V1Routes { @@ -51,10 +46,14 @@ func (s *TestSuite) SetupSuite() { // Make a ReqContext with an initialized logger to prevent nil dereferencing. reqCtx := lib.ReqContext{Log: logging.NewLogger()} // Registering v1 routes - registerHandlers(s.e, apiV1Tag, v1RoutesCopy, reqCtx) + registerHandlers(e, apiV1Tag, v1RoutesCopy, reqCtx) + + return e } -func (s *TestSuite) TestGetTransactionV1Sunset() { +func TestGetTransactionV1Sunset(t *testing.T) { + partitiontest.PartitionTest(t) + testCases := []struct { path string route string @@ -67,21 +66,37 @@ func (s *TestSuite) TestGetTransactionV1Sunset() { } rec := httptest.NewRecorder() - ctx := s.e.NewContext(nil, rec) + e := setupRouter() + ctx := e.NewContext(nil, rec) for _, testCase := range testCases { - s.e.Router().Find(http.MethodGet, testCase.path, ctx) - assert.Equal(s.T(), testCase.route, ctx.Path()) + e.Router().Find(http.MethodGet, testCase.path, ctx) + assert.Equal(t, testCase.route, ctx.Path()) // Check that router correctly routes to the v1Sunset handler. - assert.Equal(s.T(), nil, ctx.Handler()(ctx)) - assert.NotNil(s.T(), rec.Body) - assert.Equal(s.T(), http.StatusGone, rec.Code) + assert.Equal(t, nil, ctx.Handler()(ctx)) + assert.NotNil(t, rec.Body) + assert.Equal(t, http.StatusGone, rec.Code) } } -func TestTestSuite(t *testing.T) { +func TestLargeKeyRegister(t *testing.T) { partitiontest.PartitionTest(t) - suite.Run(t, new(TestSuite)) + t.Parallel() + + rec := httptest.NewRecorder() + e := setupRouter() + + // TODO: Make sure this fails without the change + assert.Equal(t, "10MB", maxRequestBodyBytes) + stringReader := strings.NewReader(strings.Repeat("a", 50_000_000)) + req, err := http.NewRequest(http.MethodPost, "/v2/participation", stringReader) + assert.NoError(t, err) + + e.ServeHTTP(rec, req) + fmt.Println(rec.Body) +} + +func TestTestSuite(t *testing.T) { } From 0b709ef166ce63f8e256a9a38787014ae6eabd37 Mon Sep 17 00:00:00 2001 From: Will Winder Date: Wed, 21 Jun 2023 15:14:59 -0400 Subject: [PATCH 2/6] Try starting the server. --- daemon/algod/api/server/router_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/daemon/algod/api/server/router_test.go b/daemon/algod/api/server/router_test.go index 5905070ba5..ae7e2b202a 100644 --- a/daemon/algod/api/server/router_test.go +++ b/daemon/algod/api/server/router_test.go @@ -87,15 +87,16 @@ func TestLargeKeyRegister(t *testing.T) { rec := httptest.NewRecorder() e := setupRouter() + go e.Start(":9999") // TODO: Make sure this fails without the change assert.Equal(t, "10MB", maxRequestBodyBytes) stringReader := strings.NewReader(strings.Repeat("a", 50_000_000)) - req, err := http.NewRequest(http.MethodPost, "/v2/participation", stringReader) + req, err := http.NewRequest(http.MethodPost, "localhost:9999/v2/participation", stringReader) assert.NoError(t, err) e.ServeHTTP(rec, req) - fmt.Println(rec.Body) + fmt.Println(rec.Body.String()) } func TestTestSuite(t *testing.T) { From 37cd508778ad2dd277670784804af9655c15114a Mon Sep 17 00:00:00 2001 From: shiqizng <80276844+shiqizng@users.noreply.github.com> Date: Wed, 21 Jun 2023 20:43:39 -0400 Subject: [PATCH 3/6] EntityTooLarge error (#22) * create a test for EntityTooLarge error * move request body limit to test * move test to v2 * update request str --- daemon/algod/api/server/router_test.go | 27 +------- .../algod/api/server/v2/test/handlers_test.go | 66 ++++++++++++++++++- daemon/algod/api/server/v2/test/helpers.go | 2 +- 3 files changed, 68 insertions(+), 27 deletions(-) diff --git a/daemon/algod/api/server/router_test.go b/daemon/algod/api/server/router_test.go index ae7e2b202a..e3c98e765f 100644 --- a/daemon/algod/api/server/router_test.go +++ b/daemon/algod/api/server/router_test.go @@ -16,19 +16,16 @@ package server import ( - "fmt" "net/http" "net/http/httptest" - "strings" "testing" "github.com/algorand/go-algorand/daemon/algod/api/server/lib" "github.com/algorand/go-algorand/daemon/algod/api/server/v1/routes" - "github.com/labstack/echo/v4" - "github.com/stretchr/testify/assert" - "github.com/algorand/go-algorand/logging" "github.com/algorand/go-algorand/test/partitiontest" + "github.com/labstack/echo/v4" + "github.com/stretchr/testify/assert" ) func setupRouter() *echo.Echo { @@ -47,7 +44,6 @@ func setupRouter() *echo.Echo { reqCtx := lib.ReqContext{Log: logging.NewLogger()} // Registering v1 routes registerHandlers(e, apiV1Tag, v1RoutesCopy, reqCtx) - return e } @@ -80,24 +76,5 @@ func TestGetTransactionV1Sunset(t *testing.T) { } } - -func TestLargeKeyRegister(t *testing.T) { - partitiontest.PartitionTest(t) - t.Parallel() - - rec := httptest.NewRecorder() - e := setupRouter() - go e.Start(":9999") - - // TODO: Make sure this fails without the change - assert.Equal(t, "10MB", maxRequestBodyBytes) - stringReader := strings.NewReader(strings.Repeat("a", 50_000_000)) - req, err := http.NewRequest(http.MethodPost, "localhost:9999/v2/participation", stringReader) - assert.NoError(t, err) - - e.ServeHTTP(rec, req) - fmt.Println(rec.Body.String()) -} - func TestTestSuite(t *testing.T) { } diff --git a/daemon/algod/api/server/v2/test/handlers_test.go b/daemon/algod/api/server/v2/test/handlers_test.go index e30169b4ad..2d08907d0f 100644 --- a/daemon/algod/api/server/v2/test/handlers_test.go +++ b/daemon/algod/api/server/v2/test/handlers_test.go @@ -30,10 +30,15 @@ import ( "testing" "time" + "github.com/algorand/go-algorand/daemon/algod/api/server/lib/middlewares" + npprivate "github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated/nonparticipating/private" + nppublic "github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated/nonparticipating/public" + pprivate "github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated/participating/private" + ppublic "github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated/participating/public" "github.com/algorand/go-algorand/ledger/eval" "github.com/algorand/go-algorand/ledger/ledgercore" - "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4/middleware" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -2203,3 +2208,62 @@ func TestDeltasForTxnGroup(t *testing.T) { require.NoError(t, err) require.Equal(t, 501, rec.Code) } + +func TestLargeKeyRegister(t *testing.T) { + partitiontest.PartitionTest(t) + t.Parallel() + + numAccounts := 1 + numTransactions := 1 + offlineAccounts := true + mockLedger, _, _, _, _ := testingenv(t, numAccounts, numTransactions, offlineAccounts) + mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden, false) + dummyShutdownChan := make(chan struct{}) + handler := v2.Handlers{ + Node: mockNode, + Log: logging.Base(), + Shutdown: dummyShutdownChan, + } + + rec := httptest.NewRecorder() + e := echo.New() + // set request body limit + e.Use( + middleware.BodyLimit("10MB"), + ) + + // Registering v2 routes + adminMiddleware := []echo.MiddlewareFunc{ + middlewares.MakeAuth("X-Algo-API-Token", []string{""}), + } + publicMiddleware := []echo.MiddlewareFunc{ + middleware.BodyLimit("10MB"), + middlewares.MakeAuth("X-Algo-API-Token", []string{""}), + } + nppublic.RegisterHandlers(e, &handler, publicMiddleware...) + npprivate.RegisterHandlers(e, &handler, adminMiddleware...) + ppublic.RegisterHandlers(e, &handler, publicMiddleware...) + pprivate.RegisterHandlers(e, &handler, adminMiddleware...) + + go e.Start(":9999") + stringReader := strings.NewReader(strings.Repeat("a", 50_000_000)) + req, err := http.NewRequest(http.MethodPost, "http://localhost:9999/v2/participation", stringReader) + assert.NoError(t, err) + e.ServeHTTP(rec, req) + assert.Equal(t, http.StatusRequestEntityTooLarge, rec.Code) + e.Close() + + //start a new server without request body limit + rec2 := httptest.NewRecorder() + s := echo.New() + nppublic.RegisterHandlers(s, &handler, publicMiddleware...) + npprivate.RegisterHandlers(s, &handler, adminMiddleware...) + ppublic.RegisterHandlers(s, &handler, publicMiddleware...) + pprivate.RegisterHandlers(s, &handler, adminMiddleware...) + go s.Start(":9998") + req, err = http.NewRequest(http.MethodPost, "http://localhost:9998/v2/participation", stringReader) + assert.NoError(t, err) + s.ServeHTTP(rec2, req) + assert.Equal(t, http.StatusOK, rec2.Code) + s.Close() +} diff --git a/daemon/algod/api/server/v2/test/helpers.go b/daemon/algod/api/server/v2/test/helpers.go index d9fe08ed82..aef8051484 100644 --- a/daemon/algod/api/server/v2/test/helpers.go +++ b/daemon/algod/api/server/v2/test/helpers.go @@ -102,7 +102,7 @@ type mockNode struct { } func (m *mockNode) InstallParticipationKey(partKeyBinary []byte) (account.ParticipationID, error) { - panic("implement me") + return account.ParticipationID{}, nil } func (m *mockNode) ListParticipationKeys() ([]account.ParticipationRecord, error) { From 49e7f9eb2ff8f6378ae995fcecff366ec3fb49d1 Mon Sep 17 00:00:00 2001 From: Will Winder Date: Wed, 21 Jun 2023 21:25:30 -0400 Subject: [PATCH 4/6] Update test. --- daemon/algod/api/server/router.go | 6 +- daemon/algod/api/server/router_test.go | 2 - .../algod/api/server/v2/test/handlers_test.go | 76 ++++++------------- 3 files changed, 27 insertions(+), 57 deletions(-) diff --git a/daemon/algod/api/server/router.go b/daemon/algod/api/server/router.go index c2f72b01b7..b599194ab3 100644 --- a/daemon/algod/api/server/router.go +++ b/daemon/algod/api/server/router.go @@ -51,8 +51,8 @@ const ( apiV1Tag = "/v1" // TokenHeader is the header where we put the token. TokenHeader = "X-Algo-API-Token" - // maxRequestBodyBytes is the maximum request body size that we allow in our APIs. - maxRequestBodyBytes = "10MB" + // MaxRequestBodyBytes is the maximum request body size that we allow in our APIs. + MaxRequestBodyBytes = "10MB" ) // wrapCtx passes a common context to each request without a global variable. @@ -83,7 +83,7 @@ func NewRouter(logger logging.Logger, node APINodeInterface, shutdown <-chan str middlewares.MakeAuth(TokenHeader, []string{adminAPIToken}), } publicMiddleware := []echo.MiddlewareFunc{ - middleware.BodyLimit(maxRequestBodyBytes), + middleware.BodyLimit(MaxRequestBodyBytes), middlewares.MakeAuth(TokenHeader, []string{adminAPIToken, apiToken}), } diff --git a/daemon/algod/api/server/router_test.go b/daemon/algod/api/server/router_test.go index e3c98e765f..9b763e7da8 100644 --- a/daemon/algod/api/server/router_test.go +++ b/daemon/algod/api/server/router_test.go @@ -76,5 +76,3 @@ func TestGetTransactionV1Sunset(t *testing.T) { } } -func TestTestSuite(t *testing.T) { -} diff --git a/daemon/algod/api/server/v2/test/handlers_test.go b/daemon/algod/api/server/v2/test/handlers_test.go index 2d08907d0f..28d07457aa 100644 --- a/daemon/algod/api/server/v2/test/handlers_test.go +++ b/daemon/algod/api/server/v2/test/handlers_test.go @@ -30,15 +30,10 @@ import ( "testing" "time" - "github.com/algorand/go-algorand/daemon/algod/api/server/lib/middlewares" - npprivate "github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated/nonparticipating/private" - nppublic "github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated/nonparticipating/public" - pprivate "github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated/participating/private" - ppublic "github.com/algorand/go-algorand/daemon/algod/api/server/v2/generated/participating/public" + "github.com/algorand/go-algorand/daemon/algod/api/server" "github.com/algorand/go-algorand/ledger/eval" "github.com/algorand/go-algorand/ledger/ledgercore" "github.com/labstack/echo/v4" - "github.com/labstack/echo/v4/middleware" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -2209,61 +2204,38 @@ func TestDeltasForTxnGroup(t *testing.T) { require.Equal(t, 501, rec.Code) } -func TestLargeKeyRegister(t *testing.T) { +func TestRouterRequestBody(t *testing.T) { partitiontest.PartitionTest(t) t.Parallel() - numAccounts := 1 - numTransactions := 1 - offlineAccounts := true - mockLedger, _, _, _, _ := testingenv(t, numAccounts, numTransactions, offlineAccounts) + mockLedger, _, _, _, _ := testingenv(t, 1, 1, true) mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden, false) dummyShutdownChan := make(chan struct{}) - handler := v2.Handlers{ - Node: mockNode, - Log: logging.Base(), - Shutdown: dummyShutdownChan, - } - - rec := httptest.NewRecorder() - e := echo.New() - // set request body limit - e.Use( - middleware.BodyLimit("10MB"), - ) + e := server.NewRouter(logging.TestingLog(t), mockNode, dummyShutdownChan, "", "", nil, 1000) + go e.Start(":0") + defer e.Close() - // Registering v2 routes - adminMiddleware := []echo.MiddlewareFunc{ - middlewares.MakeAuth("X-Algo-API-Token", []string{""}), - } - publicMiddleware := []echo.MiddlewareFunc{ - middleware.BodyLimit("10MB"), - middlewares.MakeAuth("X-Algo-API-Token", []string{""}), - } - nppublic.RegisterHandlers(e, &handler, publicMiddleware...) - npprivate.RegisterHandlers(e, &handler, adminMiddleware...) - ppublic.RegisterHandlers(e, &handler, publicMiddleware...) - pprivate.RegisterHandlers(e, &handler, adminMiddleware...) + // wait for server to start + require.Eventually(t, func() bool { return e.Listener != nil }, 5*time.Second, 100*time.Millisecond) - go e.Start(":9999") + // Admin API call greater than max body bytes should succeed + assert.Equal(t, "10MB", server.MaxRequestBodyBytes) stringReader := strings.NewReader(strings.Repeat("a", 50_000_000)) - req, err := http.NewRequest(http.MethodPost, "http://localhost:9999/v2/participation", stringReader) + fmt.Println(e.Listener) + fmt.Println(e.Listener.Addr()) + fmt.Println(e.Listener.Addr().String()) + req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("https://%s/v2/participation", e.Listener.Addr().String()), stringReader) + assert.NoError(t, err) + rec := httptest.NewRecorder() + e.ServeHTTP(rec, req) + assert.Equal(t, http.StatusOK, rec.Code) + + // Public API call greater than max body bytes fails + assert.Equal(t, "10MB", server.MaxRequestBodyBytes) + stringReader = strings.NewReader(strings.Repeat("a", 50_000_000)) + req, err = http.NewRequest(http.MethodPost, fmt.Sprintf("https://%s/v2/transactions", e.Listener.Addr().String()), stringReader) assert.NoError(t, err) + rec = httptest.NewRecorder() e.ServeHTTP(rec, req) assert.Equal(t, http.StatusRequestEntityTooLarge, rec.Code) - e.Close() - - //start a new server without request body limit - rec2 := httptest.NewRecorder() - s := echo.New() - nppublic.RegisterHandlers(s, &handler, publicMiddleware...) - npprivate.RegisterHandlers(s, &handler, adminMiddleware...) - ppublic.RegisterHandlers(s, &handler, publicMiddleware...) - pprivate.RegisterHandlers(s, &handler, adminMiddleware...) - go s.Start(":9998") - req, err = http.NewRequest(http.MethodPost, "http://localhost:9998/v2/participation", stringReader) - assert.NoError(t, err) - s.ServeHTTP(rec2, req) - assert.Equal(t, http.StatusOK, rec2.Code) - s.Close() } From f3921c27ea6cdc0d3515c13723b91576df277bb2 Mon Sep 17 00:00:00 2001 From: Will Winder Date: Thu, 22 Jun 2023 09:13:08 -0400 Subject: [PATCH 5/6] Fix data race. --- daemon/algod/api/server/v2/test/handlers_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/daemon/algod/api/server/v2/test/handlers_test.go b/daemon/algod/api/server/v2/test/handlers_test.go index 28d07457aa..a2da2f5b94 100644 --- a/daemon/algod/api/server/v2/test/handlers_test.go +++ b/daemon/algod/api/server/v2/test/handlers_test.go @@ -24,6 +24,7 @@ import ( "fmt" "io" "math" + "net" "net/http" "net/http/httptest" "strings" @@ -2211,13 +2212,11 @@ func TestRouterRequestBody(t *testing.T) { mockLedger, _, _, _, _ := testingenv(t, 1, 1, true) mockNode := makeMockNode(mockLedger, t.Name(), nil, cannedStatusReportGolden, false) dummyShutdownChan := make(chan struct{}) - e := server.NewRouter(logging.TestingLog(t), mockNode, dummyShutdownChan, "", "", nil, 1000) + l, err := net.Listen("tcp", ":0") // create listener so requests are buffered + e := server.NewRouter(logging.TestingLog(t), mockNode, dummyShutdownChan, "", "", l, 1000) go e.Start(":0") defer e.Close() - // wait for server to start - require.Eventually(t, func() bool { return e.Listener != nil }, 5*time.Second, 100*time.Millisecond) - // Admin API call greater than max body bytes should succeed assert.Equal(t, "10MB", server.MaxRequestBodyBytes) stringReader := strings.NewReader(strings.Repeat("a", 50_000_000)) From 63c1b1e6476397e0f5b9a8de9cef82af522099b2 Mon Sep 17 00:00:00 2001 From: Will Winder Date: Thu, 22 Jun 2023 10:06:36 -0400 Subject: [PATCH 6/6] Remove debug output. --- daemon/algod/api/server/router_test.go | 6 +++--- daemon/algod/api/server/v2/test/handlers_test.go | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/daemon/algod/api/server/router_test.go b/daemon/algod/api/server/router_test.go index 9b763e7da8..37fc3be74a 100644 --- a/daemon/algod/api/server/router_test.go +++ b/daemon/algod/api/server/router_test.go @@ -20,12 +20,13 @@ import ( "net/http/httptest" "testing" + "github.com/labstack/echo/v4" + "github.com/stretchr/testify/assert" + "github.com/algorand/go-algorand/daemon/algod/api/server/lib" "github.com/algorand/go-algorand/daemon/algod/api/server/v1/routes" "github.com/algorand/go-algorand/logging" "github.com/algorand/go-algorand/test/partitiontest" - "github.com/labstack/echo/v4" - "github.com/stretchr/testify/assert" ) func setupRouter() *echo.Echo { @@ -74,5 +75,4 @@ func TestGetTransactionV1Sunset(t *testing.T) { assert.NotNil(t, rec.Body) assert.Equal(t, http.StatusGone, rec.Code) } - } diff --git a/daemon/algod/api/server/v2/test/handlers_test.go b/daemon/algod/api/server/v2/test/handlers_test.go index a2da2f5b94..a4625d41c0 100644 --- a/daemon/algod/api/server/v2/test/handlers_test.go +++ b/daemon/algod/api/server/v2/test/handlers_test.go @@ -2220,9 +2220,6 @@ func TestRouterRequestBody(t *testing.T) { // Admin API call greater than max body bytes should succeed assert.Equal(t, "10MB", server.MaxRequestBodyBytes) stringReader := strings.NewReader(strings.Repeat("a", 50_000_000)) - fmt.Println(e.Listener) - fmt.Println(e.Listener.Addr()) - fmt.Println(e.Listener.Addr().String()) req, err := http.NewRequest(http.MethodPost, fmt.Sprintf("https://%s/v2/participation", e.Listener.Addr().String()), stringReader) assert.NoError(t, err) rec := httptest.NewRecorder()