neo-go/pkg/core/util_test.go
Roman Khimov e5f05790d5 core: cache standby validators in the Blockchain
They never change, so it makes no sense parsing the keys over and over
again. It also simplifies the interface a little.
2020-06-24 10:22:17 +03:00

45 lines
1.5 KiB
Go

package core
import (
"testing"
"github.com/nspcc-dev/neo-go/pkg/config"
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGenesisBlockMainNet(t *testing.T) {
cfg, err := config.Load("../../config", netmode.MainNet)
require.NoError(t, err)
block, err := createGenesisBlock(cfg.ProtocolConfiguration)
require.NoError(t, err)
//TODO: After we added Nonce field to transaction.Transaction, goveringTockenTx and UtilityTockenTx hashes
// have been changed. Consequently, hash of the genesis block has been changed.
// Update expected genesis block hash for better times.
// Old hash is "d42561e3d30e15be6400b6df2f328e02d2bf6354c41dce433bc57687c82144bf"
expect := "dba446947a90b2862ef050703b44828ad8b02d11978f8ef59bd3e1c97aabf6e5"
assert.Equal(t, expect, block.Hash().StringLE())
}
func TestGetConsensusAddressMainNet(t *testing.T) {
var (
consensusAddr = "NWNnqYniJyFh1qx5KyBeTV4uq5ewvNrAuD"
consensusScript = "72c3d9b3bbf776698694cd2c73fa597a10c31294"
)
cfg, err := config.Load("../../config", netmode.MainNet)
require.NoError(t, err)
validators, err := validatorsFromConfig(cfg.ProtocolConfiguration)
require.NoError(t, err)
script, err := getNextConsensusAddress(validators)
require.NoError(t, err)
assert.Equal(t, consensusScript, script.String())
assert.Equal(t, consensusAddr, address.Uint160ToString(script))
}