Skip to content

Commit 9c98b18

Browse files
GeorgeTsagkguggero
authored andcommitted
itest: add assertMinNumHtlcs helper to check min present HTLCs
This new helper will be useful to check that a payment attempt produced actual HTLCs that got added over a channel. This will be used in a follow-up commit to verify that the attempt was truly carried out.
1 parent f664d75 commit 9c98b18

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
@@ -2292,6 +2292,34 @@ func macFromBytes(macBytes []byte) (grpc.DialOption, error) {
22922292
return grpc.WithPerRPCCredentials(cred), nil
22932293
}
22942294

2295+
func assertMinNumHtlcs(t *testing.T, node *HarnessNode, expected int) {
2296+
t.Helper()
2297+
2298+
ctxb := context.Background()
2299+
2300+
err := wait.NoError(func() error {
2301+
listChansRequest := &lnrpc.ListChannelsRequest{}
2302+
listChansResp, err := node.ListChannels(ctxb, listChansRequest)
2303+
if err != nil {
2304+
return err
2305+
}
2306+
2307+
var numHtlcs int
2308+
for _, channel := range listChansResp.Channels {
2309+
numHtlcs += len(channel.PendingHtlcs)
2310+
}
2311+
2312+
if numHtlcs < expected {
2313+
return fmt.Errorf("expected %v HTLCs, got %v, %v",
2314+
expected, numHtlcs,
2315+
toProtoJSON(t, listChansResp))
2316+
}
2317+
2318+
return nil
2319+
}, defaultTimeout)
2320+
require.NoError(t, err)
2321+
}
2322+
22952323
func assertNumHtlcs(t *testing.T, node *HarnessNode, expected int) {
22962324
t.Helper()
22972325

0 commit comments

Comments
 (0)