mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 06:31:57 +00:00
factory: simplify validator and genesis factory functions
This commit is contained in:
@@ -3,6 +3,7 @@ package state_test
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
@@ -244,7 +245,7 @@ func makeRandomStateFromValidatorSet(
|
||||
|
||||
func makeRandomStateFromConsensusParams(consensusParams *types.ConsensusParams,
|
||||
height, lastHeightConsensusParamsChanged int64) sm.State {
|
||||
val, _ := factory.RandValidator(true, 10)
|
||||
val, _ := factory.Validator(10 + int64(rand.Uint32()))
|
||||
valSet := types.NewValidatorSet([]*types.Validator{val})
|
||||
return sm.State{
|
||||
LastBlockHeight: height - 1,
|
||||
|
||||
+7
-6
@@ -2,6 +2,7 @@ package state_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -29,9 +30,9 @@ const (
|
||||
func TestStoreBootstrap(t *testing.T) {
|
||||
stateDB := dbm.NewMemDB()
|
||||
stateStore := sm.NewStore(stateDB)
|
||||
val, _ := factory.RandValidator(true, 10)
|
||||
val2, _ := factory.RandValidator(true, 10)
|
||||
val3, _ := factory.RandValidator(true, 10)
|
||||
val, _ := factory.Validator(10 + int64(rand.Uint32()))
|
||||
val2, _ := factory.Validator(10 + int64(rand.Uint32()))
|
||||
val3, _ := factory.Validator(10 + int64(rand.Uint32()))
|
||||
vals := types.NewValidatorSet([]*types.Validator{val, val2, val3})
|
||||
bootstrapState := makeRandomStateFromValidatorSet(vals, 100, 100)
|
||||
err := stateStore.Bootstrap(bootstrapState)
|
||||
@@ -55,9 +56,9 @@ func TestStoreBootstrap(t *testing.T) {
|
||||
func TestStoreLoadValidators(t *testing.T) {
|
||||
stateDB := dbm.NewMemDB()
|
||||
stateStore := sm.NewStore(stateDB)
|
||||
val, _ := factory.RandValidator(true, 10)
|
||||
val2, _ := factory.RandValidator(true, 10)
|
||||
val3, _ := factory.RandValidator(true, 10)
|
||||
val, _ := factory.Validator(10 + int64(rand.Uint32()))
|
||||
val2, _ := factory.Validator(10 + int64(rand.Uint32()))
|
||||
val3, _ := factory.Validator(10 + int64(rand.Uint32()))
|
||||
vals := types.NewValidatorSet([]*types.Validator{val, val2, val3})
|
||||
|
||||
// 1) LoadValidators loads validators using a height where they were last changed
|
||||
|
||||
Reference in New Issue
Block a user