Skip to content

Commit c454672

Browse files
committed
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 dedf12c commit c454672

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

itest/assets_test.go

+28
Original file line numberDiff line numberDiff line change
@@ -2547,6 +2547,34 @@ func macFromBytes(macBytes []byte) (grpc.DialOption, error) {
25472547
return grpc.WithPerRPCCredentials(cred), nil
25482548
}
25492549

2550+
func assertMinNumHtlcs(t *testing.T, node *HarnessNode, expected int) {
2551+
t.Helper()
2552+
2553+
ctxb := context.Background()
2554+
2555+
err := wait.NoError(func() error {
2556+
listChansRequest := &lnrpc.ListChannelsRequest{}
2557+
listChansResp, err := node.ListChannels(ctxb, listChansRequest)
2558+
if err != nil {
2559+
return err
2560+
}
2561+
2562+
var numHtlcs int
2563+
for _, channel := range listChansResp.Channels {
2564+
numHtlcs += len(channel.PendingHtlcs)
2565+
}
2566+
2567+
if numHtlcs < expected {
2568+
return fmt.Errorf("expected %v HTLCs, got %v, %v",
2569+
expected, numHtlcs,
2570+
toProtoJSON(t, listChansResp))
2571+
}
2572+
2573+
return nil
2574+
}, defaultTimeout)
2575+
require.NoError(t, err)
2576+
}
2577+
25502578
func assertNumHtlcs(t *testing.T, node *HarnessNode, expected int) {
25512579
t.Helper()
25522580

0 commit comments

Comments
 (0)