2018-03-25 10:45:54 +00:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-03-25 15:30:21 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
2020-06-14 07:34:50 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
2020-03-03 14:21:42 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
2018-03-25 10:45:54 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2020-02-29 15:55:16 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2018-03-25 10:45:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestGenesisBlockMainNet(t *testing.T) {
|
2020-06-14 07:34:50 +00:00
|
|
|
cfg, err := config.Load("../../config", netmode.MainNet)
|
2020-02-29 15:55:16 +00:00
|
|
|
require.NoError(t, err)
|
2018-03-25 10:45:54 +00:00
|
|
|
|
|
|
|
block, err := createGenesisBlock(cfg.ProtocolConfiguration)
|
2020-02-29 15:55:16 +00:00
|
|
|
require.NoError(t, err)
|
2018-03-25 10:45:54 +00:00
|
|
|
|
2020-04-10 10:41:49 +00:00
|
|
|
//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"
|
2020-07-13 10:39:36 +00:00
|
|
|
expect := "94e61af2441145cc251752707a58107850328a48bb095fd175ca2f8513ab5676"
|
2019-11-27 09:23:18 +00:00
|
|
|
assert.Equal(t, expect, block.Hash().StringLE())
|
2018-03-25 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestGetConsensusAddressMainNet(t *testing.T) {
|
|
|
|
var (
|
2020-07-13 10:39:36 +00:00
|
|
|
consensusAddr = "NiVihDFvZacZhujTWkBhRz32UDuNRp416f"
|
|
|
|
consensusScript = "f7b4d00143932f3b6243cfc06cb4a68f22c739e2"
|
2018-03-25 10:45:54 +00:00
|
|
|
)
|
|
|
|
|
2020-06-14 07:34:50 +00:00
|
|
|
cfg, err := config.Load("../../config", netmode.MainNet)
|
2020-02-29 15:55:16 +00:00
|
|
|
require.NoError(t, err)
|
2018-03-25 10:45:54 +00:00
|
|
|
|
2020-06-23 15:15:55 +00:00
|
|
|
validators, err := validatorsFromConfig(cfg.ProtocolConfiguration)
|
2020-02-29 15:55:16 +00:00
|
|
|
require.NoError(t, err)
|
2018-03-25 10:45:54 +00:00
|
|
|
|
|
|
|
script, err := getNextConsensusAddress(validators)
|
2020-02-29 15:55:16 +00:00
|
|
|
require.NoError(t, err)
|
2018-03-25 10:45:54 +00:00
|
|
|
|
|
|
|
assert.Equal(t, consensusScript, script.String())
|
2019-12-25 14:34:18 +00:00
|
|
|
assert.Equal(t, consensusAddr, address.Uint160ToString(script))
|
2018-03-25 10:45:54 +00:00
|
|
|
}
|