@@ -2250,10 +2250,11 @@ func TestBaseApp_Init(t *testing.T) {
22502250 require .NoError (t , err )
22512251
22522252 testCases := map [string ]struct {
2253- bapp * BaseApp
2254- expectedPruning pruningtypes.PruningOptions
2255- expectedSnapshot snapshottypes.SnapshotOptions
2256- expectedErr error
2253+ bapp * BaseApp
2254+ expectedPruning pruningtypes.PruningOptions
2255+ expectedSnapshot snapshottypes.SnapshotOptions
2256+ expectedErr error
2257+ isSnapshotManagerNil bool
22572258 }{
22582259 "snapshot but no pruning" : {
22592260 NewBaseApp (name , logger , db , nil ,
@@ -2263,14 +2264,26 @@ func TestBaseApp_Init(t *testing.T) {
22632264 snapshottypes .NewSnapshotOptions (1500 , 2 ),
22642265 // if no pruning is set, the default is PruneNothing
22652266 nil ,
2267+ false ,
2268+ },
2269+ "nil snapshot store" : {
2270+ NewBaseApp (name , logger , db , nil ,
2271+ SetPruning (pruningtypes .NewPruningOptions (pruningtypes .PruningNothing )),
2272+ SetSnapshot (nil , snapshottypes .NewSnapshotOptions (1500 , 2 )),
2273+ ),
2274+ pruningtypes .NewPruningOptions (pruningtypes .PruningNothing ),
2275+ snapshottypes.SnapshotOptions {},
2276+ nil ,
2277+ true ,
22662278 },
22672279 "pruning everything only" : {
22682280 NewBaseApp (name , logger , db , nil ,
22692281 SetPruning (pruningtypes .NewPruningOptions (pruningtypes .PruningEverything )),
22702282 ),
22712283 pruningtypes .NewPruningOptions (pruningtypes .PruningEverything ),
2272- snapshottypes .NewSnapshotOptions ( snapshottypes . SnapshotIntervalOff , 0 ) ,
2284+ snapshottypes.SnapshotOptions {} ,
22732285 nil ,
2286+ true ,
22742287 },
22752288 "pruning nothing only" : {
22762289 NewBaseApp (name , logger , db , nil ,
@@ -2279,6 +2292,7 @@ func TestBaseApp_Init(t *testing.T) {
22792292 pruningtypes .NewPruningOptions (pruningtypes .PruningNothing ),
22802293 snapshottypes .NewSnapshotOptions (snapshottypes .SnapshotIntervalOff , 0 ),
22812294 nil ,
2295+ true ,
22822296 },
22832297 "pruning default only" : {
22842298 NewBaseApp (name , logger , db , nil ,
@@ -2287,6 +2301,7 @@ func TestBaseApp_Init(t *testing.T) {
22872301 pruningtypes .NewPruningOptions (pruningtypes .PruningDefault ),
22882302 snapshottypes .NewSnapshotOptions (snapshottypes .SnapshotIntervalOff , 0 ),
22892303 nil ,
2304+ true ,
22902305 },
22912306 "pruning custom only" : {
22922307 NewBaseApp (name , logger , db , nil ,
@@ -2295,6 +2310,7 @@ func TestBaseApp_Init(t *testing.T) {
22952310 pruningtypes .NewCustomPruningOptions (10 , 10 ),
22962311 snapshottypes .NewSnapshotOptions (snapshottypes .SnapshotIntervalOff , 0 ),
22972312 nil ,
2313+ true ,
22982314 },
22992315 "pruning everything and snapshots" : {
23002316 NewBaseApp (name , logger , db , nil ,
@@ -2304,6 +2320,7 @@ func TestBaseApp_Init(t *testing.T) {
23042320 pruningtypes .NewPruningOptions (pruningtypes .PruningEverything ),
23052321 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23062322 nil ,
2323+ false ,
23072324 },
23082325 "pruning nothing and snapshots" : {
23092326 NewBaseApp (name , logger , db , nil ,
@@ -2313,6 +2330,7 @@ func TestBaseApp_Init(t *testing.T) {
23132330 pruningtypes .NewPruningOptions (pruningtypes .PruningNothing ),
23142331 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23152332 nil ,
2333+ false ,
23162334 },
23172335 "pruning default and snapshots" : {
23182336 NewBaseApp (name , logger , db , nil ,
@@ -2322,6 +2340,7 @@ func TestBaseApp_Init(t *testing.T) {
23222340 pruningtypes .NewPruningOptions (pruningtypes .PruningDefault ),
23232341 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23242342 nil ,
2343+ false ,
23252344 },
23262345 "pruning custom and snapshots" : {
23272346 NewBaseApp (name , logger , db , nil ,
@@ -2331,6 +2350,7 @@ func TestBaseApp_Init(t *testing.T) {
23312350 pruningtypes .NewCustomPruningOptions (10 , 10 ),
23322351 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23332352 nil ,
2353+ false ,
23342354 },
23352355 "error custom pruning 0 interval" : {
23362356 NewBaseApp (name , logger , db , nil ,
@@ -2340,6 +2360,7 @@ func TestBaseApp_Init(t *testing.T) {
23402360 pruningtypes .NewCustomPruningOptions (10 , 0 ),
23412361 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23422362 pruningtypes .ErrPruningIntervalZero ,
2363+ false ,
23432364 },
23442365 "error custom pruning too small interval" : {
23452366 NewBaseApp (name , logger , db , nil ,
@@ -2349,6 +2370,7 @@ func TestBaseApp_Init(t *testing.T) {
23492370 pruningtypes .NewCustomPruningOptions (10 , 9 ),
23502371 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23512372 pruningtypes .ErrPruningIntervalTooSmall ,
2373+ false ,
23522374 },
23532375 "error custom pruning too small keep recent" : {
23542376 NewBaseApp (name , logger , db , nil ,
@@ -2358,15 +2380,17 @@ func TestBaseApp_Init(t *testing.T) {
23582380 pruningtypes .NewCustomPruningOptions (9 , 10 ),
23592381 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23602382 pruningtypes .ErrPruningKeepRecentTooSmall ,
2383+ false ,
23612384 },
2362- "snapshot zero interval - manager not set" : {
2385+ "snapshot zero interval - manager is set" : {
23632386 NewBaseApp (name , logger , db , nil ,
23642387 SetPruning (pruningtypes .NewCustomPruningOptions (10 , 10 )),
23652388 SetSnapshot (snapshotStore , snapshottypes .NewSnapshotOptions (0 , 2 )),
23662389 ),
23672390 pruningtypes .NewCustomPruningOptions (10 , 10 ),
2368- snapshottypes .NewSnapshotOptions (snapshottypes .SnapshotIntervalOff , 0 ),
2391+ snapshottypes .NewSnapshotOptions (snapshottypes .SnapshotIntervalOff , 2 ),
23692392 nil ,
2393+ false ,
23702394 },
23712395 "snapshot zero keep recent - allowed" : {
23722396 NewBaseApp (name , logger , db , nil ,
@@ -2376,6 +2400,7 @@ func TestBaseApp_Init(t *testing.T) {
23762400 pruningtypes .NewCustomPruningOptions (10 , 10 ),
23772401 snapshottypes .NewSnapshotOptions (1500 , 0 ), // 0 snapshot-keep-recent means keep all
23782402 nil ,
2403+ false ,
23792404 },
23802405 }
23812406
@@ -2390,7 +2415,7 @@ func TestBaseApp_Init(t *testing.T) {
23902415 actualPruning := tc .bapp .cms .GetPruning ()
23912416 require .Equal (t , tc .expectedPruning , actualPruning )
23922417
2393- if tc .expectedSnapshot . Interval == snapshottypes . SnapshotIntervalOff {
2418+ if tc .isSnapshotManagerNil {
23942419 require .Nil (t , tc .bapp .snapshotManager )
23952420 continue
23962421 }
0 commit comments