Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basicchain: use UnitTestNet default config for generation #3696

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/config_embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ var MainNetNeoFS []byte
//
//go:embed protocol.testnet.neofs.yml
var TestNetNeoFS []byte

// UnitTestNet is the unit test network configuration.
//
//go:embed protocol.unit_testnet.yml
var UnitTestNet []byte
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ func getEmbeddedConfig(configPath string) ([]byte, error) {
return config.MainNetNeoFS, nil
case fmt.Sprintf("%s/protocol.%s.yml", DefaultConfigPath, netmode.TestNetNeoFS):
return config.TestNetNeoFS, nil
case fmt.Sprintf("%s/protocol.%s.yml", DefaultConfigPath, netmode.UnitTestNet):
return config.UnitTestNet, nil
default:
return nil, fmt.Errorf("config '%s' doesn't exist and no matching embedded config was found", configPath)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/blockchain_neotest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func TestBlockchain_StartFromExistingDB(t *testing.T) {

_, _, _, err = chain.NewMultiWithCustomConfigAndStoreNoCheck(t, customConfig, cache)
require.Error(t, err)
require.True(t, strings.Contains(err.Error(), fmt.Sprintf("native %s: version mismatch for the latest hardfork Echidna (stored contract state differs from autogenerated one)", nativenames.CryptoLib)), err)
require.True(t, strings.Contains(err.Error(), fmt.Sprintf("native %s: version mismatch for the latest hardfork Default (stored contract state differs from autogenerated one)", nativenames.CryptoLib)), err)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnnaShaleva it could be correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's because you changed the node's fork scheduler.

})

t.Run("good", func(t *testing.T) {
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear from the commit message what is the reason of the problem and why does this change solve it.

if err != nil {
return nil, nil, nil, err
}
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
36 changes: 18 additions & 18 deletions 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 = "c6d742ddd1db4e966a03d02d7d3d08364cff2406c150e1cdf561c64774ed7612"
)

var (
Expand Down Expand Up @@ -1354,22 +1354,22 @@ var rpcTestCases = map[string][]rpcTestCase{
return &[]result.Validator{}
},
/* preview3 doesn't return any validators until there is a vote
check: func(t *testing.T, e *executor, validators any) {
var expected []result.Validator
sBValidators := e.chain.GetStandByValidators()
for _, sbValidator := range sBValidators {
expected = append(expected, result.Validator{
PublicKey: *sbValidator,
Votes: 0,
Active: true,
})
}

actual, ok := validators.(*[]result.Validator)
require.True(t, ok)

assert.ElementsMatch(t, expected, *actual)
},
check: func(t *testing.T, e *executor, validators any) {
var expected []result.Validator
sBValidators := e.chain.GetStandByValidators()
for _, sbValidator := range sBValidators {
expected = append(expected, result.Validator{
PublicKey: *sbValidator,
Votes: 0,
Active: true,
})
}

actual, ok := validators.(*[]result.Validator)
require.True(t, ok)

assert.ElementsMatch(t, expected, *actual)
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless change. And BTW, create an issue to enable this test, preview3 has passed long ago.

*/
},
},
Expand Down Expand Up @@ -1456,7 +1456,7 @@ var rpcTestCases = map[string][]rpcTestCase{
chg := []dboper.Operation{{
State: "Changed",
Key: []byte{0xfa, 0xff, 0xff, 0xff, 0xb},
Value: []byte{0xba, 0xaa, 0x3d, 0x19, 0x5e, 0x79, 0x12},
Value: []byte{0xba, 0x8c, 0x97, 0x19, 0x5e, 0x79, 0x12},
}, {
State: "Added",
Key: []byte{0xfb, 0xff, 0xff, 0xff, 0x14, 0xd6, 0x24, 0x87, 0x12, 0xff, 0x97, 0x22, 0x80, 0xa0, 0xae, 0xf5, 0x24, 0x1c, 0x96, 0x4d, 0x63, 0x78, 0x29, 0xcd, 0xb},
Expand Down
Binary file modified pkg/services/rpcsrv/testdata/testblocks.acc
Binary file not shown.
Loading