MCPcopy Create free account
hub / github.com/tendermint/tendermint / state

Function state

node/node_test.go:607–641  ·  view source on GitHub ↗
(nVals int, height int64)

Source from the content-addressed store, hash-verified

605}
606
607func state(nVals int, height int64) (sm.State, dbm.DB, []types.PrivValidator) {
608 privVals := make([]types.PrivValidator, nVals)
609 vals := make([]types.GenesisValidator, nVals)
610 for i := 0; i < nVals; i++ {
611 privVal := types.NewMockPV()
612 privVals[i] = privVal
613 vals[i] = types.GenesisValidator{
614 Address: privVal.PrivKey.PubKey().Address(),
615 PubKey: privVal.PrivKey.PubKey(),
616 Power: 1000,
617 Name: fmt.Sprintf("test%d", i),
618 }
619 }
620 s, _ := sm.MakeGenesisState(&types.GenesisDoc{
621 ChainID: "test-chain",
622 Validators: vals,
623 AppHash: nil,
624 })
625
626 // save validators to db for 2 heights
627 stateDB := dbm.NewMemDB()
628 stateStore := sm.NewStore(stateDB)
629 if err := stateStore.Save(s); err != nil {
630 panic(err)
631 }
632
633 for i := 1; i < int(height); i++ {
634 s.LastBlockHeight++
635 s.LastValidators = s.Validators.Copy()
636 if err := stateStore.Save(s); err != nil {
637 panic(err)
638 }
639 }
640 return s, stateDB, privVals
641}
642
643func TestLoadStateFromGenesis(t *testing.T) {
644 _ = loadStatefromGenesis(t)

Callers 3

TestCreateProposalBlockFunction · 0.70
TestMaxProposalBlockSizeFunction · 0.70

Calls 5

SaveMethod · 0.95
NewMockPVFunction · 0.92
AddressMethod · 0.65
PubKeyMethod · 0.65
CopyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…