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

Function TestStoreLoadValidators

state/store_test.go:24–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestStoreLoadValidators(t *testing.T) {
25 stateDB := dbm.NewMemDB()
26 stateStore := sm.NewStore(stateDB, sm.StoreOptions{
27 DiscardABCIResponses: false,
28 })
29 val, _ := types.RandValidator(true, 10)
30 vals := types.NewValidatorSet([]*types.Validator{val})
31
32 // 1) LoadValidators loads validators using a height where they were last changed
33 err := sm.SaveValidatorsInfo(stateDB, 1, 1, vals)
34 require.NoError(t, err)
35 err = sm.SaveValidatorsInfo(stateDB, 2, 1, vals)
36 require.NoError(t, err)
37 loadedVals, err := stateStore.LoadValidators(2)
38 require.NoError(t, err)
39 assert.NotZero(t, loadedVals.Size())
40
41 // 2) LoadValidators loads validators using a checkpoint height
42
43 err = sm.SaveValidatorsInfo(stateDB, sm.ValSetCheckpointInterval, 1, vals)
44 require.NoError(t, err)
45
46 loadedVals, err = stateStore.LoadValidators(sm.ValSetCheckpointInterval)
47 require.NoError(t, err)
48 assert.NotZero(t, loadedVals.Size())
49}
50
51func BenchmarkLoadValidators(b *testing.B) {
52 const valSetSize = 100

Callers

nothing calls this directly

Calls 4

LoadValidatorsMethod · 0.95
RandValidatorFunction · 0.92
NewValidatorSetFunction · 0.92
SizeMethod · 0.65

Tested by

no test coverage detected