Skip to content

Commit ac8a237

Browse files
authored
Merge pull request #795 from lightninglabs/load-test-stability
itest: use configurable timeout for load test
2 parents a6415f8 + b6c327b commit ac8a237

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

itest/assertions.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,19 @@ func AssertAddrEvent(t *testing.T, client taprpc.TaprootAssetsClient,
688688
addr *taprpc.Addr, numEvents int,
689689
expectedStatus taprpc.AddrEventStatus) {
690690

691+
AssertAddrEventCustomTimeout(
692+
t, client, addr, numEvents, expectedStatus, defaultWaitTimeout,
693+
)
694+
}
695+
696+
// AssertAddrEventCustomTimeout makes sure the given address was detected by
697+
// the given daemon within the given timeout.
698+
func AssertAddrEventCustomTimeout(t *testing.T,
699+
client taprpc.TaprootAssetsClient, addr *taprpc.Addr, numEvents int,
700+
expectedStatus taprpc.AddrEventStatus, timeout time.Duration) {
701+
691702
ctxb := context.Background()
692-
ctxt, cancel := context.WithTimeout(ctxb, defaultWaitTimeout)
703+
ctxt, cancel := context.WithTimeout(ctxb, timeout)
693704
defer cancel()
694705

695706
err := wait.NoError(func() error {
@@ -717,7 +728,7 @@ func AssertAddrEvent(t *testing.T, client taprpc.TaprootAssetsClient,
717728
t.Logf("Got address event %s", eventJSON)
718729

719730
return nil
720-
}, defaultWaitTimeout)
731+
}, timeout)
721732
require.NoError(t, err)
722733
}
723734

itest/loadtest/send_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
prand "math/rand"
77
"testing"
8+
"time"
89

910
"github.com/btcsuite/btcd/rpcclient"
1011
"github.com/lightninglabs/taproot-assets/itest"
@@ -44,7 +45,7 @@ func sendTest(t *testing.T, ctx context.Context, cfg *Config) {
4445

4546
sendAssets(
4647
t, ctxt, cfg.NumAssets, cfg.SendType, send, receive,
47-
bitcoinClient,
48+
bitcoinClient, cfg.TestTimeout,
4849
)
4950

5051
t.Logf("Finished %d of %d send operations", i, cfg.NumSends)
@@ -55,7 +56,7 @@ func sendTest(t *testing.T, ctx context.Context, cfg *Config) {
5556
// node to the other node.
5657
func sendAssets(t *testing.T, ctx context.Context, numAssets uint64,
5758
assetType taprpc.AssetType, send, receive *rpcClient,
58-
bitcoinClient *rpcclient.Client) {
59+
bitcoinClient *rpcclient.Client, timeout time.Duration) {
5960

6061
// Query the asset we'll be sending, so we can assert some things about
6162
// it later.
@@ -91,16 +92,20 @@ func sendAssets(t *testing.T, ctx context.Context, numAssets uint64,
9192
require.Eventually(t, func() bool {
9293
newTransfers := send.listTransfersSince(t, ctx, transfersBefore)
9394
return len(newTransfers) == 1
94-
}, defaultTimeout, wait.PollInterval)
95+
}, timeout, wait.PollInterval)
9596

9697
// And for it to be detected on the receiving node.
97-
itest.AssertAddrEvent(t, receive, addr, 1, statusDetected)
98+
itest.AssertAddrEventCustomTimeout(
99+
t, receive, addr, 1, statusDetected, timeout,
100+
)
98101

99102
// Mine a block to confirm the transfer.
100103
itest.MineBlocks(t, bitcoinClient, 1, 1)
101104

102105
// Now the transfer should go to completed eventually.
103-
itest.AssertAddrEvent(t, receive, addr, 1, statusCompleted)
106+
itest.AssertAddrEventCustomTimeout(
107+
t, receive, addr, 1, statusCompleted, timeout,
108+
)
104109
}
105110

106111
// pickSendNode picks a node at random, checks whether it has enough assets of

0 commit comments

Comments
 (0)