Browse Source

MockClient for real abci app

pull/418/head
Ethan Frey 8 years ago
parent
commit
0905332f1d
2 changed files with 26 additions and 2 deletions
  1. +2
    -2
      Makefile
  2. +24
    -0
      rpc/client/mock/abci_test.go

+ 2
- 2
Makefile 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


+ 24
- 0
rpc/client/mock/abci_test.go 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)
}

Loading…
Cancel
Save