MCPcopy Create free account
hub / github.com/Sifchain/sifnode / TestAppUpgrade_CannotLoadCorruptStoreUsingLatestHeight

Function TestAppUpgrade_CannotLoadCorruptStoreUsingLatestHeight

app/app_test.go:107–214  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

105}
106
107func TestAppUpgrade_CannotLoadCorruptStoreUsingLatestHeight(t *testing.T) {
108 // Skip this test that shows how SDK allows stores to get installed with 0 height,
109 // then, after pruning halts chain, it becomes impossible to load them at correct height,
110 // loosing any data that was added since last upgrade.
111 // Trying to rename (i.e copy) also fails as old store still errors.
112 t.Skip()
113 encCfg := MakeTestEncodingConfig()
114 db := dbm.NewMemDB()
115 app := NewSifApp(
116 log.NewTMLogger(log.NewSyncWriter(os.Stdout)),
117 db,
118 nil,
119 false,
120 map[int64]bool{},
121 DefaultNodeHome,
122 0,
123 encCfg,
124 EmptyAppOptions{},
125 )
126 err := app.LoadLatestVersion()
127 require.NoError(t, err)
128
129 genesisState := NewDefaultGenesisState(encCfg.Marshaler)
130 stateBytes, err := json.MarshalIndent(genesisState, "", " ")
131 require.NoError(t, err)
132
133 // Initialize the chain
134 app.InitChain(
135 abci.RequestInitChain{
136 Validators: []abci.ValidatorUpdate{},
137 AppStateBytes: stateBytes,
138 },
139 )
140
141 // Commit enough to trigger beginning of pruning soon
142 for i := 1; i < 105; i++ {
143 app.BeginBlock(abci.RequestBeginBlock{Header: types.Header{Height: int64(i)}})
144 app.EndBlock(abci.RequestEndBlock{Height: int64(i)})
145 app.Commit()
146 }
147
148 app = NewSifApp(
149 log.NewTMLogger(log.NewSyncWriter(os.Stdout)),
150 db,
151 nil,
152 false,
153 map[int64]bool{},
154 DefaultNodeHome,
155 0,
156 encCfg,
157 EmptyAppOptions{},
158 func(app *baseapp.BaseApp) {
159 cms := rootmulti.NewStore(db, app.Logger())
160 cms.SetPruning(storetypes.PruneDefault)
161 app.SetCMS(cms)
162 },
163 )
164 // Mount and load newStore which will be loaded with version 0,

Callers

nothing calls this directly

Calls 8

NewSifAppFunction · 0.85
NewDefaultGenesisStateFunction · 0.85
MakeTestEncodingConfigFunction · 0.70
InitChainMethod · 0.65
BeginBlockMethod · 0.45
EndBlockMethod · 0.45
LoggerMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected