Merge pull request #488 from cosmos/moar-tests
REVIEW: baseapp: start TestInfo
This commit is contained in:
commit
a91bcaf4f2
5
Makefile
5
Makefile
|
@ -60,6 +60,11 @@ godocs:
|
|||
|
||||
test: test_unit # test_cli
|
||||
|
||||
# Must be run in each package seperately for the visualization
|
||||
# Added here for easy reference
|
||||
# coverage:
|
||||
# go test -coverprofile=c.out && go tool cover -html=c.out
|
||||
|
||||
test_unit:
|
||||
@rm -rf examples/basecoin/vendor/
|
||||
@go test $(PACKAGES)
|
||||
|
|
|
@ -49,21 +49,36 @@ func TestMountStores(t *testing.T) {
|
|||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestLoadVersion(t *testing.T) {
|
||||
// TODO
|
||||
// Test that we can make commits and then reload old versions.
|
||||
// Test that LoadLatestVersion actually does.
|
||||
func TestLoadVersion(t *testing.T) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
func TestTxDecoder(t *testing.T) {
|
||||
// TODO
|
||||
// Test that txs can be unmarshalled and read and that
|
||||
// correct error codes are returned when not
|
||||
func TestTxDecoder(t *testing.T) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
func TestInfo(t *testing.T) {
|
||||
// TODO
|
||||
// Test that Info returns the latest committed state.
|
||||
func TestInfo(t *testing.T) {
|
||||
|
||||
app := newBaseApp(t.Name())
|
||||
|
||||
// ----- test an empty response -------
|
||||
reqInfo := abci.RequestInfo{}
|
||||
res := app.Info(reqInfo)
|
||||
|
||||
// should be empty
|
||||
assert.Equal(t, "", res.Version)
|
||||
assert.Equal(t, t.Name(), res.GetData())
|
||||
assert.Equal(t, int64(0), res.LastBlockHeight)
|
||||
assert.Equal(t, []uint8(nil), res.LastBlockAppHash)
|
||||
|
||||
// ----- test a proper response -------
|
||||
// TODO
|
||||
|
||||
}
|
||||
|
||||
func TestInitChainer(t *testing.T) {
|
||||
|
@ -101,14 +116,14 @@ func TestInitChainer(t *testing.T) {
|
|||
assert.Equal(t, value, res.Value)
|
||||
}
|
||||
|
||||
// Test that successive CheckTx can see eachothers effects
|
||||
// Test that successive CheckTx can see each others' effects
|
||||
// on the store within a block, and that the CheckTx state
|
||||
// gets reset to the latest Committed state during Commit
|
||||
func TestCheckTx(t *testing.T) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Test that successive DeliverTx can see eachothers effects
|
||||
// Test that successive DeliverTx can see each others' effects
|
||||
// on the store, both within and across blocks.
|
||||
func TestDeliverTx(t *testing.T) {
|
||||
app := newBaseApp(t.Name())
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
hash: 74ba16fcb7dac2ceca406dcc6c6ed00ab1cd09af4ca6f3f1d35452254e149fb4
|
||||
updated: 2018-02-20T22:02:29.601415268Z
|
||||
imports:
|
||||
- name: github.com/btcsuite/btcd
|
||||
version: 50de9da05b50eb15658bb350f6ea24368a111ab7
|
||||
subpackages:
|
||||
- btcec
|
||||
- name: github.com/cosmos/cosmos-sdk
|
||||
version: 6197eb831e7ffb2f603d59f4602663bb9b9a642e
|
||||
subpackages:
|
||||
- baseapp
|
||||
- store
|
||||
- types
|
||||
- x/auth
|
||||
- x/bank
|
||||
- name: github.com/davecgh/go-spew
|
||||
version: 346938d642f2ec3594ed81d874461961cd0faa76
|
||||
subpackages:
|
||||
- spew
|
||||
- name: github.com/go-kit/kit
|
||||
version: 4dc7be5d2d12881735283bcab7352178e190fc71
|
||||
subpackages:
|
||||
- log
|
||||
- log/level
|
||||
- log/term
|
||||
- name: github.com/go-logfmt/logfmt
|
||||
version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5
|
||||
- name: github.com/go-stack/stack
|
||||
version: 259ab82a6cad3992b4e21ff5cac294ccb06474bc
|
||||
- name: github.com/gogo/protobuf
|
||||
version: 1adfc126b41513cc696b209667c8656ea7aac67c
|
||||
subpackages:
|
||||
- gogoproto
|
||||
- jsonpb
|
||||
- proto
|
||||
- protoc-gen-gogo/descriptor
|
||||
- sortkeys
|
||||
- types
|
||||
- name: github.com/golang/protobuf
|
||||
version: 925541529c1fa6821df4e44ce2723319eb2be768
|
||||
subpackages:
|
||||
- proto
|
||||
- ptypes
|
||||
- ptypes/any
|
||||
- ptypes/duration
|
||||
- ptypes/timestamp
|
||||
- name: github.com/golang/snappy
|
||||
version: 553a641470496b2327abcac10b36396bd98e45c9
|
||||
- name: github.com/jmhodges/levigo
|
||||
version: c42d9e0ca023e2198120196f842701bb4c55d7b9
|
||||
- name: github.com/kr/logfmt
|
||||
version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0
|
||||
- name: github.com/pkg/errors
|
||||
version: 645ef00459ed84a119197bfb8d8205042c6df63d
|
||||
- name: github.com/syndtr/goleveldb
|
||||
version: 34011bf325bce385408353a30b101fe5e923eb6e
|
||||
subpackages:
|
||||
- leveldb
|
||||
- leveldb/cache
|
||||
- leveldb/comparer
|
||||
- leveldb/errors
|
||||
- leveldb/filter
|
||||
- leveldb/iterator
|
||||
- leveldb/journal
|
||||
- leveldb/memdb
|
||||
- leveldb/opt
|
||||
- leveldb/storage
|
||||
- leveldb/table
|
||||
- leveldb/util
|
||||
- name: github.com/tendermint/abci
|
||||
version: fe7e26eecffd1dfbed3644893ff5177ad729fe94
|
||||
subpackages:
|
||||
- server
|
||||
- types
|
||||
- name: github.com/tendermint/ed25519
|
||||
version: d8387025d2b9d158cf4efb07e7ebf814bcce2057
|
||||
subpackages:
|
||||
- edwards25519
|
||||
- extra25519
|
||||
- name: github.com/tendermint/go-crypto
|
||||
version: 4fc3055dbd17aa1203d0abc64b9293f378da22ec
|
||||
- name: github.com/tendermint/go-wire
|
||||
version: dec83f641903b22f039da3974607859715d0377e
|
||||
- name: github.com/tendermint/iavl
|
||||
version: 1a59ec0c82dc940c25339dd7c834df5cb76a95cb
|
||||
- name: github.com/tendermint/tmlibs
|
||||
version: c858b3ba78316fdd9096a11409a7e7a493e7d974
|
||||
subpackages:
|
||||
- common
|
||||
- db
|
||||
- log
|
||||
- merkle
|
||||
- name: golang.org/x/crypto
|
||||
version: 1875d0a70c90e57f11972aefd42276df65e895b9
|
||||
subpackages:
|
||||
- nacl/secretbox
|
||||
- openpgp/armor
|
||||
- openpgp/errors
|
||||
- poly1305
|
||||
- ripemd160
|
||||
- salsa20/salsa
|
||||
- name: golang.org/x/net
|
||||
version: 2fb46b16b8dda405028c50f7c7f0f9dd1fa6bfb1
|
||||
subpackages:
|
||||
- context
|
||||
- http2
|
||||
- http2/hpack
|
||||
- idna
|
||||
- internal/timeseries
|
||||
- lex/httplex
|
||||
- trace
|
||||
- name: golang.org/x/text
|
||||
version: e19ae1496984b1c655b8044a65c0300a3c878dd3
|
||||
subpackages:
|
||||
- secure/bidirule
|
||||
- transform
|
||||
- unicode/bidi
|
||||
- unicode/norm
|
||||
- name: google.golang.org/genproto
|
||||
version: 4eb30f4778eed4c258ba66527a0d4f9ec8a36c45
|
||||
subpackages:
|
||||
- googleapis/rpc/status
|
||||
- name: google.golang.org/grpc
|
||||
version: 401e0e00e4bb830a10496d64cd95e068c5bf50de
|
||||
subpackages:
|
||||
- balancer
|
||||
- codes
|
||||
- connectivity
|
||||
- credentials
|
||||
- grpclb/grpc_lb_v1/messages
|
||||
- grpclog
|
||||
- internal
|
||||
- keepalive
|
||||
- metadata
|
||||
- naming
|
||||
- peer
|
||||
- resolver
|
||||
- stats
|
||||
- status
|
||||
- tap
|
||||
- transport
|
||||
testImports:
|
||||
- name: github.com/pmezard/go-difflib
|
||||
version: 792786c7400a136282c1664665ae0a8db921c6c2
|
||||
subpackages:
|
||||
- difflib
|
||||
- name: github.com/stretchr/testify
|
||||
version: 12b6f73e6084dad08a7c6e575284b177ecafbc71
|
||||
subpackages:
|
||||
- assert
|
||||
- require
|
|
@ -1,6 +1,7 @@
|
|||
package bank
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -10,6 +11,30 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
func TestNewSendMsg(t *testing.T) {}
|
||||
|
||||
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}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// TODO some failures for bad result
|
||||
assert.Equal(t, msg.Type(), "bank")
|
||||
}
|
||||
|
||||
func TestInputValidation(t *testing.T) {
|
||||
addr1 := crypto.Address([]byte{1, 2})
|
||||
addr2 := crypto.Address([]byte{7, 8})
|
||||
|
@ -97,7 +122,6 @@ func TestOutputValidation(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSendMsgValidation(t *testing.T) {
|
||||
|
||||
addr1 := crypto.Address([]byte{1, 2})
|
||||
addr2 := crypto.Address([]byte{7, 8})
|
||||
atom123 := sdk.Coins{{"atom", 123}}
|
||||
|
@ -165,8 +189,89 @@ 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()
|
||||
// TODO some failures for bad results
|
||||
assert.Equal(t, res, "SendMsg{[Input{696E707574,10atom}]->[Output{364637353734373037353734,10atom}]}")
|
||||
}
|
||||
|
||||
func TestSendMsgGet(t *testing.T) {
|
||||
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.Get(nil)
|
||||
assert.Nil(t, res)
|
||||
}
|
||||
|
||||
func TestSendMsgGetSignBytes(t *testing.T) {
|
||||
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.GetSignBytes()
|
||||
// TODO bad results
|
||||
assert.Equal(t, string(res), `{"inputs":[{"address":"696E707574","coins":[{"denom":"atom","amount":10}],"sequence":1}],"outputs":[{"address":"6F7574707574","coins":[{"denom":"atom","amount":10}]}]}`)
|
||||
}
|
||||
|
||||
func TestSendMsgGetSigners(t *testing.T) {
|
||||
var msg = SendMsg{
|
||||
Inputs: []Input{
|
||||
{
|
||||
Address: crypto.Address([]byte("input1")),
|
||||
},
|
||||
{
|
||||
Address: crypto.Address([]byte("input2")),
|
||||
},
|
||||
{
|
||||
Address: crypto.Address([]byte("input3")),
|
||||
},
|
||||
},
|
||||
}
|
||||
res := msg.GetSigners()
|
||||
assert.Equal(t, fmt.Sprintf("%v", res), "[696E70757431 696E70757432 696E70757433]")
|
||||
}
|
||||
|
||||
/*
|
||||
// TODO where does this test belong ?
|
||||
// what to do w/ this test?
|
||||
func TestSendMsgSigners(t *testing.T) {
|
||||
signers := []crypto.Address{
|
||||
{1, 2, 3},
|
||||
|
@ -184,3 +289,82 @@ func TestSendMsgSigners(t *testing.T) {
|
|||
assert.Equal(t, signers, tx.Signers())
|
||||
}
|
||||
*/
|
||||
|
||||
// ----------------------------------------
|
||||
// IssueMsg Tests
|
||||
|
||||
func TestNewIssueMsg(t *testing.T) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
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}},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// TODO some failures for bad result
|
||||
assert.Equal(t, msg.Type(), "bank")
|
||||
}
|
||||
|
||||
func TestIssueMsgValidation(t *testing.T) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
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 TestIssueMsgGet(t *testing.T) {
|
||||
var msg = IssueMsg{
|
||||
Banker: crypto.Address([]byte("input")),
|
||||
Outputs: []Output{
|
||||
{
|
||||
Address: crypto.Address([]byte("loan-from-bank")),
|
||||
Coins: sdk.Coins{{"atom", 10}},
|
||||
},
|
||||
},
|
||||
}
|
||||
res := msg.Get(nil)
|
||||
assert.Nil(t, res)
|
||||
}
|
||||
|
||||
func TestIssueMsgGetSignBytes(t *testing.T) {
|
||||
var msg = IssueMsg{
|
||||
Banker: crypto.Address([]byte("input")),
|
||||
Outputs: []Output{
|
||||
{
|
||||
Address: crypto.Address([]byte("loan-from-bank")),
|
||||
Coins: sdk.Coins{{"atom", 10}},
|
||||
},
|
||||
},
|
||||
}
|
||||
res := msg.GetSignBytes()
|
||||
// TODO bad results
|
||||
assert.Equal(t, string(res), `{"banker":"696E707574","outputs":[{"address":"6C6F616E2D66726F6D2D62616E6B","coins":[{"denom":"atom","amount":10}]}]}`)
|
||||
}
|
||||
|
||||
func TestIssueMsgGetSigners(t *testing.T) {
|
||||
var msg = IssueMsg{
|
||||
Banker: crypto.Address([]byte("onlyone")),
|
||||
}
|
||||
res := msg.GetSigners()
|
||||
assert.Equal(t, fmt.Sprintf("%v", res), "[6F6E6C796F6E65]")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue