Skip to content

Commit

Permalink
basicchain: use UnitTestNet default config
Browse files Browse the repository at this point in the history
It's important to have the same chain configuration for all tests.
Otherwise, a mismatched hardfork configuration is used to dump/restore
the basic chain.

Close #3681

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
  • Loading branch information
AliceInHunterland committed Dec 2, 2024
1 parent 8fe2ae8 commit a84023c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion config/protocol.unit_testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ProtocolConfiguration:
VerifyTransactions: true
P2PSigExtensions: true
Hardforks:
Aspidochelone: 25
# Aspidochelone: 25

ApplicationConfiguration:
SkipBlockVerification: false
Expand Down
17 changes: 6 additions & 11 deletions pkg/neotest/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,13 @@ func NewMultiWithOptionsNoCheck(t testing.TB, options *Options) (*core.Blockchai
options = &Options{}
}

cfg := config.Blockchain{
ProtocolConfiguration: config.ProtocolConfiguration{
Magic: netmode.UnitTestNet,
MaxTraceableBlocks: MaxTraceableBlocks,
TimePerBlock: TimePerBlock,
StandbyCommittee: standByCommittee,
ValidatorsCount: 4,
VerifyTransactions: true,
},
cfg, err := config.Load(config.DefaultConfigPath, netmode.UnitTestNet)
if err != nil {
return nil, nil, nil, err

Check warning on line 263 in pkg/neotest/chain/chain.go

View check run for this annotation

Codecov / codecov/patch

pkg/neotest/chain/chain.go#L263

Added line #L263 was not covered by tests
}
bcfg := cfg.Blockchain()
if options.BlockchainConfigHook != nil {
options.BlockchainConfigHook(&cfg)
options.BlockchainConfigHook(&bcfg)
}

store := options.Store
Expand All @@ -282,7 +277,7 @@ func NewMultiWithOptionsNoCheck(t testing.TB, options *Options) (*core.Blockchai
logger = zaptest.NewLogger(t)
}

bc, err := core.NewBlockchain(store, cfg, logger)
bc, err := core.NewBlockchain(store, bcfg, logger)
if err == nil && !options.SkipRun {
go bc.Run()
t.Cleanup(bc.Close)
Expand Down
7 changes: 5 additions & 2 deletions pkg/services/rpcsrv/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2447,8 +2447,11 @@ func TestClient_GetStorageHistoric(t *testing.T) {
}

func TestClient_GetVersion_Hardforks(t *testing.T) {
_, _, httpSrv := initServerWithInMemoryChain(t)

_, _, httpSrv := initClearServerWithCustomConfig(t, func(cfg *config.Config) {
cfg.ProtocolConfiguration.Hardforks = map[string]uint32{
"Aspidochelone": 25,
}
})
c, err := rpcclient.New(context.Background(), httpSrv.URL, rpcclient.Options{})
require.NoError(t, err)
t.Cleanup(c.Close)
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/rpcsrv/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const (
// not yet deployed to the testing basic chain.
invokescriptContractAVM = "VwIADBQBDAMOBQYMDQIODw0DDgcJAAAAAErZMCQE2zBwaEH4J+yMqiYEEUAMFA0PAwIJAAIBAwcDBAUCAQAOBgwJStkwJATbMHFpQfgn7IyqJgQSQBNA"
// block20StateRootLE is an LE stateroot of block #20 of basic testing chain.
block20StateRootLE = "394e20adf99a6ba160df7351770dfb193ee8af174b7b3ed45f4e2ae8c43694e8"
block20StateRootLE = "bb56d46daf7da0f83102b89737402f3dff0951ec1a35d8da3851de49e0c73e97"
)

var (
Expand Down

0 comments on commit a84023c

Please sign in to comment.