mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-02 23:22:49 +00:00
Merge pull request #3696 from nspcc-dev/basic-chain-tests
basicchain: use UnitTestNet default config for generation
This commit is contained in:
commit
6d1eea307b
8 changed files with 36 additions and 14 deletions
|
@ -30,3 +30,8 @@ var MainNetNeoFS []byte
|
||||||
//
|
//
|
||||||
//go:embed protocol.testnet.neofs.yml
|
//go:embed protocol.testnet.neofs.yml
|
||||||
var TestNetNeoFS []byte
|
var TestNetNeoFS []byte
|
||||||
|
|
||||||
|
// UnitTestNet is the unit test network configuration.
|
||||||
|
//
|
||||||
|
//go:embed protocol.unit_testnet.yml
|
||||||
|
var UnitTestNet []byte
|
||||||
|
|
|
@ -18,7 +18,10 @@ ProtocolConfiguration:
|
||||||
VerifyTransactions: true
|
VerifyTransactions: true
|
||||||
P2PSigExtensions: true
|
P2PSigExtensions: true
|
||||||
Hardforks:
|
Hardforks:
|
||||||
Aspidochelone: 25
|
Aspidochelone: 3
|
||||||
|
Basilisk: 6
|
||||||
|
Cockatrice: 9
|
||||||
|
Domovoi: 12
|
||||||
|
|
||||||
ApplicationConfiguration:
|
ApplicationConfiguration:
|
||||||
SkipBlockVerification: false
|
SkipBlockVerification: false
|
||||||
|
|
|
@ -137,6 +137,8 @@ func getEmbeddedConfig(configPath string) ([]byte, error) {
|
||||||
return config.MainNetNeoFS, nil
|
return config.MainNetNeoFS, nil
|
||||||
case fmt.Sprintf("%s/protocol.%s.yml", DefaultConfigPath, netmode.TestNetNeoFS):
|
case fmt.Sprintf("%s/protocol.%s.yml", DefaultConfigPath, netmode.TestNetNeoFS):
|
||||||
return config.TestNetNeoFS, nil
|
return config.TestNetNeoFS, nil
|
||||||
|
case fmt.Sprintf("%s/protocol.%s.yml", DefaultConfigPath, netmode.UnitTestNet):
|
||||||
|
return config.UnitTestNet, nil
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("config '%s' doesn't exist and no matching embedded config was found", configPath)
|
return nil, fmt.Errorf("config '%s' doesn't exist and no matching embedded config was found", configPath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,9 @@ func TestNativeContract_InvokeInternal(t *testing.T) {
|
||||||
mdDeploy := manState.Manifest.ABI.GetMethod("deploy", 2)
|
mdDeploy := manState.Manifest.ABI.GetMethod("deploy", 2)
|
||||||
require.NotNil(t, mdDeploy)
|
require.NotNil(t, mdDeploy)
|
||||||
t.Run("fail, bad call flag", func(t *testing.T) {
|
t.Run("fail, bad call flag", func(t *testing.T) {
|
||||||
|
bc, _, _ := chain.NewMultiWithCustomConfig(t, func(c *config.Blockchain) {
|
||||||
|
c.Hardforks = nil
|
||||||
|
})
|
||||||
ic, err := bc.GetTestVM(trigger.Application, nil, nil)
|
ic, err := bc.GetTestVM(trigger.Application, nil, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
v := ic.SpawnVM()
|
v := ic.SpawnVM()
|
||||||
|
|
|
@ -401,6 +401,17 @@ func TestNEO_RecursiveGASMint(t *testing.T) {
|
||||||
func TestNEO_GetCommitteeAddress(t *testing.T) {
|
func TestNEO_GetCommitteeAddress(t *testing.T) {
|
||||||
neoValidatorInvoker := newNeoValidatorsClient(t)
|
neoValidatorInvoker := newNeoValidatorsClient(t)
|
||||||
e := neoValidatorInvoker.Executor
|
e := neoValidatorInvoker.Executor
|
||||||
|
cfg := neoValidatorInvoker.Chain.GetConfig()
|
||||||
|
|
||||||
|
maxHardforkHeight := uint32(0)
|
||||||
|
for _, height := range cfg.Hardforks {
|
||||||
|
if height > maxHardforkHeight {
|
||||||
|
maxHardforkHeight = height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for range maxHardforkHeight {
|
||||||
|
neoValidatorInvoker.AddNewBlock(t)
|
||||||
|
}
|
||||||
standByCommitteePublicKeys, err := keys.NewPublicKeysFromStrings(e.Chain.GetConfig().StandbyCommittee)
|
standByCommitteePublicKeys, err := keys.NewPublicKeysFromStrings(e.Chain.GetConfig().StandbyCommittee)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
slices.SortFunc(standByCommitteePublicKeys, (*keys.PublicKey).Cmp)
|
slices.SortFunc(standByCommitteePublicKeys, (*keys.PublicKey).Cmp)
|
||||||
|
|
|
@ -258,18 +258,13 @@ func NewMultiWithOptionsNoCheck(t testing.TB, options *Options) (*core.Blockchai
|
||||||
options = &Options{}
|
options = &Options{}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg := config.Blockchain{
|
cfg, err := config.Load(config.DefaultConfigPath, netmode.UnitTestNet)
|
||||||
ProtocolConfiguration: config.ProtocolConfiguration{
|
if err != nil {
|
||||||
Magic: netmode.UnitTestNet,
|
return nil, nil, nil, err
|
||||||
MaxTraceableBlocks: MaxTraceableBlocks,
|
|
||||||
TimePerBlock: TimePerBlock,
|
|
||||||
StandbyCommittee: standByCommittee,
|
|
||||||
ValidatorsCount: 4,
|
|
||||||
VerifyTransactions: true,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
bcfg := cfg.Blockchain()
|
||||||
if options.BlockchainConfigHook != nil {
|
if options.BlockchainConfigHook != nil {
|
||||||
options.BlockchainConfigHook(&cfg)
|
options.BlockchainConfigHook(&bcfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
store := options.Store
|
store := options.Store
|
||||||
|
@ -282,7 +277,7 @@ func NewMultiWithOptionsNoCheck(t testing.TB, options *Options) (*core.Blockchai
|
||||||
logger = zaptest.NewLogger(t)
|
logger = zaptest.NewLogger(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
bc, err := core.NewBlockchain(store, cfg, logger)
|
bc, err := core.NewBlockchain(store, bcfg, logger)
|
||||||
if err == nil && !options.SkipRun {
|
if err == nil && !options.SkipRun {
|
||||||
go bc.Run()
|
go bc.Run()
|
||||||
t.Cleanup(bc.Close)
|
t.Cleanup(bc.Close)
|
||||||
|
|
|
@ -2457,7 +2457,10 @@ func TestClient_GetVersion_Hardforks(t *testing.T) {
|
||||||
v, err := c.GetVersion()
|
v, err := c.GetVersion()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
expected := map[config.Hardfork]uint32{
|
expected := map[config.Hardfork]uint32{
|
||||||
config.HFAspidochelone: 25,
|
config.HFAspidochelone: 3,
|
||||||
|
config.HFBasilisk: 6,
|
||||||
|
config.HFCockatrice: 9,
|
||||||
|
config.HFDomovoi: 12,
|
||||||
}
|
}
|
||||||
require.InDeltaMapValues(t, expected, v.Protocol.Hardforks, 0)
|
require.InDeltaMapValues(t, expected, v.Protocol.Hardforks, 0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ const (
|
||||||
// not yet deployed to the testing basic chain.
|
// not yet deployed to the testing basic chain.
|
||||||
invokescriptContractAVM = "VwIADBQBDAMOBQYMDQIODw0DDgcJAAAAAErZMCQE2zBwaEH4J+yMqiYEEUAMFA0PAwIJAAIBAwcDBAUCAQAOBgwJStkwJATbMHFpQfgn7IyqJgQSQBNA"
|
invokescriptContractAVM = "VwIADBQBDAMOBQYMDQIODw0DDgcJAAAAAErZMCQE2zBwaEH4J+yMqiYEEUAMFA0PAwIJAAIBAwcDBAUCAQAOBgwJStkwJATbMHFpQfgn7IyqJgQSQBNA"
|
||||||
// block20StateRootLE is an LE stateroot of block #20 of basic testing chain.
|
// block20StateRootLE is an LE stateroot of block #20 of basic testing chain.
|
||||||
block20StateRootLE = "394e20adf99a6ba160df7351770dfb193ee8af174b7b3ed45f4e2ae8c43694e8"
|
block20StateRootLE = "570ba0814003f6e6a2a2e41d1b727f8af756e9c26d2453c8316868607b66da0a"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in a new issue