TMSP -> ABCI

This commit is contained in:
Ethan Buchman
2017-01-12 16:04:32 -05:00
parent 80f377135b
commit 5189a2248d
52 changed files with 221 additions and 219 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ import (
//"encoding/hex"
. "github.com/tendermint/go-common"
"github.com/tendermint/tmsp/types"
"github.com/tendermint/abci/types"
)
func main() {
+1 -1
View File
@@ -9,7 +9,7 @@ import (
//"encoding/hex"
. "github.com/tendermint/go-common"
"github.com/tendermint/tmsp/types"
"github.com/tendermint/abci/types"
)
func main() {
+13 -13
View File
@@ -7,24 +7,24 @@ import (
. "github.com/tendermint/go-common"
"github.com/tendermint/go-process"
"github.com/tendermint/tmsp/client"
"github.com/tendermint/tmsp/types"
"github.com/tendermint/abci/client"
"github.com/tendermint/abci/types"
)
//----------------------------------------
func StartApp(tmspApp string) *process.Process {
func StartApp(abciApp string) *process.Process {
// Start the app
//outBuf := NewBufferCloser(nil)
proc, err := process.StartProcess("tmsp_app",
proc, err := process.StartProcess("abci_app",
"",
"bash",
[]string{"-c", tmspApp},
[]string{"-c", abciApp},
nil,
os.Stdout,
)
if err != nil {
panic("running tmsp_app: " + err.Error())
panic("running abci_app: " + err.Error())
}
// TODO a better way to handle this?
@@ -33,16 +33,16 @@ func StartApp(tmspApp string) *process.Process {
return proc
}
func StartClient(tmspType string) tmspcli.Client {
func StartClient(abciType string) abcicli.Client {
// Start client
client, err := tmspcli.NewClient("tcp://127.0.0.1:46658", tmspType, true)
client, err := abcicli.NewClient("tcp://127.0.0.1:46658", abciType, true)
if err != nil {
panic("connecting to tmsp_app: " + err.Error())
panic("connecting to abci_app: " + err.Error())
}
return client
}
func SetOption(client tmspcli.Client, key, value string) {
func SetOption(client abcicli.Client, key, value string) {
res := client.SetOptionSync(key, value)
_, _, log := res.Code, res.Data, res.Log
if res.IsErr() {
@@ -50,7 +50,7 @@ func SetOption(client tmspcli.Client, key, value string) {
}
}
func Commit(client tmspcli.Client, hashExp []byte) {
func Commit(client abcicli.Client, hashExp []byte) {
res := client.CommitSync()
_, data, log := res.Code, res.Data, res.Log
if res.IsErr() {
@@ -62,7 +62,7 @@ func Commit(client tmspcli.Client, hashExp []byte) {
}
}
func DeliverTx(client tmspcli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) {
func DeliverTx(client abcicli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) {
res := client.DeliverTxSync(txBytes)
code, data, log := res.Code, res.Data, res.Log
if code != codeExp {
@@ -75,7 +75,7 @@ func DeliverTx(client tmspcli.Client, txBytes []byte, codeExp types.CodeType, da
}
}
func CheckTx(client tmspcli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) {
func CheckTx(client abcicli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) {
res := client.CheckTxSync(txBytes)
code, data, log := res.Code, res.Data, res.Log
if res.IsErr() {
+11 -11
View File
@@ -4,15 +4,15 @@ import (
"fmt"
"os"
"github.com/tendermint/tmsp/types"
"github.com/tendermint/abci/types"
)
var tmspType string
var abciType string
func init() {
tmspType = os.Getenv("TMSP")
if tmspType == "" {
tmspType = "socket"
abciType = os.Getenv("ABCI")
if abciType == "" {
abciType = "socket"
}
}
@@ -21,15 +21,15 @@ func main() {
}
func testCounter() {
tmspApp := os.Getenv("TMSP_APP")
if tmspApp == "" {
panic("No TMSP_APP specified")
abciApp := os.Getenv("ABCI_APP")
if abciApp == "" {
panic("No ABCI_APP specified")
}
fmt.Printf("Running %s test with tmsp=%s\n", tmspApp, tmspType)
appProc := StartApp(tmspApp)
fmt.Printf("Running %s test with abci=%s\n", abciApp, abciType)
appProc := StartApp(abciApp)
defer appProc.StopProcess(true)
client := StartClient(tmspType)
client := StartClient(abciType)
defer client.Stop()
SetOption(client, "serial", "on")
+5 -5
View File
@@ -1,17 +1,17 @@
#! /bin/bash
set -e
# These tests spawn the counter app and server by execing the TMSP_APP command and run some simple client tests against it
# These tests spawn the counter app and server by execing the ABCI_APP command and run some simple client tests against it
ROOT=$GOPATH/src/github.com/tendermint/tmsp/tests/test_app
ROOT=$GOPATH/src/github.com/tendermint/abci/tests/test_app
cd $ROOT
# test golang counter
TMSP_APP="counter" go run *.go
ABCI_APP="counter" go run *.go
# test golang counter via grpc
TMSP_APP="counter -tmsp=grpc" TMSP="grpc" go run *.go
ABCI_APP="counter -abci=grpc" ABCI="grpc" go run *.go
# test nodejs counter
# TODO: fix node app
#TMSP_APP="node $GOPATH/src/github.com/tendermint/js-tmsp/example/app.js" go test -test.run TestCounter
#ABCI_APP="node $GOPATH/src/github.com/tendermint/js-abci/example/app.js" go test -test.run TestCounter
+5 -3
View File
@@ -1,5 +1,7 @@
#! /bin/bash
cd $GOPATH/src/github.com/tendermint/abci
function testExample() {
N=$1
INPUT=$2
@@ -8,7 +10,7 @@ function testExample() {
echo "Example $N"
$APP &> /dev/null &
sleep 2
tmsp-cli --verbose batch < $INPUT > "${INPUT}.out.new"
abci-cli --verbose batch < $INPUT > "${INPUT}.out.new"
killall "$APP"
pre=`shasum < "${INPUT}.out"`
@@ -26,8 +28,8 @@ function testExample() {
rm "${INPUT}".out.new
}
testExample 1 tests/test_cli/ex1.tmsp dummy
testExample 2 tests/test_cli/ex2.tmsp counter
testExample 1 tests/test_cli/ex1.abci dummy
testExample 2 tests/test_cli/ex2.abci counter
echo ""
echo "PASS"