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: migrate e2e/auth to system tests and fix sign-batch #22149

Merged
merged 16 commits into from
Oct 11, 2024
Merged
24 changes: 22 additions & 2 deletions client/account_retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ type Account interface {
GetSequence() uint64
}

type mockAccount struct {
addr []byte
}

func (m mockAccount) GetAddress() sdk.AccAddress {
return m.addr
}

func (m mockAccount) GetPubKey() cryptotypes.PubKey {
return nil
}

func (m mockAccount) GetAccountNumber() uint64 {
return 0
}

func (m mockAccount) GetSequence() uint64 {
return 0
}
Comment on lines +24 to +34
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider making mock values configurable

The implementation of GetPubKey, GetAccountNumber, and GetSequence methods is correct for a basic mock. However, to enhance flexibility in testing scenarios, consider making these values configurable. This would allow tests to set specific values when needed.

Here's a suggested implementation:

type mockAccount struct {
	address []byte
	pubKey  cryptotypes.PubKey
	accNum  uint64
	seq     uint64
}

func (m mockAccount) GetPubKey() cryptotypes.PubKey {
	return m.pubKey
}

func (m mockAccount) GetAccountNumber() uint64 {
	return m.accNum
}

func (m mockAccount) GetSequence() uint64 {
	return m.seq
}

This change would require updating the MockAccountRetriever.GetAccount method to initialize these fields.


// AccountRetriever defines the interfaces required by transactions to
// ensure an account exists and to be able to query for account fields necessary
// for signing.
Expand All @@ -32,8 +52,8 @@ type MockAccountRetriever struct {
ReturnAccNum, ReturnAccSeq uint64
}

func (mar MockAccountRetriever) GetAccount(_ Context, _ sdk.AccAddress) (Account, error) {
return nil, nil
func (mar MockAccountRetriever) GetAccount(_ Context, address sdk.AccAddress) (Account, error) {
return mockAccount{addr: address}, nil
}

func (mar MockAccountRetriever) GetAccountWithHeight(_ Context, _ sdk.AccAddress) (Account, int64, error) {
Expand Down
20 changes: 0 additions & 20 deletions tests/e2e/auth/cli_test.go

This file was deleted.

Loading
Loading