Skip to content

Commit 21a22de

Browse files
committed
itest: add assertMinNumHtlcs helper to check min present HTLCs
1 parent 5cbcf10 commit 21a22de

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

itest/assets_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,6 +2128,34 @@ func macFromBytes(macBytes []byte) (grpc.DialOption, error) {
21282128
return grpc.WithPerRPCCredentials(cred), nil
21292129
}
21302130

2131+
func assertMinNumHtlcs(t *testing.T, node *HarnessNode, expected int) {
2132+
t.Helper()
2133+
2134+
ctxb := context.Background()
2135+
2136+
err := wait.NoError(func() error {
2137+
listChansRequest := &lnrpc.ListChannelsRequest{}
2138+
listChansResp, err := node.ListChannels(ctxb, listChansRequest)
2139+
if err != nil {
2140+
return err
2141+
}
2142+
2143+
var numHtlcs int
2144+
for _, channel := range listChansResp.Channels {
2145+
numHtlcs += len(channel.PendingHtlcs)
2146+
}
2147+
2148+
if numHtlcs < expected {
2149+
return fmt.Errorf("expected %v HTLCs, got %v, %v",
2150+
expected, numHtlcs,
2151+
spew.Sdump(toProtoJSON(t, listChansResp)))
2152+
}
2153+
2154+
return nil
2155+
}, defaultTimeout)
2156+
require.NoError(t, err)
2157+
}
2158+
21312159
func assertNumHtlcs(t *testing.T, node *HarnessNode, expected int) {
21322160
t.Helper()
21332161

0 commit comments

Comments
 (0)