Rework the process of loading a genesis.json file to load a starting app state and set of initial transactions to process.
* New function to create genesis account from MsgCreateValidator
* Add arg to PrintUnsignedStdTx() to actually operate in offline mode
* New func processStdTxs()
* Remove gen-tx command
* Cleanup, return validators as they need to be written into genesis.json
* Modify gaiad init to allow auto-create of stdTx
* Remove server/testnet.go
* Don't load node_key.json, which might not be available
* Get the txs through DeliverTx
* Add app.slashingKeeper.AddValidators at the end of genesis
* On InitChain(), Signature's account number must be 0
* Add (tentative?) command to generate {node_key,priv_validator}.json files
* Reintroduce gaiad testnet
* Prompt user for passwords
* Update gaia to work with auth.StdTx
* Remove test_utils, NewTestGaiaAppGenState is now deprecated
* Combine --genesis-format and --generate-only
* Improve sign command's --offline flag documentation
* Moniker must be set
* Call app.slashingKeeper.AddValidators() even if len(txs) == 0
* Refactoring, introduce gaiad init --skip-genesis, code cleanup
* Drop unnecessary workaround to make lcd_tests pass
* Reintroduce gentx
* Simple name changes, GenesisState.Txs -> .GenTxs; OWK -> OverwriteKey; OverwriteKeys -> OverwriteKey
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package clitest
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
|
"github.com/cosmos/cosmos-sdk/server"
|
|
"github.com/cosmos/cosmos-sdk/tests"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
var (
|
|
basecoindHome = ""
|
|
basecliHome = ""
|
|
)
|
|
|
|
func init() {
|
|
basecoindHome, basecliHome = getTestingHomeDirs()
|
|
}
|
|
|
|
func TestInitStartSequence(t *testing.T) {
|
|
os.RemoveAll(basecoindHome)
|
|
servAddr, port, err := server.FreeTCPAddr()
|
|
require.NoError(t, err)
|
|
executeInit(t)
|
|
executeStart(t, servAddr, port)
|
|
}
|
|
|
|
func executeInit(t *testing.T) {
|
|
var (
|
|
chainID string
|
|
initRes map[string]json.RawMessage
|
|
)
|
|
_, stderr := tests.ExecuteT(t, fmt.Sprintf("basecoind --home=%s --home-client=%s init --name=test", basecoindHome, basecliHome), app.DefaultKeyPass)
|
|
err := json.Unmarshal([]byte(stderr), &initRes)
|
|
require.NoError(t, err)
|
|
err = json.Unmarshal(initRes["chain_id"], &chainID)
|
|
require.NoError(t, err)
|
|
}
|
|
|
|
func executeStart(t *testing.T, servAddr, port string) {
|
|
proc := tests.GoExecuteTWithStdout(t, fmt.Sprintf("basecoind start --home=%s --rpc.laddr=%v", basecoindHome, servAddr))
|
|
defer proc.Stop(false)
|
|
tests.WaitForTMStart(port)
|
|
}
|
|
|
|
func getTestingHomeDirs() (string, string) {
|
|
tmpDir := os.TempDir()
|
|
basecoindHome := fmt.Sprintf("%s%s.test_basecoind", tmpDir, string(os.PathSeparator))
|
|
basecliHome := fmt.Sprintf("%s%s.test_basecli", tmpDir, string(os.PathSeparator))
|
|
return basecoindHome, basecliHome
|
|
}
|