diff --git a/example/dummy/dummy.go b/example/dummy/dummy.go index 82927ca6..89f997a4 100644 --- a/example/dummy/dummy.go +++ b/example/dummy/dummy.go @@ -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, "") } diff --git a/example/dummy/persistent_dummy.go b/example/dummy/persistent_dummy.go index 89bc6e72..cc2d2d40 100644 --- a/example/dummy/persistent_dummy.go +++ b/example/dummy/persistent_dummy.go @@ -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, "") } diff --git a/tests/test_cli/ex1.abci.out b/tests/test_cli/ex1.abci.out index e434944a..c3a62d55 100644 --- a/tests/test_cli/ex1.abci.out +++ b/tests/test_cli/ex1.abci.out @@ -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 diff --git a/tests/test_cli/test.sh b/tests/test_cli/test.sh index 4266dd16..8ea8d545 100644 --- a/tests/test_cli/test.sh +++ b/tests/test_cli/test.sh @@ -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"