Skip to content

Commit 1dc72c8

Browse files
committed
Remove t.context until go 1.24
Signed-off-by: Satyam Zode <[email protected]>
1 parent 65ba471 commit 1dc72c8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

services/friendbot/internal/friendbot_test.go

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

89
"github.com/stellar/go/txnbuild"
910

@@ -14,7 +15,8 @@ import (
1415
)
1516

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

8486
func TestFriendbot_Pay_accountExists(t *testing.T) {
85-
ctx := t.Context()
87+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
88+
defer cancel()
8689
mockSubmitTransaction := func(ctx context.Context, minion *Minion, hclient horizonclient.ClientInterface, tx string) (*hProtocol.Transaction, error) {
8790
// Instead of submitting the tx, we emulate a success.
8891
txSuccess := hProtocol.Transaction{EnvelopeXdr: tx, Successful: true}

services/friendbot/internal/minion_test.go

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

89
"github.com/stellar/go/clients/horizonclient"
910
"github.com/stellar/go/keypair"
@@ -17,7 +18,9 @@ import (
1718
// in which Minion.Run() will try to send multiple messages to a channel that gets closed
1819
// immediately after receiving one message.
1920
func TestMinion_NoChannelErrors(t *testing.T) {
20-
ctx := t.Context()
21+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
22+
defer cancel()
23+
2124
mockSubmitTransaction := func(ctx context.Context, minion *Minion, hclient horizonclient.ClientInterface, tx string) (txn *hProtocol.Transaction, err error) {
2225
return txn, nil
2326
}
@@ -80,7 +83,8 @@ func TestMinion_NoChannelErrors(t *testing.T) {
8083
}
8184

8285
func TestMinion_CorrectNumberOfTxSubmissions(t *testing.T) {
83-
ctx := t.Context()
86+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
87+
defer cancel()
8488

8589
var (
8690
numTxSubmits int

0 commit comments

Comments
 (0)