Skip to content

Commit

Permalink
test: add Name to Account (backport #3690) (#3695)
Browse files Browse the repository at this point in the history
There are a few places in celestia-node where I want to use the account
names from testnode but they weren't persisted/exposed prior to this
PR.<hr>This is an automatic backport of pull request #3690 done by
[Mergify](https://mergify.com).

Co-authored-by: Rootul P <[email protected]>
  • Loading branch information
mergify[bot] and rootulp authored Jul 17, 2024
1 parent 43a360e commit 76cd246
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
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

0 comments on commit 76cd246

Please sign in to comment.