mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 12:11:58 +00:00
move handshake to state, use Handshaker, more tests
This commit is contained in:
42
state/state_test.go
Normal file
42
state/state_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
dbm "github.com/tendermint/go-db"
|
||||
"github.com/tendermint/tendermint/config/tendermint_test"
|
||||
)
|
||||
|
||||
func TestStateCopyEquals(t *testing.T) {
|
||||
config := tendermint_test.ResetConfig("state_")
|
||||
// Get State db
|
||||
stateDB := dbm.NewDB("state", config.GetString("db_backend"), config.GetString("db_dir"))
|
||||
state := GetState(config, stateDB)
|
||||
|
||||
stateCopy := state.Copy()
|
||||
|
||||
if !state.Equals(stateCopy) {
|
||||
t.Fatal("expected state and its copy to be identical. got %v\n expected %v\n", stateCopy, state)
|
||||
}
|
||||
|
||||
stateCopy.LastBlockHeight += 1
|
||||
|
||||
if state.Equals(stateCopy) {
|
||||
t.Fatal("expected states to be different. got same %v", state)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStateSaveLoad(t *testing.T) {
|
||||
config := tendermint_test.ResetConfig("state_")
|
||||
// Get State db
|
||||
stateDB := dbm.NewDB("state", config.GetString("db_backend"), config.GetString("db_dir"))
|
||||
state := GetState(config, stateDB)
|
||||
|
||||
state.LastBlockHeight += 1
|
||||
state.Save()
|
||||
|
||||
loadedState := LoadState(stateDB)
|
||||
if !state.Equals(loadedState) {
|
||||
t.Fatal("expected state and its copy to be identical. got %v\n expected %v\n", loadedState, state)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user