From 8be1a2f1edc9274581248b34e043198b9c83d1ee Mon Sep 17 00:00:00 2001 From: noot Date: Thu, 1 Apr 2021 14:47:22 -0400 Subject: [PATCH] update tests --- Makefile | 2 +- cmd/gossamer/config.go | 6 +++--- cmd/gossamer/config_test.go | 20 ++++++++++---------- cmd/gossamer/export_test.go | 18 +++++++++--------- cmd/gossamer/flags_test.go | 16 ++++++++-------- cmd/gossamer/toml_config_test.go | 10 +++++----- dot/build_spec_test.go | 2 +- dot/core/test_helpers.go | 4 ++-- dot/rpc/modules/chain_test.go | 2 +- dot/state/service_test.go | 2 +- dot/sync/syncer_test.go | 2 +- dot/utils.go | 2 +- lib/babe/babe_test.go | 4 ++-- lib/genesis/helpers.go | 2 +- lib/runtime/life/exports_test.go | 8 ++++---- lib/runtime/wasmer/exports_test.go | 10 +++++----- scripts/docker-entrypoint.sh | 2 +- tests/utils/gossamer_utils.go | 6 +++--- 18 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Makefile b/Makefile index f5eb9907df..bd17f547bb 100644 --- a/Makefile +++ b/Makefile @@ -89,7 +89,7 @@ build-debug: ## init: Initialize gossamer using the default genesis and toml configuration files init: - ./bin/gossamer --key alice init --genesis-raw chain/gssmr/genesis-raw.json --force + ./bin/gossamer --key alice init --genesis chain/gssmr/genesis.json --force ## init-repo: Set initial configuration for the repo init-repo: diff --git a/cmd/gossamer/config.go b/cmd/gossamer/config.go index 92b4d120bd..df1a53c82c 100644 --- a/cmd/gossamer/config.go +++ b/cmd/gossamer/config.go @@ -372,7 +372,7 @@ func setDotInitConfig(ctx *cli.Context, tomlCfg ctoml.InitConfig, cfg *dot.InitC cfg.Genesis = tomlCfg.Genesis } - // check --genesis-raw flag and update init configuration + // check --genesis flag and update init configuration if genesis := ctx.String(GenesisFlag.Name); genesis != "" { cfg.Genesis = genesis } @@ -687,8 +687,8 @@ func updateDotConfigFromGenesisJSONRaw(tomlCfg ctoml.Config, cfg *dot.Config) { cfg.Core.BabeAuthority = tomlCfg.Core.Roles == types.AuthorityRole cfg.Core.GrandpaAuthority = tomlCfg.Core.Roles == types.AuthorityRole - // use default genesis-raw file if genesis configuration not provided, for example, - // if we load a toml configuration file without a defined genesis-raw init value or + // use default genesis file if genesis configuration not provided, for example, + // if we load a toml configuration file without a defined genesis init value or // if we pass an empty string as the genesis init value using the --geneis-raw flag if cfg.Init.Genesis == "" { cfg.Init.Genesis = DefaultCfg().Init.Genesis diff --git a/cmd/gossamer/config_test.go b/cmd/gossamer/config_test.go index 909f78eae5..4a3fbcc5e7 100644 --- a/cmd/gossamer/config_test.go +++ b/cmd/gossamer/config_test.go @@ -93,11 +93,11 @@ func TestInitConfigFromFlags(t *testing.T) { expected dot.InitConfig }{ { - "Test gossamer --genesis-raw", - []string{"config", "genesis-raw"}, + "Test gossamer --genesis", + []string{"config", "genesis"}, []interface{}{testCfgFile.Name(), "test_genesis"}, dot.InitConfig{ - GenesisRaw: "test_genesis", + Genesis: "test_genesis", }, }, } @@ -650,7 +650,7 @@ func TestUpdateConfigFromGenesisJSON(t *testing.T) { ctx, err := newTestContext( t.Name(), - []string{"config", "genesis-raw"}, + []string{"config", "genesis"}, []interface{}{testCfgFile.Name(), genFile.Name()}, ) require.Nil(t, err) @@ -675,7 +675,7 @@ func TestUpdateConfigFromGenesisJSON(t *testing.T) { FinalityGadgetLvl: log.LvlInfo, }, Init: dot.InitConfig{ - GenesisRaw: genFile.Name(), + Genesis: genFile.Name(), }, Account: testCfg.Account, Core: testCfg.Core, @@ -687,7 +687,7 @@ func TestUpdateConfigFromGenesisJSON(t *testing.T) { cfg, err := createDotConfig(ctx) require.Nil(t, err) - cfg.Init.GenesisRaw = genFile.Name() + cfg.Init.Genesis = genFile.Name() updateDotConfigFromGenesisJSONRaw(*dotConfigToToml(testCfg), cfg) require.Equal(t, expected, cfg) } @@ -702,7 +702,7 @@ func TestUpdateConfigFromGenesisJSON_Default(t *testing.T) { ctx, err := newTestContext( t.Name(), - []string{"config", "genesis-raw"}, + []string{"config", "genesis"}, []interface{}{testCfgFile.Name(), ""}, ) require.Nil(t, err) @@ -727,7 +727,7 @@ func TestUpdateConfigFromGenesisJSON_Default(t *testing.T) { FinalityGadgetLvl: log.LvlInfo, }, Init: dot.InitConfig{ - GenesisRaw: DefaultCfg().Init.GenesisRaw, + Genesis: DefaultCfg().Init.Genesis, }, Account: testCfg.Account, Core: testCfg.Core, @@ -778,7 +778,7 @@ func TestUpdateConfigFromGenesisData(t *testing.T) { FinalityGadgetLvl: log.LvlInfo, }, Init: dot.InitConfig{ - GenesisRaw: genFile.Name(), + Genesis: genFile.Name(), }, Account: testCfg.Account, Core: testCfg.Core, @@ -796,7 +796,7 @@ func TestUpdateConfigFromGenesisData(t *testing.T) { cfg, err := createDotConfig(ctx) require.Nil(t, err) - cfg.Init.GenesisRaw = genFile.Name() + cfg.Init.Genesis = genFile.Name() expected.Core.BabeThresholdNumerator = 0 expected.Core.BabeThresholdDenominator = 0 diff --git a/cmd/gossamer/export_test.go b/cmd/gossamer/export_test.go index 0d1328b8b5..bab4be37d4 100644 --- a/cmd/gossamer/export_test.go +++ b/cmd/gossamer/export_test.go @@ -52,8 +52,8 @@ func TestExportCommand(t *testing.T) { expected *dot.Config }{ { - "Test gossamer export --config --genesis-raw --basepath --name --log --force", - []string{"config", "genesis-raw", "basepath", "name", "log", "force"}, + "Test gossamer export --config --genesis --basepath --name --log --force", + []string{"config", "genesis", "basepath", "name", "log", "force"}, []interface{}{testConfig, genFile.Name(), testDir, testName, log.LvlInfo.String(), "true"}, &dot.Config{ Global: dot.GlobalConfig{ @@ -75,7 +75,7 @@ func TestExportCommand(t *testing.T) { FinalityGadgetLvl: log.LvlInfo, }, Init: dot.InitConfig{ - GenesisRaw: genFile.Name(), + Genesis: genFile.Name(), }, Account: testCfg.Account, Core: testCfg.Core, @@ -90,13 +90,13 @@ func TestExportCommand(t *testing.T) { }, }, { - "Test gossamer export --config --genesis-raw --bootnodes --log --force", - []string{"config", "genesis-raw", "bootnodes", "name", "force"}, + "Test gossamer export --config --genesis --bootnodes --log --force", + []string{"config", "genesis", "bootnodes", "name", "force"}, []interface{}{testConfig, genFile.Name(), testBootnode, "Gossamer", "true"}, &dot.Config{ Global: testCfg.Global, Init: dot.InitConfig{ - GenesisRaw: genFile.Name(), + Genesis: genFile.Name(), }, Log: dot.LogConfig{ CoreLvl: log.LvlInfo, @@ -121,13 +121,13 @@ func TestExportCommand(t *testing.T) { }, }, { - "Test gossamer export --config --genesis-raw --protocol --log --force", - []string{"config", "genesis-raw", "protocol", "force"}, + "Test gossamer export --config --genesis --protocol --log --force", + []string{"config", "genesis", "protocol", "force"}, []interface{}{testConfig, genFile.Name(), testProtocol, "true"}, &dot.Config{ Global: testCfg.Global, Init: dot.InitConfig{ - GenesisRaw: genFile.Name(), + Genesis: genFile.Name(), }, Log: dot.LogConfig{ CoreLvl: log.LvlInfo, diff --git a/cmd/gossamer/flags_test.go b/cmd/gossamer/flags_test.go index d0d7584156..6b459f338d 100644 --- a/cmd/gossamer/flags_test.go +++ b/cmd/gossamer/flags_test.go @@ -43,23 +43,23 @@ func TestFixFlagOrder(t *testing.T) { values []interface{} }{ { - "Test gossamer --config --genesis-raw --log --force", - []string{"config", "genesis-raw", "log", "force"}, + "Test gossamer --config --genesis --log --force", + []string{"config", "genesis", "log", "force"}, []interface{}{testConfig.Name(), genFile.Name(), "trace", true}, }, { - "Test gossamer --config --genesis-raw --force --log", - []string{"config", "genesis-raw", "force", "log"}, + "Test gossamer --config --genesis --force --log", + []string{"config", "genesis", "force", "log"}, []interface{}{testConfig.Name(), genFile.Name(), true, "trace"}, }, { - "Test gossamer --config --force --genesis-raw --log", - []string{"config", "force", "genesis-raw", "log"}, + "Test gossamer --config --force --genesis --log", + []string{"config", "force", "genesis", "log"}, []interface{}{testConfig.Name(), true, genFile.Name(), "trace"}, }, { - "Test gossamer --force --config --genesis-raw --log", - []string{"force", "config", "genesis-raw", "log"}, + "Test gossamer --force --config --genesis --log", + []string{"force", "config", "genesis", "log"}, []interface{}{true, testConfig.Name(), genFile.Name(), "trace"}, }, } diff --git a/cmd/gossamer/toml_config_test.go b/cmd/gossamer/toml_config_test.go index 9f825deb6d..f7bb047d08 100644 --- a/cmd/gossamer/toml_config_test.go +++ b/cmd/gossamer/toml_config_test.go @@ -10,10 +10,10 @@ import ( ) const GssmrConfigPath = "../../chain/gssmr/config.toml" -const GssmrGenesisPath = "../../chain/gssmr/genesis-raw.json" +const GssmrGenesisPath = "../../chain/gssmr/genesis.json" const KusamaConfigPath = "../../chain/kusama/config.toml" -const KusamaGenesisPath = "../../chain/kusama/genesis-raw.json" +const KusamaGenesisPath = "../../chain/kusama/genesis.json" // TestLoadConfig tests loading a toml configuration file func TestLoadConfig(t *testing.T) { @@ -25,7 +25,7 @@ func TestLoadConfig(t *testing.T) { defer utils.RemoveTestDir(t) - cfg.Init.GenesisRaw = genFile.Name() + cfg.Init.Genesis = genFile.Name() err := dot.InitNode(cfg) require.Nil(t, err) @@ -41,7 +41,7 @@ func TestLoadConfigGssmr(t *testing.T) { require.NotNil(t, cfg) cfg.Global.BasePath = utils.NewTestDir(t) - cfg.Init.GenesisRaw = GssmrGenesisPath + cfg.Init.Genesis = GssmrGenesisPath defer utils.RemoveTestDir(t) @@ -59,7 +59,7 @@ func TestLoadConfigKusama(t *testing.T) { require.NotNil(t, cfg) cfg.Global.BasePath = utils.NewTestDir(t) - cfg.Init.GenesisRaw = KusamaGenesisPath + cfg.Init.Genesis = KusamaGenesisPath defer utils.RemoveTestDir(t) diff --git a/dot/build_spec_test.go b/dot/build_spec_test.go index 7d1e3a8db5..c49c74ca4b 100644 --- a/dot/build_spec_test.go +++ b/dot/build_spec_test.go @@ -53,7 +53,7 @@ func TestBuildFromGenesis(t *testing.T) { func TestBuildFromDB(t *testing.T) { // setup expected cfg := NewTestConfig(t) - cfg.Init.GenesisRaw = "../chain/gssmr/genesis-raw.json" + cfg.Init.GenesisRaw = "../chain/gssmr/genesis.json" expected, err := genesis.NewGenesisFromJSONRaw(cfg.Init.GenesisRaw) require.NoError(t, err) // initialize node (initialize state database and load genesis data) diff --git a/dot/core/test_helpers.go b/dot/core/test_helpers.go index e5657c6a28..26c9882750 100644 --- a/dot/core/test_helpers.go +++ b/dot/core/test_helpers.go @@ -42,9 +42,9 @@ import ( var testMessageTimeout = time.Second func newTestGenesisWithTrieAndHeader(t *testing.T) (*genesis.Genesis, *trie.Trie, *types.Header) { - gen, err := genesis.NewGenesisFromJSONRaw("../../chain/gssmr/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../chain/gssmr/genesis.json") if err != nil { - gen, err = genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis-raw.json") + gen, err = genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis.json") require.NoError(t, err) } diff --git a/dot/rpc/modules/chain_test.go b/dot/rpc/modules/chain_test.go index 1f51915892..b081aafca2 100644 --- a/dot/rpc/modules/chain_test.go +++ b/dot/rpc/modules/chain_test.go @@ -305,7 +305,7 @@ func newTestStateService(t *testing.T) *state.Service { } func newTestGenesisWithTrieAndHeader() (*genesis.Genesis, *trie.Trie, *types.Header) { - gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis.json") if err != nil { panic(err) } diff --git a/dot/state/service_test.go b/dot/state/service_test.go index b338061c4a..fc29fdfcde 100644 --- a/dot/state/service_test.go +++ b/dot/state/service_test.go @@ -33,7 +33,7 @@ import ( ) func newTestGenesisWithTrieAndHeader(t *testing.T) (*genesis.Genesis, *trie.Trie, *types.Header) { - gen, err := genesis.NewGenesisFromJSONRaw("../../chain/gssmr/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../chain/gssmr/genesis.json") require.NoError(t, err) genTrie, err := genesis.NewTrieFromGenesis(gen) diff --git a/dot/sync/syncer_test.go b/dot/sync/syncer_test.go index 6beea25edf..2afe0bc9a7 100644 --- a/dot/sync/syncer_test.go +++ b/dot/sync/syncer_test.go @@ -42,7 +42,7 @@ import ( ) func newTestGenesisWithTrieAndHeader(t *testing.T) (*genesis.Genesis, *trie.Trie, *types.Header) { - gen, err := genesis.NewGenesisFromJSONRaw("../../chain/gssmr/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../chain/gssmr/genesis.json") require.NoError(t, err) genTrie, err := genesis.NewTrieFromGenesis(gen) diff --git a/dot/utils.go b/dot/utils.go index bb598c4b90..03c9640468 100644 --- a/dot/utils.go +++ b/dot/utils.go @@ -57,7 +57,7 @@ func NewTestGenesis(t *testing.T) *genesis.Genesis { } } -// NewTestGenesisRawFile returns a test genesis-raw file using "gssmr" raw data +// NewTestGenesisRawFile returns a test genesis file using "gssmr" raw data func NewTestGenesisRawFile(t *testing.T, cfg *Config) *os.File { dir := utils.NewTestDir(t) diff --git a/lib/babe/babe_test.go b/lib/babe/babe_test.go index af226cfa98..32862dc089 100644 --- a/lib/babe/babe_test.go +++ b/lib/babe/babe_test.go @@ -62,9 +62,9 @@ var ( ) func newTestGenesisWithTrieAndHeader(t *testing.T) (*genesis.Genesis, *trie.Trie, *types.Header) { - gen, err := genesis.NewGenesisFromJSONRaw("../../chain/gssmr/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../chain/gssmr/genesis.json") if err != nil { - gen, err = genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis-raw.json") + gen, err = genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis.json") require.NoError(t, err) } diff --git a/lib/genesis/helpers.go b/lib/genesis/helpers.go index ea52aa5ee3..b9f0eb8af7 100644 --- a/lib/genesis/helpers.go +++ b/lib/genesis/helpers.go @@ -36,7 +36,7 @@ import ( "github.com/ChainSafe/gossamer/lib/trie" ) -// NewGenesisFromJSONRaw parses a JSON formatted genesis-raw file +// NewGenesisFromJSONRaw parses a JSON formatted genesis file func NewGenesisFromJSONRaw(file string) (*Genesis, error) { fp, err := filepath.Abs(file) if err != nil { diff --git a/lib/runtime/life/exports_test.go b/lib/runtime/life/exports_test.go index 3c1e29386c..eec1cccdd0 100644 --- a/lib/runtime/life/exports_test.go +++ b/lib/runtime/life/exports_test.go @@ -19,7 +19,7 @@ import ( ) func newInstanceFromGenesis(t *testing.T) runtime.Instance { - gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis.json") require.NoError(t, err) genTrie, err := genesis.NewTrieFromGenesis(gen) @@ -200,7 +200,7 @@ func TestInstance_ExecuteBlock_GossamerRuntime(t *testing.T) { block := buildBlock(t, instance) // reset state back to parent state before executing - gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis.json") require.NoError(t, err) genTrie, err := genesis.NewTrieFromGenesis(gen) require.NoError(t, err) @@ -213,7 +213,7 @@ func TestInstance_ExecuteBlock_GossamerRuntime(t *testing.T) { } func TestInstance_ExecuteBlock_KusamaRuntime_KusamaBlock1(t *testing.T) { - gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/kusama/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/kusama/genesis.json") require.NoError(t, err) genTrie, err := genesis.NewTrieFromGenesis(gen) @@ -263,7 +263,7 @@ func TestInstance_ExecuteBlock_KusamaRuntime_KusamaBlock1(t *testing.T) { } func TestInstance_ExecuteBlock_PolkadotRuntime_PolkadotBlock1(t *testing.T) { - gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/polkadot/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/polkadot/genesis.json") require.NoError(t, err) genTrie, err := genesis.NewTrieFromGenesis(gen) diff --git a/lib/runtime/wasmer/exports_test.go b/lib/runtime/wasmer/exports_test.go index 2f412d58e1..91b9d4d162 100644 --- a/lib/runtime/wasmer/exports_test.go +++ b/lib/runtime/wasmer/exports_test.go @@ -54,7 +54,7 @@ func TestInstance_Version_PolkadotRuntime(t *testing.T) { } func TestInstance_Version_KusamaRuntime(t *testing.T) { - gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/kusama/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/kusama/genesis.json") require.NoError(t, err) genTrie, err := genesis.NewTrieFromGenesis(gen) @@ -409,7 +409,7 @@ func TestInstance_ExecuteBlock_NodeRuntime(t *testing.T) { func TestInstance_ExecuteBlock_GossamerRuntime(t *testing.T) { t.Skip() // TODO: fix timestamping issue - gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis.json") require.NoError(t, err) genTrie, err := genesis.NewTrieFromGenesis(gen) @@ -437,7 +437,7 @@ func TestInstance_ExecuteBlock_GossamerRuntime(t *testing.T) { } func TestInstance_ApplyExtrinsic_GossamerRuntime(t *testing.T) { - gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/gssmr/genesis.json") require.NoError(t, err) genTrie, err := genesis.NewTrieFromGenesis(gen) @@ -490,7 +490,7 @@ func TestInstance_ExecuteBlock_PolkadotRuntime(t *testing.T) { } func TestInstance_ExecuteBlock_PolkadotRuntime_PolkadotBlock1(t *testing.T) { - gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/polkadot/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/polkadot/genesis.json") require.NoError(t, err) genTrie, err := genesis.NewTrieFromGenesis(gen) @@ -540,7 +540,7 @@ func TestInstance_ExecuteBlock_PolkadotRuntime_PolkadotBlock1(t *testing.T) { } func TestInstance_ExecuteBlock_KusamaRuntime_KusamaBlock1(t *testing.T) { - gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/kusama/genesis-raw.json") + gen, err := genesis.NewGenesisFromJSONRaw("../../../chain/kusama/genesis.json") require.NoError(t, err) genTrie, err := genesis.NewTrieFromGenesis(gen) diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index d7296bd0b7..3abb78976b 100755 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -22,7 +22,7 @@ BASE_PATH=~/gossamer-dev set -euxo pipefail if [ ! -f $BASE_PATH/genesis_created ]; then - /usr/local/gossamer init --genesis-raw=/gocode/src/github.com/ChainSafe/gossamer/chain/gssmr/genesis-raw.json + /usr/local/gossamer init --genesis=/gocode/src/github.com/ChainSafe/gossamer/chain/gssmr/genesis.json touch $BASE_PATH/genesis_created; fi; diff --git a/tests/utils/gossamer_utils.go b/tests/utils/gossamer_utils.go index c079ce4d21..70f086c66d 100644 --- a/tests/utils/gossamer_utils.go +++ b/tests/utils/gossamer_utils.go @@ -66,7 +66,7 @@ var ( // GenesisSixAuths is the genesis file that has 6 authorities GenesisSixAuths string = filepath.Join(currentDir, "../utils/genesis_sixauths.json") // GenesisDefault is the default gssmr genesis file - GenesisDefault string = filepath.Join(currentDir, "../..", "chain/gssmr/genesis-raw.json") + GenesisDefault string = filepath.Join(currentDir, "../..", "chain/gssmr/genesis.json") // ConfigDefault is the default config file ConfigDefault string = filepath.Join(currentDir, "../utils/config_default.toml") @@ -95,7 +95,7 @@ func InitGossamer(idx int, basePath, genesis, config string) (*Node, error) { cmdInit := exec.Command(gossamerCMD, "init", "--config", config, "--basepath", basePath, - "--genesis-raw", genesis, + "--genesis", genesis, "--force", ) @@ -433,7 +433,7 @@ func generateDefaultConfig() *ctoml.Config { SyncLvl: "info", }, Init: ctoml.InitConfig{ - GenesisRaw: "./chain/gssmr/genesis-raw.json", + GenesisRaw: "./chain/gssmr/genesis.json", }, Account: ctoml.AccountConfig{ Key: "",