* Migrate encode, decode, and broadcast cmd's to use TxGenerator marshal methods * Fix tests, add EncodingConfig * Add simapp/encoding.go and wire up with simcli * add godocs * fix tests * Debugging CLI Tests * Fix integration test * 6391 - lint issues and code coverage (#6414) * fixed lint issue of "txEncodeRespStr" * added tests for encode.go * WIP: added tests for decode.go * added txEncoder at bytes * updated decode test * updated txBytes to use TxEncoder in decoder test * added a require after TxEncoder * removed file save * debug decode command * fixed decode tests * added decode cli * updated encode and decode in a single file * separated decode test from encode test * review changes * removed register interface * review change * Fix tests * WIP add test for tx sign * removed commented code * Fix flags * WIP add test for sign * Address review suggestions * fixed command issue * Add tests for TxEncoder * Revert sign changes * Fix TxEncoder tests * Fix GetSign Cmd * Add tx test * Remove duplicate validation * Add tests for TxDecoder * Fix tests * Fix tests * Output to clientCtx.Output * Fix cli_tests Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com> Co-authored-by: atheesh <atheesh@vitwit.com> Co-authored-by: anilCSE <anil@vitwit.com> Co-authored-by: sahith-narahari <sahithnarahari@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
37 lines
948 B
Go
37 lines
948 B
Go
package client
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
// TestAccountRetriever is an AccountRetriever that can be used in unit tests
|
|
type TestAccountRetriever struct {
|
|
Accounts map[string]struct {
|
|
Address sdk.AccAddress
|
|
Num uint64
|
|
Seq uint64
|
|
}
|
|
}
|
|
|
|
var _ AccountRetriever = TestAccountRetriever{}
|
|
|
|
// EnsureExists implements AccountRetriever.EnsureExists
|
|
func (t TestAccountRetriever) EnsureExists(_ NodeQuerier, addr sdk.AccAddress) error {
|
|
_, ok := t.Accounts[addr.String()]
|
|
if !ok {
|
|
return fmt.Errorf("account %s not found", addr)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetAccountNumberSequence implements AccountRetriever.GetAccountNumberSequence
|
|
func (t TestAccountRetriever) GetAccountNumberSequence(_ NodeQuerier, addr sdk.AccAddress) (accNum uint64, accSeq uint64, err error) {
|
|
acc, ok := t.Accounts[addr.String()]
|
|
if !ok {
|
|
return 0, 0, fmt.Errorf("account %s not found", addr)
|
|
}
|
|
return acc.Num, acc.Seq, nil
|
|
}
|