mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-15 06:11:20 +00:00
time in nanoseconds
This commit is contained in:
@ -8,10 +8,10 @@ import (
|
|||||||
// Time
|
// Time
|
||||||
|
|
||||||
func WriteTime(w io.Writer, t time.Time, n *int64, err *error) {
|
func WriteTime(w io.Writer, t time.Time, n *int64, err *error) {
|
||||||
WriteInt64(w, t.Unix(), n, err)
|
WriteInt64(w, t.UnixNano(), n, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadTime(r io.Reader, n *int64, err *error) time.Time {
|
func ReadTime(r io.Reader, n *int64, err *error) time.Time {
|
||||||
t := ReadInt64(r, n, err)
|
t := ReadInt64(r, n, err)
|
||||||
return time.Unix(t, 0)
|
return time.Unix(0, t)
|
||||||
}
|
}
|
||||||
|
@ -63,20 +63,27 @@ func TestGenesisSaveLoad(t *testing.T) {
|
|||||||
t.Error("Error appending initial block:", err)
|
t.Error("Error appending initial block:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save s0, load s1.
|
// Save s0
|
||||||
commitTime := time.Now()
|
commitTime := time.Now()
|
||||||
s0.Save(commitTime)
|
s0.Save(commitTime)
|
||||||
//s0.DB.(*MemDB).Print()
|
|
||||||
s1 := LoadState(s0.DB)
|
|
||||||
|
|
||||||
// Compare CommitTime
|
// Sanity check s0
|
||||||
if commitTime.Unix() != s1.CommitTime.Unix() {
|
//s0.DB.(*MemDB).Print()
|
||||||
t.Error("CommitTime was not the same")
|
if s0.Validators.TotalVotingPower() == 0 {
|
||||||
|
t.Error("s0 Validators TotalVotingPower should not be 0")
|
||||||
}
|
}
|
||||||
// Compare height & blockHash
|
|
||||||
if s0.Height != 1 {
|
if s0.Height != 1 {
|
||||||
t.Error("s0 Height should be 1, got", s0.Height)
|
t.Error("s0 Height should be 1, got", s0.Height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load s1
|
||||||
|
s1 := LoadState(s0.DB)
|
||||||
|
|
||||||
|
// Compare CommitTime
|
||||||
|
if !s0.CommitTime.Equal(s1.CommitTime) {
|
||||||
|
t.Error("CommitTime was not the same", s0.CommitTime, s1.CommitTime)
|
||||||
|
}
|
||||||
|
// Compare height & blockHash
|
||||||
if s0.Height != s1.Height {
|
if s0.Height != s1.Height {
|
||||||
t.Error("Height mismatch")
|
t.Error("Height mismatch")
|
||||||
}
|
}
|
||||||
@ -85,14 +92,12 @@ func TestGenesisSaveLoad(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// Compare Validators
|
// Compare Validators
|
||||||
if s0.Validators.Size() != s1.Validators.Size() {
|
if s0.Validators.Size() != s1.Validators.Size() {
|
||||||
t.Error("Validators Size changed")
|
t.Error("Validators Size mismatch")
|
||||||
}
|
|
||||||
if s0.Validators.TotalVotingPower() == 0 {
|
|
||||||
t.Error("s0 Validators TotalVotingPower should not be 0")
|
|
||||||
}
|
}
|
||||||
if s0.Validators.TotalVotingPower() != s1.Validators.TotalVotingPower() {
|
if s0.Validators.TotalVotingPower() != s1.Validators.TotalVotingPower() {
|
||||||
t.Error("Validators TotalVotingPower changed")
|
t.Error("Validators TotalVotingPower mismatch")
|
||||||
|
}
|
||||||
|
if !bytes.Equal(s0.AccountBalances.Tree.Hash(), s1.AccountBalances.Tree.Hash()) {
|
||||||
|
t.Error("AccountBalance mismatch")
|
||||||
}
|
}
|
||||||
// TODO Compare accountBalances, height, blockHash
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user