neoneo-go/pkg/core/block/helper_test.go
Anna Shaleva 6b21ad9922 *: replace interface{} with any keyword
Everywhere including examples, external interop APIs, bindings generators
code and in other valuable places. A couple of `interface{}` usages are
intentionally left in the CHANGELOG.md, documentation and tests.
2023-04-04 13:22:42 +03:00

37 lines
726 B
Go

package block
import (
"encoding/hex"
"encoding/json"
"fmt"
"os"
"testing"
"github.com/nspcc-dev/neo-go/internal/testserdes"
"github.com/stretchr/testify/require"
)
func getDecodedBlock(t *testing.T, i int) *Block {
data, err := getBlockData(i)
require.NoError(t, err)
b, err := hex.DecodeString(data["raw"].(string))
require.NoError(t, err)
block := New(false)
require.NoError(t, testserdes.DecodeBinary(b, block))
return block
}
func getBlockData(i int) (map[string]any, error) {
b, err := os.ReadFile(fmt.Sprintf("../test_data/block_%d.json", i))
if err != nil {
return nil, err
}
var data map[string]any
if err := json.Unmarshal(b, &data); err != nil {
return nil, err
}
return data, err
}