mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-27 00:35:18 +00:00
message test
This commit is contained in:
parent
71742d2eef
commit
2327b01ed4
@ -9,34 +9,52 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestMsgPlaceBid_ValidateBasic(t *testing.T) {
|
func TestMsgPlaceBid_ValidateBasic(t *testing.T) {
|
||||||
addr := sdk.AccAddress([]byte("someName"))
|
addr, err := sdk.AccAddressFromBech32(testAccAddress1)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
msg MsgPlaceBid
|
msg MsgPlaceBid
|
||||||
expectPass bool
|
expectPass bool
|
||||||
}{
|
}{
|
||||||
{"normal",
|
{
|
||||||
|
"normal",
|
||||||
|
NewMsgPlaceBid(1, addr, c("token", 10)),
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"zero id",
|
||||||
NewMsgPlaceBid(0, addr, c("token", 10)),
|
NewMsgPlaceBid(0, addr, c("token", 10)),
|
||||||
true},
|
false,
|
||||||
{"emptyAddr",
|
},
|
||||||
NewMsgPlaceBid(0, sdk.AccAddress{}, c("token", 10)),
|
{
|
||||||
false},
|
"empty address ",
|
||||||
{"negativeAmount",
|
NewMsgPlaceBid(1, nil, c("token", 10)),
|
||||||
NewMsgPlaceBid(0, addr, sdk.Coin{Denom: "token", Amount: sdk.NewInt(-10)}),
|
false,
|
||||||
false},
|
},
|
||||||
{"zeroAmount",
|
{
|
||||||
NewMsgPlaceBid(0, addr, c("token", 0)),
|
"invalid address",
|
||||||
true},
|
NewMsgPlaceBid(1, addr[:10], c("token", 10)),
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"negative amount",
|
||||||
|
NewMsgPlaceBid(1, addr, sdk.Coin{Denom: "token", Amount: sdk.NewInt(-10)}),
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"zero amount",
|
||||||
|
NewMsgPlaceBid(1, addr, c("token", 0)),
|
||||||
|
true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
|
||||||
if tc.expectPass {
|
if tc.expectPass {
|
||||||
require.NoError(t, tc.msg.ValidateBasic())
|
require.NoError(t, tc.msg.ValidateBasic(), tc.name)
|
||||||
} else {
|
} else {
|
||||||
require.Error(t, tc.msg.ValidateBasic())
|
require.Error(t, tc.msg.ValidateBasic(), tc.name)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user