diff --git a/x/backing/handler_test.go b/x/backing/handler_test.go index decc22c3..ad88ef1e 100644 --- a/x/backing/handler_test.go +++ b/x/backing/handler_test.go @@ -72,3 +72,12 @@ func TestBackStoryMsg(t *testing.T) { assert.Equal(t, int64(1), idres.ID, "incorrect result backing id") } + +func TestByzantineMsg(t *testing.T) { + ctx, bk, _, _, _, _ := mockDB() + h := NewHandler(bk) + assert.NotNil(t, h) + res := h(ctx, nil) + assert.Equal(t, sdk.CodeUnknownRequest, res.Code) + assert.Equal(t, sdk.CodespaceRoot, res.Codespace) +} diff --git a/x/backing/msg_test.go b/x/backing/msg_test.go index a4032f3b..92f0019b 100644 --- a/x/backing/msg_test.go +++ b/x/backing/msg_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "github.com/TruStory/truchain/x/story" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" ) @@ -33,7 +34,7 @@ func TestInvalidStoryIdBackMsg(t *testing.T) { msg := NewBackStoryMsg(invalidStoryID, validStake, validArgument, validCreator, validPeriod) err := msg.ValidateBasic() - assert.Equal(t, sdk.CodeType(702), err.Code(), err.Error()) + assert.Equal(t, story.CodeInvalidStoryID, err.Code(), err.Error()) } func TestInvalidAddressBackMsg(t *testing.T) { @@ -45,7 +46,7 @@ func TestInvalidAddressBackMsg(t *testing.T) { msg := NewBackStoryMsg(validStoryID, validStake, validArgument, invalidCreator, validPeriod) err := msg.ValidateBasic() - assert.Equal(t, sdk.CodeType(7), err.Code(), err.Error()) + assert.Equal(t, sdk.CodeInvalidAddress, err.Code(), err.Error()) } func TestInValidStakeBackMsg(t *testing.T) { @@ -57,7 +58,7 @@ func TestInValidStakeBackMsg(t *testing.T) { msg := NewBackStoryMsg(validStoryID, invalidStake, validArgument, validCreator, validPeriod) err := msg.ValidateBasic() - assert.Equal(t, sdk.CodeType(5), err.Code(), err.Error()) + assert.Equal(t, sdk.CodeInsufficientFunds, err.Code(), err.Error()) } func TestInValidBackingPeriodBackMsg(t *testing.T) { @@ -69,7 +70,7 @@ func TestInValidBackingPeriodBackMsg(t *testing.T) { msg := NewBackStoryMsg(validStoryID, validStake, validArgument, validCreator, invalidPeriod) err := msg.ValidateBasic() - assert.Equal(t, sdk.CodeType(901), err.Code(), err.Error()) + assert.Equal(t, CodeInvalidPeriod, err.Code(), err.Error()) } func TestInValidBackingPeriod2BackMsg(t *testing.T) { @@ -81,5 +82,5 @@ func TestInValidBackingPeriod2BackMsg(t *testing.T) { msg := NewBackStoryMsg(validStoryID, validStake, validArgument, validCreator, invalidPeriod) err := msg.ValidateBasic() - assert.Equal(t, sdk.CodeType(901), err.Code(), err.Error()) + assert.Equal(t, CodeInvalidPeriod, err.Code(), err.Error()) } diff --git a/x/vote/tally_test.go b/x/vote/tally_test.go index fd7e1c05..d57275ca 100644 --- a/x/vote/tally_test.go +++ b/x/vote/tally_test.go @@ -254,4 +254,8 @@ func Test_subtract(t *testing.T) { result.Amount = sdk.NewInt(-75) assert.Equal(t, subtract(coinB, coinA), result) + + // If different coin type return coinA + coinC, _ := sdk.ParseCoin("25anotherusecase") + assert.Equal(t, subtract(coinA, coinC), coinA) }