mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 12:11:58 +00:00
Fix up commits, debug cli tests
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package dummy
|
package dummy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/tendermint/abci/types"
|
"github.com/tendermint/abci/types"
|
||||||
@@ -33,6 +34,7 @@ func (app *DummyApplication) DeliverTx(tx []byte) types.Result {
|
|||||||
} else {
|
} else {
|
||||||
app.state.Set(tx, tx)
|
app.state.Set(tx, tx)
|
||||||
}
|
}
|
||||||
|
fmt.Println("set data")
|
||||||
return types.OK
|
return types.OK
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +43,20 @@ func (app *DummyApplication) CheckTx(tx []byte) types.Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (app *DummyApplication) Commit() 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, "")
|
return types.NewResultOK(hash, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -94,6 +94,7 @@ func (app *PersistentDummyApplication) Commit() types.Result {
|
|||||||
// Save a new version
|
// Save a new version
|
||||||
var appHash []byte
|
var appHash []byte
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if app.app.state.Size() > 0 {
|
if app.app.state.Size() > 0 {
|
||||||
appHash, err = app.app.state.SaveVersion(app.height)
|
appHash, err = app.app.state.SaveVersion(app.height)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -103,12 +104,7 @@ func (app *PersistentDummyApplication) Commit() types.Result {
|
|||||||
app.logger.Info("Saved state", "root", appHash)
|
app.logger.Info("Saved state", "root", appHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
lastBlock := LastBlockInfo{
|
app.logger.Info("Commit block", "height", app.height, "root", appHash)
|
||||||
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)
|
|
||||||
return types.NewResultOK(appHash, "")
|
return types.NewResultOK(appHash, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,21 +2,21 @@
|
|||||||
-> data: hello
|
-> data: hello
|
||||||
-> data.hex: 68656C6C6F
|
-> data.hex: 68656C6C6F
|
||||||
|
|
||||||
> info
|
> info
|
||||||
-> data: {"size":0}
|
-> data: {"size":0}
|
||||||
-> data.hex: 7B2273697A65223A307D
|
-> data.hex: 7B2273697A65223A307D
|
||||||
|
|
||||||
> commit
|
> commit
|
||||||
|
|
||||||
> deliver_tx "abc"
|
> deliver_tx "abc"
|
||||||
|
|
||||||
> info
|
> info
|
||||||
-> data: {"size":1}
|
-> data: {"size":1}
|
||||||
-> data.hex: 7B2273697A65223A317D
|
-> data.hex: 7B2273697A65223A317D
|
||||||
|
|
||||||
> commit
|
> commit
|
||||||
-> data: u<02>~<7E><><EFBFBD>X<EFBFBD>$<24>l<EFBFBD><6C>E<EFBFBD>
|
-> data: I<EFBFBD><EFBFBD>\ͬޮ<CDAC>(<28><01><><EFBFBD>h<EFBFBD><68><EFBFBD><EFBFBD>
|
||||||
-> data.hex: 750502FC7E84BBD788ED589624F06CFA871845D1
|
-> data.hex: 49DFD15CCDACDEAE9728CB01FBB5E8688CA58B91
|
||||||
|
|
||||||
> query "abc"
|
> query "abc"
|
||||||
-> log: exists
|
-> log: exists
|
||||||
@@ -26,9 +26,9 @@
|
|||||||
|
|
||||||
> deliver_tx "def=xyz"
|
> deliver_tx "def=xyz"
|
||||||
|
|
||||||
> commit
|
> commit
|
||||||
-> data: v9;<3B>.E<02><>iLb<4C><62>Q<EFBFBD><51><EFBFBD><EFBFBD>
|
-> data: p-<2D>"<22>7?<3F>?<3F><><EFBFBD>* <20>,<2C>+
|
||||||
-> data.hex: 76393B8A182E450286B0694C629ECB51B286EFD5
|
-> data.hex: 70102DB32280373FBF3F9F89DA2A20CE2CD62B0B
|
||||||
|
|
||||||
> query "def"
|
> query "def"
|
||||||
-> log: exists
|
-> log: exists
|
||||||
|
@@ -15,6 +15,7 @@ function testExample() {
|
|||||||
|
|
||||||
echo "Example $N"
|
echo "Example $N"
|
||||||
$APP &> /dev/null &
|
$APP &> /dev/null &
|
||||||
|
# $APP &> ./app.out &
|
||||||
sleep 2
|
sleep 2
|
||||||
abci-cli --verbose batch < "$INPUT" > "${INPUT}.out.new"
|
abci-cli --verbose batch < "$INPUT" > "${INPUT}.out.new"
|
||||||
killall "$APP"
|
killall "$APP"
|
||||||
|
Reference in New Issue
Block a user