Skip to content

Commit b51d286

Browse files
committed
itest: replace wait.NoError calls with BeforeTimeout
Function `wait.NoError` will call the given target function multiple times. Whereas `BeforeTimeout` calls the given target function once. We don't want to call the target function more than once in this itest. This commit changes `wait.NoError` calls to `BeforeTimeout`.
1 parent 75da2c7 commit b51d286

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

itest/rfq_test.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,13 @@ func testRfqAssetBuyHtlcIntercept(t *harnessTest) {
101101

102102
// Wait until Carol receives an incoming quote accept message (sent from
103103
// Bob) RFQ event notification.
104-
waitErr := wait.NoError(func() error {
104+
BeforeTimeout(t.t, func() {
105105
event, err := carolEventNtfns.Recv()
106106
require.NoError(t.t, err)
107107

108108
_, ok := event.Event.(*rfqrpc.RfqEvent_PeerAcceptedBuyQuote)
109109
require.True(t.t, ok, "unexpected event: %v", event)
110-
111-
return nil
112110
}, defaultWaitTimeout)
113-
require.NoError(t.t, waitErr)
114111

115112
// Carol should have received an accepted quote from Bob. This accepted
116113
// quote can be used by Carol to make a payment to Bob.
@@ -188,25 +185,22 @@ func testRfqAssetBuyHtlcIntercept(t *harnessTest) {
188185
// At this point Bob should have received a HTLC with the asset transfer
189186
// specific scid. We'll wait for Bob to publish an accept HTLC event and
190187
// then validate it against the accepted quote.
191-
waitErr = wait.NoError(func() error {
188+
BeforeTimeout(t.t, func() {
192189
t.Log("Waiting for Bob to receive HTLC")
193190

194191
event, err := bobEventNtfns.Recv()
195192
require.NoError(t.t, err)
196193

197194
acceptHtlc, ok := event.Event.(*rfqrpc.RfqEvent_AcceptHtlc)
198-
if ok {
199-
require.Equal(
200-
t.t, acceptedQuote.Scid,
201-
acceptHtlc.AcceptHtlc.Scid,
202-
)
203-
t.Log("Bob has accepted the HTLC")
204-
return nil
205-
}
195+
require.True(t.t, ok, "unexpected event type: %v", event)
206196

207-
return fmt.Errorf("unexpected event: %v", event)
197+
// Ensure that the scid of the HTLC matches the scid of the
198+
// accepted quote.
199+
require.Equal(
200+
t.t, acceptedQuote.Scid, acceptHtlc.AcceptHtlc.Scid,
201+
)
202+
t.Log("Bob has accepted the HTLC")
208203
}, defaultWaitTimeout)
209-
require.NoError(t.t, waitErr)
210204

211205
// Close event streams.
212206
err = carolEventNtfns.CloseSend()

0 commit comments

Comments
 (0)