Skip to content

Commit

Permalink
Reply to some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Olshansk committed Nov 7, 2023
1 parent 5f6a9ec commit f4b3e7e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion x/supplier/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ var (
ErrSupplierInvalidSessionStartHeight = sdkerrors.Register(ModuleName, 6, "invalid session start height")
ErrSupplierInvalidSessionId = sdkerrors.Register(ModuleName, 7, "invalid session ID")
ErrSupplierInvalidService = sdkerrors.Register(ModuleName, 8, "invalid service")
ErrSupplierInvalidRootHash = sdkerrors.Register(ModuleName, 9, "invalid root hash")
ErrSupplierInvalidClaimRootHash = sdkerrors.Register(ModuleName, 9, "invalid root hash")
)
2 changes: 1 addition & 1 deletion x/supplier/types/message_create_claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (msg *MsgCreateClaim) ValidateBasic() error {
// Validate the root hash
// TODO_IMPROVE: Only checking to make sure a non-nil hash was provided for now, but we can validate the length as well.
if len(msg.RootHash) == 0 {
return sdkerrors.Wrapf(ErrSupplierInvalidRootHash, "invalid root hash (%v)", msg.RootHash)
return sdkerrors.Wrapf(ErrSupplierInvalidClaimRootHash, "invalid root hash (%v)", msg.RootHash)
}

return nil
Expand Down
18 changes: 9 additions & 9 deletions x/supplier/types/message_create_claim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ import (

func TestMsgCreateClaim_ValidateBasic(t *testing.T) {
tests := []struct {
testCase string
desc string

msg MsgCreateClaim
err error
}{
{
testCase: "invalid address",
desc: "invalid address",

msg: MsgCreateClaim{
SupplierAddress: "invalid_address",
},
err: ErrSupplierInvalidAddress,
},
{
testCase: "valid address but invalid session start height",
desc: "valid address but invalid session start height",

msg: MsgCreateClaim{
SupplierAddress: sample.AccAddress(),
Expand All @@ -37,7 +37,7 @@ func TestMsgCreateClaim_ValidateBasic(t *testing.T) {
err: ErrSupplierInvalidSessionStartHeight,
},
{
testCase: "valid address and session start height but invalid session ID",
desc: "valid address and session start height but invalid session ID",

msg: MsgCreateClaim{
SupplierAddress: sample.AccAddress(),
Expand All @@ -49,7 +49,7 @@ func TestMsgCreateClaim_ValidateBasic(t *testing.T) {
err: ErrSupplierInvalidSessionId,
},
{
testCase: "valid address, session start height, session ID but invalid service",
desc: "valid address, session start height, session ID but invalid service",

msg: MsgCreateClaim{
SupplierAddress: sample.AccAddress(),
Expand All @@ -64,7 +64,7 @@ func TestMsgCreateClaim_ValidateBasic(t *testing.T) {
err: ErrSupplierInvalidService,
},
{
testCase: "valid address, session start height, session ID, service but invalid root hash",
desc: "valid address, session start height, session ID, service but invalid root hash",

msg: MsgCreateClaim{
SupplierAddress: sample.AccAddress(),
Expand All @@ -77,10 +77,10 @@ func TestMsgCreateClaim_ValidateBasic(t *testing.T) {
},
RootHash: []byte(""), // Invalid root hash
},
err: ErrSupplierInvalidRootHash,
err: ErrSupplierInvalidClaimRootHash,
},
{
testCase: "all valid inputs",
desc: "all valid inputs",

msg: MsgCreateClaim{
SupplierAddress: sample.AccAddress(),
Expand All @@ -97,7 +97,7 @@ func TestMsgCreateClaim_ValidateBasic(t *testing.T) {
},
}
for _, tt := range tests {
t.Run(tt.testCase, func(t *testing.T) {
t.Run(tt.desc, func(t *testing.T) {
err := tt.msg.ValidateBasic()
if tt.err != nil {
require.ErrorIs(t, err, tt.err)
Expand Down

0 comments on commit f4b3e7e

Please sign in to comment.