-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(
fungible/types
): increase code coverage for types (#953)
* more samples * types coverage * imports
- Loading branch information
Showing
9 changed files
with
151 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package sample | ||
|
||
import ( | ||
"testing" | ||
|
||
ethcommon "github.com/ethereum/go-ethereum/common" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestEthAddress(t *testing.T) { | ||
ethAddress := EthAddress() | ||
require.NotEqual(t, ethcommon.Address{}, ethAddress) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package types | ||
|
||
import ( | ||
"testing" | ||
|
||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
"github.com/stretchr/testify/require" | ||
"github.com/zeta-chain/zetacore/testutil/sample" | ||
) | ||
|
||
func TestMsgUpdateSystemContract_ValidateBasic(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
msg MsgUpdateSystemContract | ||
err error | ||
}{ | ||
{ | ||
name: "invalid address", | ||
msg: MsgUpdateSystemContract{ | ||
Creator: "invalid_address", | ||
NewSystemContractAddress: sample.EthAddress().String(), | ||
}, | ||
err: sdkerrors.ErrInvalidAddress, | ||
}, | ||
{ | ||
name: "invalid new system contract address", | ||
msg: MsgUpdateSystemContract{ | ||
Creator: sample.AccAddress(), | ||
NewSystemContractAddress: "invalid_address", | ||
}, | ||
err: sdkerrors.ErrInvalidAddress, | ||
}, | ||
{ | ||
name: "valid message", | ||
msg: MsgUpdateSystemContract{ | ||
Creator: sample.AccAddress(), | ||
NewSystemContractAddress: sample.EthAddress().String(), | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
err := tt.msg.ValidateBasic() | ||
if tt.err != nil { | ||
require.ErrorIs(t, err, tt.err) | ||
return | ||
} | ||
require.NoError(t, err) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
x/fungible/types/message_update_zrc20_withdraw_fee_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package types | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
"github.com/stretchr/testify/require" | ||
"github.com/zeta-chain/zetacore/testutil/sample" | ||
) | ||
|
||
func TestMsgUpdateZRC20WithdrawFee_ValidateBasic(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
msg MsgUpdateZRC20WithdrawFee | ||
err error | ||
}{ | ||
{ | ||
name: "invalid address", | ||
msg: MsgUpdateZRC20WithdrawFee{ | ||
Creator: "invalid_address", | ||
Zrc20Address: sample.EthAddress().String(), | ||
NewWithdrawFee: sdk.NewUint(1), | ||
}, | ||
err: sdkerrors.ErrInvalidAddress, | ||
}, | ||
{ | ||
name: "invalid new system contract address", | ||
msg: MsgUpdateZRC20WithdrawFee{ | ||
Creator: sample.AccAddress(), | ||
Zrc20Address: "invalid_address", | ||
NewWithdrawFee: sdk.NewUint(1), | ||
}, | ||
err: sdkerrors.ErrInvalidAddress, | ||
}, | ||
{ | ||
name: "invalid new withdraw fee", | ||
msg: MsgUpdateZRC20WithdrawFee{ | ||
Creator: sample.AccAddress(), | ||
Zrc20Address: sample.EthAddress().String(), | ||
}, | ||
err: sdkerrors.ErrInvalidRequest, | ||
}, | ||
{ | ||
name: "valid message", | ||
msg: MsgUpdateZRC20WithdrawFee{ | ||
Creator: sample.AccAddress(), | ||
Zrc20Address: sample.EthAddress().String(), | ||
NewWithdrawFee: sdk.NewUint(1), | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
err := tt.msg.ValidateBasic() | ||
if tt.err != nil { | ||
require.ErrorIs(t, err, tt.err) | ||
return | ||
} | ||
require.NoError(t, err) | ||
}) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters