Skip to content

Commit 8eb2292

Browse files
committed
Update context handling in tests and remove mux params
Signed-off-by: Satyam Zode <[email protected]>
1 parent efefde8 commit 8eb2292

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

services/friendbot/internal/friendbot_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"sync"
66
"testing"
7-
"time"
87

98
"github.com/stellar/go/txnbuild"
109

@@ -15,8 +14,8 @@ import (
1514
)
1615

1716
func TestFriendbot_Pay_accountDoesNotExist(t *testing.T) {
18-
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
19-
defer cancel()
17+
ctx := context.Background()
18+
2019
mockSubmitTransaction := func(ctx context.Context, minion *Minion, hclient horizonclient.ClientInterface, tx string) (*hProtocol.Transaction, error) {
2120
// Instead of submitting the tx, we emulate a success.
2221
txSuccess := hProtocol.Transaction{EnvelopeXdr: tx, Successful: true}
@@ -84,8 +83,7 @@ func TestFriendbot_Pay_accountDoesNotExist(t *testing.T) {
8483
}
8584

8685
func TestFriendbot_Pay_accountExists(t *testing.T) {
87-
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
88-
defer cancel()
86+
ctx := context.Background()
8987
mockSubmitTransaction := func(ctx context.Context, minion *Minion, hclient horizonclient.ClientInterface, tx string) (*hProtocol.Transaction, error) {
9088
// Instead of submitting the tx, we emulate a success.
9189
txSuccess := hProtocol.Transaction{EnvelopeXdr: tx, Successful: true}
@@ -153,8 +151,7 @@ func TestFriendbot_Pay_accountExists(t *testing.T) {
153151
}
154152

155153
func TestFriendbot_Pay_accountExistsAlreadyFunded(t *testing.T) {
156-
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
157-
defer cancel()
154+
ctx := context.Background()
158155
mockSubmitTransaction := func(ctx context.Context, minion *Minion, hclient horizonclient.ClientInterface, tx string) (*hProtocol.Transaction, error) {
159156
// Instead of submitting the tx, we emulate a success.
160157
txSuccess := hProtocol.Transaction{EnvelopeXdr: tx, Successful: true}

services/friendbot/internal/minion_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"sync"
66
"testing"
7-
"time"
87

98
"github.com/stellar/go/clients/horizonclient"
109
"github.com/stellar/go/keypair"
@@ -18,8 +17,7 @@ import (
1817
// in which Minion.Run() will try to send multiple messages to a channel that gets closed
1918
// immediately after receiving one message.
2019
func TestMinion_NoChannelErrors(t *testing.T) {
21-
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
22-
defer cancel()
20+
ctx := context.Background()
2321

2422
mockSubmitTransaction := func(ctx context.Context, minion *Minion, hclient horizonclient.ClientInterface, tx string) (txn *hProtocol.Transaction, err error) {
2523
return txn, nil
@@ -83,8 +81,7 @@ func TestMinion_NoChannelErrors(t *testing.T) {
8381
}
8482

8583
func TestMinion_CorrectNumberOfTxSubmissions(t *testing.T) {
86-
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
87-
defer cancel()
84+
ctx := context.Background()
8885

8986
var (
9087
numTxSubmits int

services/friendbot/main.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
stdhttp "net/http"
77
"os"
88

9-
"github.com/go-chi/chi/middleware"
109
"github.com/go-chi/chi/v5"
1110
"github.com/riandyrn/otelchi"
1211
"github.com/spf13/cobra"
@@ -121,12 +120,6 @@ func newMux(cfg Config) *chi.Mux {
121120
// middlewares
122121
mux.Use(http.XFFMiddleware(http.XFFMiddlewareConfig{BehindCloudflare: cfg.UseCloudflareIP}))
123122
mux.Use(http.NewAPIMux(log.DefaultLogger).Middlewares()...)
124-
125-
// Add OpenTelemetry middleware
126-
mux.Use(middleware.RequestID)
127-
mux.Use(middleware.RealIP)
128-
mux.Use(middleware.Logger)
129-
mux.Use(middleware.Recoverer)
130123
mux.Use(otelchi.Middleware(serviceName, otelchi.WithChiRoutes(mux)))
131124

132125
return mux

0 commit comments

Comments
 (0)