Skip to content

Commit 1d19386

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 5d8753a commit 1d19386

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
@@ -2491,6 +2491,34 @@ func macFromBytes(macBytes []byte) (grpc.DialOption, error) {
24912491
return grpc.WithPerRPCCredentials(cred), nil
24922492
}
24932493

2494+
func assertMinNumHtlcs(t *testing.T, node *HarnessNode, expected int) {
2495+
t.Helper()
2496+
2497+
ctxb := context.Background()
2498+
2499+
err := wait.NoError(func() error {
2500+
listChansRequest := &lnrpc.ListChannelsRequest{}
2501+
listChansResp, err := node.ListChannels(ctxb, listChansRequest)
2502+
if err != nil {
2503+
return err
2504+
}
2505+
2506+
var numHtlcs int
2507+
for _, channel := range listChansResp.Channels {
2508+
numHtlcs += len(channel.PendingHtlcs)
2509+
}
2510+
2511+
if numHtlcs < expected {
2512+
return fmt.Errorf("expected %v HTLCs, got %v, %v",
2513+
expected, numHtlcs,
2514+
toProtoJSON(t, listChansResp))
2515+
}
2516+
2517+
return nil
2518+
}, defaultTimeout)
2519+
require.NoError(t, err)
2520+
}
2521+
24942522
func assertNumHtlcs(t *testing.T, node *HarnessNode, expected int) {
24952523
t.Helper()
24962524

0 commit comments

Comments
 (0)