MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / state

Function state

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

Source from the content-addressed store, hash-verified

448}
449
450func state(nVals int, height int64) (sm.State, dbm.DB, []types.PrivValidator) {
451 privVals := make([]types.PrivValidator, nVals)
452 vals := make([]types.GenesisValidator, nVals)
453 for i := 0; i < nVals; i++ {
454 privVal := types.NewMockPV()
455 privVals[i] = privVal
456 vals[i] = types.GenesisValidator{
457 Address: privVal.PrivKey.PubKey().Address(),
458 PubKey: privVal.PrivKey.PubKey(),
459 Power: 1000,
460 Name: fmt.Sprintf("test%d", i),
461 }
462 }
463 s, _ := sm.MakeGenesisState(&types.GenesisDoc{
464 ChainID: "test-chain",
465 Validators: vals,
466 AppHash: nil,
467 })
468
469 // save validators to db for 2 heights
470 stateDB := dbm.NewMemDB()
471 stateStore := sm.NewStore(stateDB, sm.StoreOptions{
472 DiscardABCIResponses: false,
473 })
474 if err := stateStore.Save(s); err != nil {
475 panic(err)
476 }
477
478 for i := 1; i < int(height); i++ {
479 s.LastBlockHeight++
480 s.LastValidators = s.Validators.Copy()
481 if err := stateStore.Save(s); err != nil {
482 panic(err)
483 }
484 }
485 return s, stateDB, privVals
486}

Callers 2

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