Skip to content

Commit

Permalink
addresses first round of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
staheri14 committed Apr 4, 2024
1 parent de60542 commit d580860
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 33 deletions.
2 changes: 1 addition & 1 deletion test/e2e/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestE2ESimple(t *testing.T) {
0, defaultResources))

t.Log("Creating account")
kr, err := testnet.CreateAccount("alice", 1e12)
kr, err := testnet.CreateAccount("alice", 1e12, "")
require.NoError(t, err)

t.Log("Setting up testnet")
Expand Down
42 changes: 15 additions & 27 deletions test/e2e/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (t *Testnet) CreateTxClient(name,
Str("name", name).
Str("directory", txsimKeyringDir).
Msg("txsim keyring directory created")
_, err := t.CreateAndAddAccountToGenesis(name, 1e16, txsimKeyringDir)
_, err := t.CreateAccount(name, 1e16, txsimKeyringDir)
if err != nil {
return err
}
Expand Down Expand Up @@ -172,14 +172,23 @@ func (t *Testnet) StartTxClients() error {
return nil
}

// CreateAndAddAccountToGenesis creates an account and adds it to the
// CreateAccount creates an account and adds it to the
// testnet genesis. The account is created with the given name and tokens and
// is persisted in the given txsimKeyringDir.
func (t *Testnet) CreateAndAddAccountToGenesis(name string, tokens int64, txsimKeyringDir string) (keyring.Keyring, error) {
// If txsimKeyringDir is an empty string, an in-memory keyring is created.
func (t *Testnet) CreateAccount(name string, tokens int64, txsimKeyringDir string) (keyring.Keyring, error) {
cdc := encoding.MakeConfig(app.ModuleEncodingRegisters...).Codec
kr, err := keyring.New(app.Name, keyring.BackendTest, txsimKeyringDir, nil, cdc)
if err != nil {
return nil, err
var kr keyring.Keyring
var err error
// if no keyring directory is specified, create an in-memory keyring
if txsimKeyringDir == "" {
kr = keyring.NewInMemory(cdc)
} else { // create a keyring with the specified directory
kr, err = keyring.New(app.Name, keyring.BackendTest,
txsimKeyringDir, nil, cdc)
if err != nil {
return nil, err
}
}
key, _, err := kr.NewMnemonic(name, keyring.English, "", "", hd.Secp256k1)
if err != nil {
Expand Down Expand Up @@ -216,27 +225,6 @@ func (t *Testnet) CreateNode(version string, startHeight, upgradeHeight int64, r
return nil
}

func (t *Testnet) CreateAccount(name string, tokens int64) (keyring.Keyring, error) {
cdc := encoding.MakeConfig(app.ModuleEncodingRegisters...).Codec
kr := keyring.NewInMemory(cdc)
key, _, err := kr.NewMnemonic(name, keyring.English, "", "", hd.Secp256k1)
if err != nil {
return nil, err
}
pk, err := key.GetPubKey()
if err != nil {
return nil, err
}
err = t.genesis.AddAccount(genesis.Account{
PubKey: pk,
Balance: tokens,
})
if err != nil {
return nil, err
}
return kr, nil
}

func (t *Testnet) Setup() error {
genesis, err := t.genesis.Export()
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/throughput_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestE2EThroughput(t *testing.T) {
if os.Getenv("KNUU_NAMESPACE") != "test" {
if os.Getenv("KNUU_NAMESPACE") != "test-sanaz" {
t.Skip("skipping e2e throughput test")
}

Expand Down Expand Up @@ -53,9 +53,9 @@ func TestE2EThroughput(t *testing.T) {
// create txsim nodes and point them to the validators
t.Log("Creating txsim nodes")
// version of the txsim docker image to be used
txsimVersion := "90a5d2d"
txsimVersion := latestVersion

err = testnet.CreateTxClients(txsimVersion, seed, 1, "10000-10000", 3, defaultResources, gRPCEndpoints)
err = testnet.CreateTxClients(txsimVersion, 1, "10000-10000", 3, defaultResources, gRPCEndpoints)
require.NoError(t, err)

// start the testnet
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestMinorVersionCompatibility(t *testing.T) {
require.NoError(t, testnet.CreateGenesisNode(v, 10000000, 0, defaultResources))
}

kr, err := testnet.CreateAccount("alice", 1e12)
kr, err := testnet.CreateAccount("alice", 1e12, "")
require.NoError(t, err)

require.NoError(t, testnet.Setup())
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestMajorUpgradeToV2(t *testing.T) {
upgradeHeight, defaultResources))
}

kr, err := testnet.CreateAccount("alice", 1e12)
kr, err := testnet.CreateAccount("alice", 1e12, "")
require.NoError(t, err)

require.NoError(t, testnet.Setup())
Expand Down

0 comments on commit d580860

Please sign in to comment.