multi: move many t.Fatalf calls to require.NoError
This commit is contained in:
1 parent
9e6f0ef46b
commit
9a10c80bcb
92 files changed
+1905
-5565
No files matched your search
@@ -8,6 +8,7 @@ import (
|
||||
"testing/quick"
|
||||
|
||||
"github.com/lightningnetwork/lnd/tlv"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// TestExtraOpaqueDataEncodeDecode tests that we're able to encode/decode
|
||||
@@ -128,9 +129,7 @@ func TestExtraOpaqueDataPackUnpackRecords(t *testing.T) {
|
||||
&recordProducer{tlv.MakePrimitiveRecord(type2, &hop2)},
|
||||
}
|
||||
typeMap, err := extraBytes.ExtractRecords(newRecords...)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to extract record: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to extract record")
|
||||
|
||||
// We should find that the new backing values have been populated with
|
||||
// the proper value.
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestNetAddressDisplay(t *testing.T) {
|
||||
@@ -13,14 +14,10 @@ func TestNetAddressDisplay(t *testing.T) {
|
||||
|
||||
pubKeyStr := "036a0c5ea35df8a528b98edf6f290b28676d51d0fe202b073fe677612a39c0aa09"
|
||||
pubHex, err := hex.DecodeString(pubKeyStr)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to decode str: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to decode str")
|
||||
|
||||
pubKey, err := btcec.ParsePubKey(pubHex)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to parse pubkey: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to parse pubkey")
|
||||
addr, _ := net.ResolveTCPAddr("tcp", "10.0.0.2:9000")
|
||||
|
||||
netAddr := NetAddress{
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -101,9 +102,7 @@ func TestChannelUpdateCompatabilityParsing(t *testing.T) {
|
||||
err := parseChannelUpdateCompatabilityMode(
|
||||
bufio.NewReader(&b), &newChanUpdate, 0,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to parse channel update: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to parse channel update")
|
||||
|
||||
// At this point, we'll ensure that we get the exact same failure out
|
||||
// on the other side.
|
||||
@@ -130,9 +129,7 @@ func TestChannelUpdateCompatabilityParsing(t *testing.T) {
|
||||
err = parseChannelUpdateCompatabilityMode(
|
||||
bufio.NewReader(&b), &newChanUpdate2, 0,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to parse channel update: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to parse channel update")
|
||||
|
||||
if !reflect.DeepEqual(newChanUpdate2, newChanUpdate) {
|
||||
t.Fatalf("mismatched channel updates: %v", err)
|
||||
@@ -158,9 +155,7 @@ func TestWriteOnionErrorChanUpdate(t *testing.T) {
|
||||
// onion error message.
|
||||
var errorBuf bytes.Buffer
|
||||
err := writeOnionErrorChanUpdate(&errorBuf, &update, 0)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to encode onion error: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to encode onion error")
|
||||
|
||||
// Finally, read the length encoded and ensure that it matches the raw
|
||||
// length.
|
||||
@@ -188,9 +183,7 @@ func TestFailIncorrectDetailsOptionalAmount(t *testing.T) {
|
||||
}
|
||||
|
||||
onionError2, err := DecodeFailure(bytes.NewReader(b.Bytes()), 0)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to decode error: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to decode error")
|
||||
|
||||
invalidDetailsErr, ok := onionError2.(*FailIncorrectDetails)
|
||||
if !ok {
|
||||
@@ -241,9 +234,7 @@ func TestFailIncorrectDetailsOptionalHeight(t *testing.T) {
|
||||
}
|
||||
|
||||
onionError2, err := DecodeFailure(bytes.NewReader(b.Bytes()), 0)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to decode error: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to decode error")
|
||||
|
||||
invalidDetailsErr, ok := onionError2.(*FailIncorrectDetails)
|
||||
if !ok {
|
||||
|
||||
Reference in new issue
Block a user