mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-09 15:04:39 +02:00
multi: move many t.Fatalf calls to require.NoError
This commit is contained in:
@ -8,6 +8,8 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func makeFakePackedMulti() (PackedMulti, error) {
|
||||
@ -25,9 +27,7 @@ func assertBackupMatches(t *testing.T, filePath string,
|
||||
t.Helper()
|
||||
|
||||
packedBackup, err := ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to test file: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to test file")
|
||||
|
||||
if !bytes.Equal(packedBackup, currentBackup) {
|
||||
t.Fatalf("backups don't match after first swap: "+
|
||||
@ -53,9 +53,7 @@ func TestUpdateAndSwap(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tempTestDir, err := ioutil.TempDir("", "")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to make temp dir: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to make temp dir")
|
||||
defer os.Remove(tempTestDir)
|
||||
|
||||
testCases := []struct {
|
||||
@ -193,9 +191,7 @@ func TestExtractMulti(t *testing.T) {
|
||||
// First, as prep, we'll create a single chan backup, then pack that
|
||||
// fully into a multi backup.
|
||||
channel, err := genRandomOpenChannelShell()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to gen chan: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to gen chan")
|
||||
|
||||
singleBackup := NewSingle(channel, nil)
|
||||
|
||||
@ -204,24 +200,18 @@ func TestExtractMulti(t *testing.T) {
|
||||
StaticBackups: []Single{singleBackup},
|
||||
}
|
||||
err = unpackedMulti.PackToWriter(&b, keyRing)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to pack to writer: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to pack to writer")
|
||||
|
||||
packedMulti := PackedMulti(b.Bytes())
|
||||
|
||||
// Finally, we'll make a new temporary file, then write out the packed
|
||||
// multi directly to to it.
|
||||
tempFile, err := ioutil.TempFile("", "")
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create temp file: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to create temp file")
|
||||
defer os.Remove(tempFile.Name())
|
||||
|
||||
_, err = tempFile.Write(packedMulti)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to write temp file: %v", err)
|
||||
}
|
||||
require.NoError(t, err, "unable to write temp file")
|
||||
if err := tempFile.Sync(); err != nil {
|
||||
t.Fatalf("unable to sync temp file: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user