-
Notifications
You must be signed in to change notification settings - Fork 639
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: account/keeper tests for ICA #420
Changes from all commits
670f139
a5ada7d
61eae32
4c27d87
4b63f25
c85b8c7
b2a61ec
d9d2392
af21f8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,15 +187,15 @@ func (am AppModule) OnChanCloseInit( | |
channelID string, | ||
) error { | ||
// Disallow user-initiated channel closing for interchain account channels | ||
return nil | ||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @colin-axner updating chan closing capabilities |
||
} | ||
|
||
func (am AppModule) OnChanCloseConfirm( | ||
ctx sdk.Context, | ||
portID, | ||
channelID string, | ||
) error { | ||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") | ||
return nil | ||
} | ||
|
||
func (am AppModule) OnRecvPacket( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import ( | |
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
"github.com/tendermint/tendermint/crypto/tmhash" | ||
yaml "gopkg.in/yaml.v2" | ||
"gopkg.in/yaml.v2" | ||
|
||
connectiontypes "github.com/cosmos/ibc-go/v2/modules/core/03-connection/types" | ||
) | ||
|
@@ -66,40 +66,44 @@ func NewInterchainAccount(ba *authtypes.BaseAccount, accountOwner string) *Inter | |
} | ||
|
||
// SetPubKey - Implements AccountI | ||
func (InterchainAccount) SetPubKey(pubKey crypto.PubKey) error { | ||
return fmt.Errorf("not supported for interchain accounts") | ||
func (ia InterchainAccount) SetPubKey(pubKey crypto.PubKey) error { | ||
return sdkerrors.Wrap(ErrUnsupported, "cannot set public key for interchain account") | ||
} | ||
|
||
// SetSequence - Implements AccountI | ||
func (InterchainAccount) SetSequence(seq uint64) error { | ||
return fmt.Errorf("not supported for interchain accounts") | ||
func (ia InterchainAccount) SetSequence(seq uint64) error { | ||
return sdkerrors.Wrap(ErrUnsupported, "cannot set sequence number for interchain account") | ||
} | ||
|
||
func (ia InterchainAccount) Validate() error { | ||
if strings.TrimSpace(ia.AccountOwner) == "" { | ||
return sdkerrors.Wrap(ErrInvalidAccountAddress, "AccountOwner cannot be empty") | ||
} | ||
|
||
return ia.BaseAccount.Validate() | ||
} | ||
|
||
type ibcAccountPretty struct { | ||
type InterchainAccountPretty struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tiny nit: can we make this unexposed/private? |
||
Address sdk.AccAddress `json:"address" yaml:"address"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This field There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Updated. |
||
PubKey string `json:"public_key" yaml:"public_key"` | ||
AccountNumber uint64 `json:"account_number" yaml:"account_number"` | ||
Sequence uint64 `json:"sequence" yaml:"sequence"` | ||
AccountOwner string `json:"address" yaml:"account_owner"` | ||
AccountOwner string `json:"account_owner" yaml:"account_owner"` | ||
} | ||
|
||
func (ia InterchainAccount) String() string { | ||
out, _ := ia.MarshalYAML() | ||
return out.(string) | ||
return string(out) | ||
} | ||
|
||
// MarshalYAML returns the YAML representation of a InterchainAccount. | ||
func (ia InterchainAccount) MarshalYAML() (interface{}, error) { | ||
// MarshalYAML returns the YAML representation of an InterchainAccount | ||
func (ia InterchainAccount) MarshalYAML() ([]byte, error) { | ||
accAddr, err := sdk.AccAddressFromBech32(ia.Address) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
bs, err := yaml.Marshal(ibcAccountPretty{ | ||
bz, err := yaml.Marshal(InterchainAccountPretty{ | ||
Address: accAddr, | ||
PubKey: "", | ||
AccountNumber: ia.AccountNumber, | ||
|
@@ -111,28 +115,34 @@ func (ia InterchainAccount) MarshalYAML() (interface{}, error) { | |
return nil, err | ||
} | ||
|
||
return string(bs), nil | ||
return bz, nil | ||
} | ||
|
||
// MarshalJSON returns the JSON representation of a InterchainAccount. | ||
// MarshalJSON returns the JSON representation of an InterchainAccount. | ||
func (ia InterchainAccount) MarshalJSON() ([]byte, error) { | ||
accAddr, err := sdk.AccAddressFromBech32(ia.Address) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return json.Marshal(ibcAccountPretty{ | ||
bz, err := json.Marshal(InterchainAccountPretty{ | ||
Address: accAddr, | ||
PubKey: "", | ||
AccountNumber: ia.AccountNumber, | ||
Sequence: ia.Sequence, | ||
AccountOwner: ia.AccountOwner, | ||
}) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return bz, nil | ||
} | ||
|
||
// UnmarshalJSON unmarshals raw JSON bytes into a ModuleAccount. | ||
func (ia *InterchainAccount) UnmarshalJSON(bz []byte) error { | ||
var alias ibcAccountPretty | ||
var alias InterchainAccountPretty | ||
if err := json.Unmarshal(bz, &alias); err != nil { | ||
return err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't used anywhere. Some leftover code from the previous implementation I think.