Commit cc4abc3e authored by David Vorick's avatar David Vorick

add genesisTime field to CreateGenesisState

parent 3853c8fc
......@@ -380,37 +380,37 @@ func testRepeatBlock(t *testing.T, s *State) {
// TestBlockTimestamps creates a new state and uses it to call
// testBlockTimestamps.
func TestBlockTimestamps(t *testing.T) {
s := CreateGenesisState()
s := CreateGenesisState(Timestamp(time.Now().Unix()))
testBlockTimestamps(t, s)
}
// TestEmptyBlock creates a new state and uses it to call testEmptyBlock.
func TestEmptyBlock(t *testing.T) {
s := CreateGenesisState()
s := CreateGenesisState(Timestamp(time.Now().Unix()))
testEmptyBlock(t, s)
}
// TestLargeBlock creates a new state and uses it to call testLargeBlock.
func TestLargeBlock(t *testing.T) {
s := CreateGenesisState()
s := CreateGenesisState(Timestamp(time.Now().Unix()))
testLargeBlock(t, s)
}
// TestMinerPayouts creates a new state and uses it to call testMinerPayouts.
func TestMinerPayouts(t *testing.T) {
s := CreateGenesisState()
s := CreateGenesisState(Timestamp(time.Now().Unix()))
testMinerPayouts(t, s)
}
// TestMissedTarget creates a new state and uses it to call testMissedTarget.
func TestMissedTarget(t *testing.T) {
s := CreateGenesisState()
s := CreateGenesisState(Timestamp(time.Now().Unix()))
testMissedTarget(t, s)
}
// TestRepeatBlock creates a new state and uses it to call testRepeatBlock.
func TestRepeatBlock(t *testing.T) {
s := CreateGenesisState()
s := CreateGenesisState(Timestamp(time.Now().Unix()))
testRepeatBlock(t, s)
}
......
......@@ -86,8 +86,9 @@ func TestEverything(t *testing.T) {
// ahead of the other. We'll show all of the blocks to the other state,
// which will cause it to fork and rewind the entire diverse set of blocks
// and then apply an entirely different diverse set of blocks.
s0 := CreateGenesisState()
s1 := CreateGenesisState()
genesisTime := Timestamp(time.Now().Unix() - 1)
s0 := CreateGenesisState(genesisTime)
s1 := CreateGenesisState(genesisTime)
// Verify that the genesis state creation is consistent.
if s0.stateHash() != s1.stateHash() {
......
......@@ -42,8 +42,9 @@ type State struct {
}
// CreateGenesisState will create the state that contains the genesis block and
// nothing else.
func CreateGenesisState() (s *State) {
// nothing else. genesisTime is taken as an input instead of the constant being
// used directly because it makes certain parts of testing a lot easier.
func CreateGenesisState(genesisTime Timestamp) (s *State) {
// Create a new state and initialize the maps.
s = &State{
badBlocks: make(map[BlockID]struct{}),
......@@ -55,7 +56,7 @@ func CreateGenesisState() (s *State) {
// Create the genesis block and add it as the BlockRoot.
genesisBlock := Block{
Timestamp: GenesisTimestamp,
Timestamp: genesisTime,
}
s.blockRoot = &blockNode{
block: genesisBlock,
......
......@@ -53,7 +53,7 @@ type daemon struct {
func newDaemon(config DaemonConfig) (d *daemon, err error) {
d = new(daemon)
d.state = consensus.CreateGenesisState()
d.state = consensus.CreateGenesisState(consensus.GenesisTimestamp)
d.tpool, err = transactionpool.New(d.state)
if err != nil {
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment