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

test: add Name to Account #3690

Merged
merged 2 commits into from
Jul 17, 2024
Merged
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
4 changes: 4 additions & 0 deletions test/util/genesis/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func accountsToSDKTypes(accounts []Account) ([]banktypes.Balance, []authtypes.Ge
type Account struct {
PubKey cryptotypes.PubKey
Balance int64
Name string
}

func (ga Account) ValidateBasic() error {
Expand All @@ -119,5 +120,8 @@ func (ga Account) ValidateBasic() error {
if ga.Balance <= 0 {
return fmt.Errorf("balance must be greater than 0")
}
if ga.Name == "" {
return fmt.Errorf("name cannot be empty")
}
return nil
}
1 change: 1 addition & 0 deletions test/util/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func (g *Genesis) NewAccount(acc KeyringAccount) error {
account := Account{
PubKey: pubKey,
Balance: acc.InitialTokens,
Name: acc.Name,
}

g.accounts = append(g.accounts, account)
Expand Down
4 changes: 3 additions & 1 deletion test/util/test_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ func SetupDeterministicGenesisState(testApp *app.App, pubKeys []cryptotypes.PubK
WithGenesisTime(time.Date(2023, 1, 1, 1, 1, 1, 1, time.UTC).UTC())

// add accounts to genesis
for _, pk := range pubKeys {
for i, pk := range pubKeys {
err := gen.AddAccount(genesis.Account{
PubKey: pk,
Balance: balance,
Name: fmt.Sprintf("%v", i),
})
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -237,6 +238,7 @@ func AddDeterministicValidatorToGenesis(g *genesis.Genesis) error {
account := genesis.Account{
PubKey: validatorPubKey,
Balance: val.KeyringAccount.InitialTokens,
Name: val.Name,
}

// add the validator's account to the genesis
Expand Down
Loading