x/bank: boost test coverage

This commit is contained in:
Zach Ramsay 2018-02-20 23:57:24 +00:00
parent 2b25f5948d
commit b9780ff9ae

View File

@ -1,6 +1,7 @@
package bank
import (
//"fmt"
"testing"
"github.com/stretchr/testify/assert"
@ -10,6 +11,27 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
func TestSendMsgType(t *testing.T) {
// Construct a SendMsg
var msg = SendMsg{
Inputs: []Input{
{
Address: crypto.Address([]byte("input")),
Coins: sdk.Coins{{"atom", 10}},
Sequence: 1,
},
},
Outputs: []Output{
{
Address: crypto.Address([]byte("output")),
Coins: sdk.Coins{{"atom", 10}},
},
},
}
assert.Equal(t, msg.Type(), "bank")
}
func TestInputValidation(t *testing.T) {
addr1 := crypto.Address([]byte{1, 2})
addr2 := crypto.Address([]byte{7, 8})
@ -165,6 +187,60 @@ func TestSendMsgValidation(t *testing.T) {
}
}
func TestSendMsgString(t *testing.T) {
// Construct a SendMsg
var msg = SendMsg{
Inputs: []Input{
{
Address: crypto.Address([]byte("input")),
Coins: sdk.Coins{{"atom", 10}},
Sequence: 1,
},
},
Outputs: []Output{
{
Address: crypto.Address([]byte("output")),
Coins: sdk.Coins{{"atom", 10}},
},
},
}
res := msg.String()
assert.Equal(t, res, "SendMsg{[Input{696E707574,10atom}]->[Output{364637353734373037353734,10atom}]}")
}
// ----------------------------------------
// IssueMsg Tests
func TestIssueMsgString(t *testing.T) {
// Construct a IssueMsg
var msg = IssueMsg{
Banker: crypto.Address([]byte("input")),
Outputs: []Output{
{
Address: crypto.Address([]byte("loan-from-bank")),
Coins: sdk.Coins{{"atom", 10}},
},
},
}
res := msg.String()
assert.Equal(t, res, "IssueMsg{696E707574#[Output{36433646363136453244363637323646364432443632363136453642,10atom}]}")
}
func TestIssueMsgType(t *testing.T) {
// Construct an IssueMsg
var msg = IssueMsg{
Banker: crypto.Address([]byte("input")),
Outputs: []Output{
{
Address: crypto.Address([]byte("loan-from-bank")),
Coins: sdk.Coins{{"atom", 10}},
},
},
}
assert.Equal(t, msg.Type(), "bank")
}
/*
// TODO where does this test belong ?
func TestSendMsgSigners(t *testing.T) {