From 4cbc222e4f6e61c03f4dccc1a83cb7b2bb8d92f8 Mon Sep 17 00:00:00 2001 From: rhuairahrighairigh Date: Thu, 20 Jun 2019 18:28:21 +0100 Subject: [PATCH] tidy up naming --- app/app.go | 4 ++-- app/app_test.go | 16 ++++++++-------- app/export.go | 2 +- app/genesis.go | 4 ++-- app/genesis_test.go | 14 +++++++------- cmd/gaiad/main.go | 16 ++++++++-------- init/gentx.go | 2 +- init/init_test.go | 6 +++--- init/testnet.go | 8 ++++---- init/validate_genesis.go | 2 +- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/app/app.go b/app/app.go index 1f1fcd87..c20931ab 100644 --- a/app/app.go +++ b/app/app.go @@ -285,7 +285,7 @@ func (app *App) initFromGenesisState(ctx sdk.Context, genesisState GenesisState) mint.InitGenesis(ctx, app.mintKeeper, genesisState.MintData) // validate genesis state - if err := GaiaValidateGenesisState(genesisState); err != nil { + if err := ValidateGenesisState(genesisState); err != nil { panic(err) // TODO find a way to do this w/o panics } @@ -308,7 +308,7 @@ func (app *App) initFromGenesisState(ctx sdk.Context, genesisState GenesisState) return validators } -// custom logic for gaia initialization +// custom logic for app initialization func (app *App) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain { stateJSON := req.AppStateBytes // TODO is this now the whole genesis file? diff --git a/app/app_test.go b/app/app_test.go index 0378705f..d2b0c890 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -22,7 +22,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" ) -func setGenesis(gapp *App, accs ...*auth.BaseAccount) error { +func setGenesis(app *App, accs ...*auth.BaseAccount) error { genaccs := make([]GenesisAccount, len(accs)) for i, acc := range accs { genaccs[i] = NewGenesisAccount(acc) @@ -40,26 +40,26 @@ func setGenesis(gapp *App, accs ...*auth.BaseAccount) error { slashing.DefaultGenesisState(), ) - stateBytes, err := codec.MarshalJSONIndent(gapp.cdc, genesisState) + stateBytes, err := codec.MarshalJSONIndent(app.cdc, genesisState) if err != nil { return err } // Initialize the chain vals := []abci.ValidatorUpdate{} - gapp.InitChain(abci.RequestInitChain{Validators: vals, AppStateBytes: stateBytes}) - gapp.Commit() + app.InitChain(abci.RequestInitChain{Validators: vals, AppStateBytes: stateBytes}) + app.Commit() return nil } func TestExport(t *testing.T) { db := db.NewMemDB() - gapp := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0) - setGenesis(gapp) + app := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0) + setGenesis(app) // Making a new app object with the db, so that initchain hasn't been called - newGapp := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0) - _, _, err := newGapp.ExportAppStateAndValidators(false, []string{}) + newApp := NewApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, 0) + _, _, err := newApp.ExportAppStateAndValidators(false, []string{}) require.NoError(t, err, "ExportAppStateAndValidators should not have an error") } diff --git a/app/export.go b/app/export.go index d8db72e4..d8dfe017 100644 --- a/app/export.go +++ b/app/export.go @@ -19,7 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking" ) -// export the state of gaia for a genesis file +// export the state of the app for a genesis file func (app *App) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList []string) ( appState json.RawMessage, validators []tmtypes.GenesisValidator, err error) { diff --git a/app/genesis.go b/app/genesis.go index 886c76a2..572c4a32 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -218,11 +218,11 @@ func NewDefaultGenesisState() GenesisState { } } -// GaiaValidateGenesisState ensures that the genesis state obeys the expected invariants +// ValidateGenesisState ensures that the genesis state obeys the expected invariants // TODO: No validators are both bonded and jailed (#2088) // TODO: Error if there is a duplicate validator (#1708) // TODO: Ensure all state machine parameters are in genesis (#1704) -func GaiaValidateGenesisState(genesisState GenesisState) error { +func ValidateGenesisState(genesisState GenesisState) error { if err := validateGenesisStateAccounts(genesisState.Accounts); err != nil { return err } diff --git a/app/genesis_test.go b/app/genesis_test.go index 2619f9ba..e16f5299 100644 --- a/app/genesis_test.go +++ b/app/genesis_test.go @@ -109,23 +109,23 @@ func makeMsg(name string, pk crypto.PubKey) auth.StdTx { return auth.NewStdTx([]sdk.Msg{msg}, auth.StdFee{}, nil, "") } -func TestGaiaGenesisValidation(t *testing.T) { +func TestGenesisValidation(t *testing.T) { genTxs := []auth.StdTx{makeMsg("test-0", pk1), makeMsg("test-1", pk2)} dupGenTxs := []auth.StdTx{makeMsg("test-0", pk1), makeMsg("test-1", pk1)} // require duplicate accounts fails validation genesisState := makeGenesisState(t, dupGenTxs) - err := GaiaValidateGenesisState(genesisState) + err := ValidateGenesisState(genesisState) require.Error(t, err) // require invalid vesting account fails validation (invalid end time) genesisState = makeGenesisState(t, genTxs) genesisState.Accounts[0].OriginalVesting = genesisState.Accounts[0].Coins - err = GaiaValidateGenesisState(genesisState) + err = ValidateGenesisState(genesisState) require.Error(t, err) genesisState.Accounts[0].StartTime = 1548888000 genesisState.Accounts[0].EndTime = 1548775410 - err = GaiaValidateGenesisState(genesisState) + err = ValidateGenesisState(genesisState) require.Error(t, err) // require bonded + jailed validator fails validation @@ -134,7 +134,7 @@ func TestGaiaGenesisValidation(t *testing.T) { val1.Jailed = true val1.Status = sdk.Bonded genesisState.StakingData.Validators = append(genesisState.StakingData.Validators, val1) - err = GaiaValidateGenesisState(genesisState) + err = ValidateGenesisState(genesisState) require.Error(t, err) // require duplicate validator fails validation @@ -143,7 +143,7 @@ func TestGaiaGenesisValidation(t *testing.T) { val2 := staking.NewValidator(addr1, pk1, staking.NewDescription("test #3", "", "", "")) genesisState.StakingData.Validators = append(genesisState.StakingData.Validators, val1) genesisState.StakingData.Validators = append(genesisState.StakingData.Validators, val2) - err = GaiaValidateGenesisState(genesisState) + err = ValidateGenesisState(genesisState) require.Error(t, err) } @@ -156,7 +156,7 @@ func TestNewDefaultGenesisAccount(t *testing.T) { func TestGenesisStateSanitize(t *testing.T) { genesisState := makeGenesisState(t, nil) - require.Nil(t, GaiaValidateGenesisState(genesisState)) + require.Nil(t, ValidateGenesisState(genesisState)) addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) authAcc1 := auth.NewBaseAccountWithAddress(addr1) diff --git a/cmd/gaiad/main.go b/cmd/gaiad/main.go index 076016ff..004ca350 100644 --- a/cmd/gaiad/main.go +++ b/cmd/gaiad/main.go @@ -19,7 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/kava-labs/kava/app" - gaiaInit "github.com/kava-labs/kava/init" + initPkg "github.com/kava-labs/kava/init" ) // kvd custom flags @@ -40,16 +40,16 @@ func main() { cobra.EnableCommandSorting = false rootCmd := &cobra.Command{ Use: "kvd", - Short: "Gaia Daemon (server)", + Short: "Kava Daemon (server)", PersistentPreRunE: server.PersistentPreRunEFn(ctx), } - rootCmd.AddCommand(gaiaInit.InitCmd(ctx, cdc)) - rootCmd.AddCommand(gaiaInit.CollectGenTxsCmd(ctx, cdc)) - rootCmd.AddCommand(gaiaInit.TestnetFilesCmd(ctx, cdc)) - rootCmd.AddCommand(gaiaInit.GenTxCmd(ctx, cdc)) - rootCmd.AddCommand(gaiaInit.AddGenesisAccountCmd(ctx, cdc)) - rootCmd.AddCommand(gaiaInit.ValidateGenesisCmd(ctx, cdc)) + rootCmd.AddCommand(initPkg.InitCmd(ctx, cdc)) + rootCmd.AddCommand(initPkg.CollectGenTxsCmd(ctx, cdc)) + rootCmd.AddCommand(initPkg.TestnetFilesCmd(ctx, cdc)) + rootCmd.AddCommand(initPkg.GenTxCmd(ctx, cdc)) + rootCmd.AddCommand(initPkg.AddGenesisAccountCmd(ctx, cdc)) + rootCmd.AddCommand(initPkg.ValidateGenesisCmd(ctx, cdc)) rootCmd.AddCommand(client.NewCompletionCmd(rootCmd, true)) server.AddCommands(ctx, cdc, rootCmd, newApp, exportAppStateAndTMValidators) diff --git a/init/gentx.go b/init/gentx.go index 8c66cf16..3c7c3926 100644 --- a/init/gentx.go +++ b/init/gentx.go @@ -89,7 +89,7 @@ following delegation and commission default parameters: return err } - if err = app.GaiaValidateGenesisState(genesisState); err != nil { + if err = app.ValidateGenesisState(genesisState); err != nil { return err } diff --git a/init/init_test.go b/init/init_test.go index 48f91339..1f06dd74 100644 --- a/init/init_test.go +++ b/init/init_test.go @@ -32,7 +32,7 @@ func TestInitCmd(t *testing.T) { cdc := app.MakeCodec() cmd := InitCmd(ctx, cdc) - require.NoError(t, cmd.RunE(nil, []string{"gaianode-test"})) + require.NoError(t, cmd.RunE(nil, []string{"kavanode-test"})) } func setupClientHome(t *testing.T) func() { @@ -59,7 +59,7 @@ func TestEmptyState(t *testing.T) { cdc := app.MakeCodec() cmd := InitCmd(ctx, cdc) - require.NoError(t, cmd.RunE(nil, []string{"gaianode-test"})) + require.NoError(t, cmd.RunE(nil, []string{"kavanode-test"})) old := os.Stdout r, w, _ := os.Pipe() @@ -101,7 +101,7 @@ func TestStartStandAlone(t *testing.T) { ctx := server.NewContext(cfg, logger) cdc := app.MakeCodec() initCmd := InitCmd(ctx, cdc) - require.NoError(t, initCmd.RunE(nil, []string{"gaianode-test"})) + require.NoError(t, initCmd.RunE(nil, []string{"kavanode-test"})) app, err := mock.NewApp(home, logger) require.Nil(t, err) diff --git a/init/testnet.go b/init/testnet.go index cde2fed4..80d7cf83 100644 --- a/init/testnet.go +++ b/init/testnet.go @@ -106,8 +106,8 @@ func initTestnet(config *tmconfig.Config, cdc *codec.Codec) error { nodeIDs := make([]string, numValidators) valPubKeys := make([]crypto.PubKey, numValidators) - gaiaConfig := srvconfig.DefaultConfig() - gaiaConfig.MinGasPrices = viper.GetString(server.FlagMinGasPrices) + appConfig := srvconfig.DefaultConfig() + appConfig.MinGasPrices = viper.GetString(server.FlagMinGasPrices) var ( accs []app.GenesisAccount @@ -236,8 +236,8 @@ func initTestnet(config *tmconfig.Config, cdc *codec.Codec) error { return err } - gaiaConfigFilePath := filepath.Join(nodeDir, "config/kvd.toml") - srvconfig.WriteConfigFile(gaiaConfigFilePath, gaiaConfig) + appConfigFilePath := filepath.Join(nodeDir, "config/kvd.toml") + srvconfig.WriteConfigFile(appConfigFilePath, appConfig) } if err := initGenFiles(cdc, chainID, accs, genFiles, numValidators); err != nil { diff --git a/init/validate_genesis.go b/init/validate_genesis.go index 852c8761..7535fe73 100644 --- a/init/validate_genesis.go +++ b/init/validate_genesis.go @@ -40,7 +40,7 @@ func ValidateGenesisCmd(ctx *server.Context, cdc *codec.Codec) *cobra.Command { return fmt.Errorf("Error unmarshaling genesis doc %s: %s", genesis, err.Error()) } - if err = app.GaiaValidateGenesisState(genstate); err != nil { + if err = app.ValidateGenesisState(genstate); err != nil { return fmt.Errorf("Error validating genesis file %s: %s", genesis, err.Error()) }