mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-30 09:33:36 +00:00
block: use require in tests
This commit is contained in:
parent
489b88afbb
commit
79bceb3e40
2 changed files with 9 additions and 21 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue