From 79bceb3e40c65f49b23ee9412d5f33335ff6db61 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 15 Jan 2020 11:35:02 +0300 Subject: [PATCH] block: use require in tests --- pkg/core/block/block_test.go | 17 +++++------------ pkg/core/block/helper_test.go | 13 ++++--------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/pkg/core/block/block_test.go b/pkg/core/block/block_test.go index 571e404d3..236ccebd8 100644 --- a/pkg/core/block/block_test.go +++ b/pkg/core/block/block_test.go @@ -9,20 +9,17 @@ import ( "github.com/CityOfZion/neo-go/pkg/encoding/address" "github.com/CityOfZion/neo-go/pkg/io" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) // Test blocks are blocks from mainnet with their corresponding index. func TestDecodeBlock1(t *testing.T) { data, err := getBlockData(1) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) b, err := hex.DecodeString(data["raw"].(string)) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) block := &Block{} r := io.NewBinReaderFromBuf(b) @@ -51,14 +48,10 @@ func TestTrimmedBlock(t *testing.T) { block := getDecodedBlock(t, 1) b, err := block.Trim() - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) trimmedBlock, err := NewBlockFromTrimmedBytes(b) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) assert.True(t, trimmedBlock.Trimmed) assert.Equal(t, block.Version, trimmedBlock.Version) diff --git a/pkg/core/block/helper_test.go b/pkg/core/block/helper_test.go index 31a8f29d8..8f3821cc6 100644 --- a/pkg/core/block/helper_test.go +++ b/pkg/core/block/helper_test.go @@ -8,25 +8,20 @@ import ( "testing" "github.com/CityOfZion/neo-go/pkg/io" + "github.com/stretchr/testify/require" ) func getDecodedBlock(t *testing.T, i int) *Block { data, err := getBlockData(i) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) b, err := hex.DecodeString(data["raw"].(string)) - if err != nil { - t.Fatal(err) - } + require.NoError(t, err) block := &Block{} r := io.NewBinReaderFromBuf(b) block.DecodeBinary(r) - if r.Err != nil { - t.Fatal(r.Err) - } + require.NoError(t, r.Err) return block }