Skip to content

Commit b308895

Browse files
committed
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.
1 parent cd566eb commit b308895

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

cmd/lncli/commands_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package main
22

33
import (
4-
"errors"
4+
"encoding/hex"
55
"fmt"
66
"math"
77
"strconv"
@@ -52,19 +52,18 @@ func TestParseChanPoint(t *testing.T) {
5252
"3a5a467dc0bc:string",
5353
true,
5454
0,
55-
errors.New("unable to decode output index: strconv." +
56-
"ParseInt: parsing \"string\": invalid syntax"),
55+
strconv.ErrSyntax,
5756
}, {
5857
"not_hex:0",
5958
true,
6059
0,
61-
errors.New("unable to parse hex string: encoding/hex:" +
62-
" invalid byte: U+006E 'n'"),
60+
hex.InvalidByteError('n'),
6361
},
6462
}
6563
for _, tc := range testCases {
6664
cp, err := parseChanPoint(tc.channelPoinStr)
67-
require.Equal(t, tc.err, err)
65+
require.ErrorIs(t, err, tc.err)
66+
6867
require.Equal(t, tc.channelPointIsNil, cp == nil)
6968
if !tc.channelPointIsNil {
7069
require.Equal(t, tc.outputIndex, cp.OutputIndex)

0 commit comments

Comments
 (0)