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-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) {
|
|
|
|
cfg, err := config.Load("../../config", config.ModeMainNet)
|
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-04-30 13:00:33 +00:00
|
|
|
expect := "8eb36fe47f07a795a1783a9f066603db66c5b76cf878650b1e137c114f46c0cc"
|
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-04-21 13:45:48 +00:00
|
|
|
consensusAddr = "APtiVEdLi5GEmQ8CL5RcCE7BNcsPsxeXh7"
|
|
|
|
consensusScript = "590c459950f1d83e67ee11fcef202a6ebb8b1a77"
|
2018-03-25 10:45:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
cfg, err := config.Load("../../config", config.ModeMainNet)
|
2020-02-29 15:55:16 +00:00
|
|
|
require.NoError(t, err)
|
2018-03-25 10:45:54 +00:00
|
|
|
|
|
|
|
validators, err := getValidators(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
|
|
|
}
|
|
|
|
|
|
|
|
func TestUtilityTokenTX(t *testing.T) {
|
2020-04-10 10:41:49 +00:00
|
|
|
//TODO: After we added Nonce field to transaction.Transaction, UtilityTockenTx hash
|
|
|
|
// has been changed. Update it for better times.
|
|
|
|
// Old hash is "602c79718b16e442de58778e148d0b1084e3b2dffd5de6b7b16cee7969282de7"
|
2020-04-30 13:00:33 +00:00
|
|
|
expect := "8ef63ccd6f4ea20a93e7f4e84b2d43f778077612b241d617e42e1750cca4f2c5"
|
2020-02-14 14:44:46 +00:00
|
|
|
assert.Equal(t, expect, UtilityTokenID().StringLE())
|
2018-03-25 10:45:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestGoverningTokenTX(t *testing.T) {
|
2020-04-10 10:41:49 +00:00
|
|
|
//TODO: After we added Nonce field to transaction.Transaction, GoveringTockenTx hash
|
|
|
|
// has been changed. Update it for better times.
|
|
|
|
// Old hash is "c56f33fc6ecfcd0c225c4ab356fee59390af8560be0e930faebe74a6daff7c9b"
|
2020-04-30 13:00:33 +00:00
|
|
|
expect := "7dc12f8835b085d468ddbab3f7152c0e2f5679b5815b2028685abb4608e7b7dc"
|
2020-02-14 14:44:46 +00:00
|
|
|
assert.Equal(t, expect, GoverningTokenID().StringLE())
|
2018-03-25 10:45:54 +00:00
|
|
|
}
|