itest: remove loop in wsTestCaseBiDirectionalSubscription

So we know which open channel operation failed.
This commit is contained in:
yyforyongyu 2024-10-31 07:29:28 +08:00
parent 782edde213
commit c07162603d
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868

View File

@ -440,7 +440,6 @@ func wsTestCaseBiDirectionalSubscription(ht *lntest.HarnessTest) {
msgChan := make(chan *lnrpc.ChannelAcceptResponse, 1) msgChan := make(chan *lnrpc.ChannelAcceptResponse, 1)
errChan := make(chan error) errChan := make(chan error)
done := make(chan struct{}) done := make(chan struct{})
timeout := time.After(defaultTimeout)
// We want to read messages over and over again. We just accept any // We want to read messages over and over again. We just accept any
// channels that are opened. // channels that are opened.
@ -506,6 +505,7 @@ func wsTestCaseBiDirectionalSubscription(ht *lntest.HarnessTest) {
} }
return return
} }
ht.Logf("Finish writing message %s", resMsg)
// Also send the message on our message channel to make // Also send the message on our message channel to make
// sure we count it as successful. // sure we count it as successful.
@ -525,23 +525,27 @@ func wsTestCaseBiDirectionalSubscription(ht *lntest.HarnessTest) {
bob := ht.NewNodeWithCoins("Bob", nil) bob := ht.NewNodeWithCoins("Bob", nil)
ht.EnsureConnected(alice, bob) ht.EnsureConnected(alice, bob)
// Open 3 channels to make sure multiple requests and responses can be assertMsgReceived := func() {
// sent over the web socket.
const numChannels = 3
for i := 0; i < numChannels; i++ {
ht.OpenChannel(
bob, alice, lntest.OpenChannelParams{Amt: 500000},
)
select { select {
case <-msgChan: case <-msgChan:
case err := <-errChan: case err := <-errChan:
ht.Fatalf("Received error from WS: %v", err) ht.Fatalf("Received error from WS: %v", err)
case <-timeout: case <-time.After(defaultTimeout):
ht.Fatalf("Timeout before message was received") ht.Fatalf("Timeout before message was received")
} }
} }
// Open 3 channels to make sure multiple requests and responses can be
// sent over the web socket.
ht.OpenChannel(bob, alice, lntest.OpenChannelParams{Amt: 500000})
assertMsgReceived()
ht.OpenChannel(bob, alice, lntest.OpenChannelParams{Amt: 500000})
assertMsgReceived()
ht.OpenChannel(bob, alice, lntest.OpenChannelParams{Amt: 500000})
assertMsgReceived()
} }
func wsTestPingPongTimeout(ht *lntest.HarnessTest) { func wsTestPingPongTimeout(ht *lntest.HarnessTest) {