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.
This commit is contained in:
ffranr
2024-02-27 11:11:21 +00:00
parent cd566eb097
commit b308895583

View File

@@ -1,7 +1,7 @@
package main package main
import ( import (
"errors" "encoding/hex"
"fmt" "fmt"
"math" "math"
"strconv" "strconv"
@@ -52,19 +52,18 @@ func TestParseChanPoint(t *testing.T) {
"3a5a467dc0bc:string", "3a5a467dc0bc:string",
true, true,
0, 0,
errors.New("unable to decode output index: strconv." + strconv.ErrSyntax,
"ParseInt: parsing \"string\": invalid syntax"),
}, { }, {
"not_hex:0", "not_hex:0",
true, true,
0, 0,
errors.New("unable to parse hex string: encoding/hex:" + hex.InvalidByteError('n'),
" invalid byte: U+006E 'n'"),
}, },
} }
for _, tc := range testCases { for _, tc := range testCases {
cp, err := parseChanPoint(tc.channelPoinStr) cp, err := parseChanPoint(tc.channelPoinStr)
require.Equal(t, tc.err, err) require.ErrorIs(t, err, tc.err)
require.Equal(t, tc.channelPointIsNil, cp == nil) require.Equal(t, tc.channelPointIsNil, cp == nil)
if !tc.channelPointIsNil { if !tc.channelPointIsNil {
require.Equal(t, tc.outputIndex, cp.OutputIndex) require.Equal(t, tc.outputIndex, cp.OutputIndex)