Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jhernandezb authored and shanev committed Feb 7, 2019
1 parent a9b6dd4 commit 72a8760
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
9 changes: 9 additions & 0 deletions x/backing/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
11 changes: 6 additions & 5 deletions x/backing/msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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())
}
4 changes: 4 additions & 0 deletions x/vote/tally_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 72a8760

Please sign in to comment.