mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-28 12:11:44 +00:00
test: app persistence
This commit is contained in:
@ -1251,7 +1251,8 @@ func (cs *ConsensusState) finalizeCommit(height int) {
|
|||||||
PanicConsensus(Fmt("+2/3 committed an invalid block: %v", err))
|
PanicConsensus(Fmt("+2/3 committed an invalid block: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Notice(Fmt("Finalizing commit of block with %d txs", block.NumTxs), "height", block.Height, "hash", block.Hash())
|
log.Notice(Fmt("Finalizing commit of block with %d txs", block.NumTxs),
|
||||||
|
"height", block.Height, "hash", block.Hash(), "root", block.AppHash)
|
||||||
log.Info(Fmt("%v", block))
|
log.Info(Fmt("%v", block))
|
||||||
|
|
||||||
// Fire off event for new block.
|
// Fire off event for new block.
|
||||||
|
@ -246,6 +246,7 @@ func (s *State) ReplayBlocks(header *types.Header, partsHeader types.PartSetHead
|
|||||||
// TODO: put validators in iavl tree so we can set the state with an older validator set
|
// TODO: put validators in iavl tree so we can set the state with an older validator set
|
||||||
lastVals, nextVals := stateCopy.GetValidators()
|
lastVals, nextVals := stateCopy.GetValidators()
|
||||||
stateCopy.SetBlockAndValidators(header, partsHeader, lastVals, nextVals)
|
stateCopy.SetBlockAndValidators(header, partsHeader, lastVals, nextVals)
|
||||||
|
stateCopy.AppHash = header.AppHash
|
||||||
}
|
}
|
||||||
|
|
||||||
// run the transactions
|
// run the transactions
|
||||||
|
68
test/persist/test.sh
Normal file
68
test/persist/test.sh
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
export TMROOT=$HOME/.tendermint_persist
|
||||||
|
|
||||||
|
rm -rf $TMROOT
|
||||||
|
tendermint init
|
||||||
|
|
||||||
|
function start_procs(){
|
||||||
|
name=$1
|
||||||
|
echo "Starting persistent dummy and tendermint"
|
||||||
|
dummy --persist $TMROOT/dummy &> "dummy_${name}.log" &
|
||||||
|
PID_DUMMY=$!
|
||||||
|
tendermint node &> tendermint_${name}.log &
|
||||||
|
PID_TENDERMINT=$!
|
||||||
|
sleep 5
|
||||||
|
}
|
||||||
|
|
||||||
|
function kill_procs(){
|
||||||
|
kill -9 $PID_DUMMY $PID_TENDERMINT
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function send_txs(){
|
||||||
|
# send a bunch of txs over a few blocks
|
||||||
|
echo "Sending txs"
|
||||||
|
# for i in `seq 1 5`; do
|
||||||
|
# for j in `seq 1 100`; do
|
||||||
|
tx=`head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"'`
|
||||||
|
curl -s 127.0.0.1:46657/broadcast_tx_async?tx=\"$tx\" &> /dev/null
|
||||||
|
# done
|
||||||
|
sleep 1
|
||||||
|
# done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
start_procs 1
|
||||||
|
send_txs
|
||||||
|
kill_procs
|
||||||
|
start_procs 2
|
||||||
|
|
||||||
|
# wait for node to handshake and make a new block
|
||||||
|
addr="localhost:46657"
|
||||||
|
curl -s $addr/status > /dev/null
|
||||||
|
ERR=$?
|
||||||
|
i=0
|
||||||
|
while [ "$ERR" != 0 ]; do
|
||||||
|
sleep 1
|
||||||
|
curl -s $addr/status > /dev/null
|
||||||
|
ERR=$?
|
||||||
|
i=$(($i + 1))
|
||||||
|
if [[ $i == 10 ]]; then
|
||||||
|
echo "Timed out waiting for tendermint to start"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# wait for a new block
|
||||||
|
h1=`curl -s $addr/status | jq .result[1].latest_block_height`
|
||||||
|
h2=$h1
|
||||||
|
while [ "$h2" == "$h1" ]; do
|
||||||
|
sleep 1
|
||||||
|
h2=`curl -s $addr/status | jq .result[1].latest_block_height`
|
||||||
|
done
|
||||||
|
|
||||||
|
kill_procs
|
||||||
|
|
||||||
|
echo "Passed Test: Persistence"
|
@ -11,6 +11,9 @@ bash test/test_cover.sh
|
|||||||
# run the app tests
|
# run the app tests
|
||||||
bash test/app/test.sh
|
bash test/app/test.sh
|
||||||
|
|
||||||
|
# run the persistence test
|
||||||
|
bash test/persist.test.sh
|
||||||
|
|
||||||
if [[ "$BRANCH" == "master" || $(echo "$BRANCH" | grep "release-") != "" ]]; then
|
if [[ "$BRANCH" == "master" || $(echo "$BRANCH" | grep "release-") != "" ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "* branch $BRANCH; testing libs"
|
echo "* branch $BRANCH; testing libs"
|
||||||
|
@ -130,7 +130,9 @@ func NewEventCache(evsw EventSwitch) EventCache {
|
|||||||
|
|
||||||
// All events should be based on this FireEvent to ensure they are TMEventData
|
// All events should be based on this FireEvent to ensure they are TMEventData
|
||||||
func fireEvent(fireable events.Fireable, event string, data TMEventData) {
|
func fireEvent(fireable events.Fireable, event string, data TMEventData) {
|
||||||
|
if fireable != nil {
|
||||||
fireable.FireEvent(event, data)
|
fireable.FireEvent(event, data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData)) {
|
func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData)) {
|
||||||
|
Reference in New Issue
Block a user