Browse Source

Fix up commits, debug cli tests

pull/1780/head
Ethan Frey 7 years ago
parent
commit
bae4e4acce
4 changed files with 28 additions and 16 deletions
  1. +16
    -1
      example/dummy/dummy.go
  2. +2
    -6
      example/dummy/persistent_dummy.go
  3. +9
    -9
      tests/test_cli/ex1.abci.out
  4. +1
    -0
      tests/test_cli/test.sh

+ 16
- 1
example/dummy/dummy.go View File

@ -1,6 +1,7 @@
package dummy
import (
"fmt"
"strings"
"github.com/tendermint/abci/types"
@ -33,6 +34,7 @@ func (app *DummyApplication) DeliverTx(tx []byte) types.Result {
} else {
app.state.Set(tx, tx)
}
fmt.Println("set data")
return types.OK
}
@ -41,7 +43,20 @@ func (app *DummyApplication) CheckTx(tx []byte) types.Result {
}
func (app *DummyApplication) Commit() types.Result {
hash := app.state.Hash()
// Save a new version
var hash []byte
var err error
if app.state.Size() > 0 {
// just add one more to height (kind of arbitrarily stupid)
height := app.state.LatestVersion() + 1
hash, err = app.state.SaveVersion(height)
if err != nil {
// if this wasn't a dummy app, we'd do something smarter
panic(err)
}
}
return types.NewResultOK(hash, "")
}


+ 2
- 6
example/dummy/persistent_dummy.go View File

@ -94,6 +94,7 @@ func (app *PersistentDummyApplication) Commit() types.Result {
// Save a new version
var appHash []byte
var err error
if app.app.state.Size() > 0 {
appHash, err = app.app.state.SaveVersion(app.height)
if err != nil {
@ -103,12 +104,7 @@ func (app *PersistentDummyApplication) Commit() types.Result {
app.logger.Info("Saved state", "root", appHash)
}
lastBlock := LastBlockInfo{
Height: app.height,
AppHash: appHash, // this hash will be in the next block header
}
app.logger.Info("Saving block", "height", lastBlock.Height, "root", lastBlock.AppHash)
app.logger.Info("Commit block", "height", app.height, "root", appHash)
return types.NewResultOK(appHash, "")
}


+ 9
- 9
tests/test_cli/ex1.abci.out View File

@ -2,21 +2,21 @@
-> data: hello
-> data.hex: 68656C6C6F
> info
> info
-> data: {"size":0}
-> data.hex: 7B2273697A65223A307D
> commit
> commit
> deliver_tx "abc"
> info
> info
-> data: {"size":1}
-> data.hex: 7B2273697A65223A317D
> commit
-> data: uü~„»×ˆíX–$ðlú‡EÑ
-> data.hex: 750502FC7E84BBD788ED589624F06CFA871845D1
> commit
-> data: IßÑ\ͬޮ—(ËûµèhŒ¥‹‘
-> data.hex: 49DFD15CCDACDEAE9728CB01FBB5E8688CA58B91
> query "abc"
-> log: exists
@ -26,9 +26,9 @@
> deliver_tx "def=xyz"
> commit
-> data: v9;Š.E†°iLbžËQ²†ïÕ
-> data.hex: 76393B8A182E450286B0694C629ECB51B286EFD5
> commit
-> data: p-³"€7?¿?Ÿ‰Ú* Î,Ö+
-> data.hex: 70102DB32280373FBF3F9F89DA2A20CE2CD62B0B
> query "def"
-> log: exists


+ 1
- 0
tests/test_cli/test.sh View File

@ -15,6 +15,7 @@ function testExample() {
echo "Example $N"
$APP &> /dev/null &
# $APP &> ./app.out &
sleep 2
abci-cli --verbose batch < "$INPUT" > "${INPUT}.out.new"
killall "$APP"


Loading…
Cancel
Save