MockClient for real abci app

This commit is contained in:
Ethan Frey 2017-02-22 16:49:45 +01:00
parent df172fa840
commit 0905332f1d
2 changed files with 27 additions and 3 deletions

View File

@ -22,11 +22,11 @@ dist:
test:
@echo "--> Running go test"
@go test $(PACKAGES)
@go test -p 1 $(PACKAGES)
test_race:
@echo "--> Running go test --race"
@go test -v -race $(PACKAGES)
@go test -p 1 -v -race $(PACKAGES)
test_integrations:
@bash ./test/test.sh

View File

@ -2,10 +2,12 @@ package mock_test
import (
"errors"
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/abci/example/dummy"
abci "github.com/tendermint/abci/types"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types"
@ -138,5 +140,27 @@ func TestABCIRecorder(t *testing.T) {
assert.Nil(ba.Response)
require.NotNil(ba.Error)
assert.EqualValues(ba.Args, txs[2])
}
func TestABCIApp(t *testing.T) {
assert, require := assert.New(t), require.New(t)
app := dummy.NewDummyApplication()
m := mock.ABCIApp{app}
// get some info
info, err := m.ABCIInfo()
require.Nil(err)
assert.Equal(`{"size":0}`, info.Response.GetData())
// add a key
key, value := "foo", "bar"
tx := fmt.Sprintf("%s=%s", key, value)
res, err := m.BroadcastTxSync(types.Tx(tx))
require.Nil(err)
assert.True(res.Code.IsOK())
// check the key
qres, err := m.ABCIQuery("/key", []byte(key), false)
require.Nil(err)
assert.EqualValues(value, qres.Response.Value)
}