mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-05 18:03:09 +02:00
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:
@@ -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)
|
||||||
|
Reference in New Issue
Block a user