From b308895583076e6e0f0c02f8bf3551886e3a3577 Mon Sep 17 00:00:00 2001 From: ffranr Date: Tue, 27 Feb 2024 11:11:21 +0000 Subject: [PATCH] lncli: unit test makes use of error wrapping during comparison This commit modifies a unit test such that it inspects a wrapped error rather than comparing errors by string. --- cmd/lncli/commands_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cmd/lncli/commands_test.go b/cmd/lncli/commands_test.go index 17e32268b..a1f967561 100644 --- a/cmd/lncli/commands_test.go +++ b/cmd/lncli/commands_test.go @@ -1,7 +1,7 @@ package main import ( - "errors" + "encoding/hex" "fmt" "math" "strconv" @@ -52,19 +52,18 @@ func TestParseChanPoint(t *testing.T) { "3a5a467dc0bc:string", true, 0, - errors.New("unable to decode output index: strconv." + - "ParseInt: parsing \"string\": invalid syntax"), + strconv.ErrSyntax, }, { "not_hex:0", true, 0, - errors.New("unable to parse hex string: encoding/hex:" + - " invalid byte: U+006E 'n'"), + hex.InvalidByteError('n'), }, } for _, tc := range testCases { cp, err := parseChanPoint(tc.channelPoinStr) - require.Equal(t, tc.err, err) + require.ErrorIs(t, err, tc.err) + require.Equal(t, tc.channelPointIsNil, cp == nil) if !tc.channelPointIsNil { require.Equal(t, tc.outputIndex, cp.OutputIndex)