@@ -2265,10 +2265,11 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
22652265 require .NoError (t , err )
22662266
22672267 testCases := map [string ]struct {
2268- bapp * BaseApp
2269- expectedPruning pruningtypes.PruningOptions
2270- expectedSnapshot snapshottypes.SnapshotOptions
2271- expectedErr error
2268+ bapp * BaseApp
2269+ expectedPruning pruningtypes.PruningOptions
2270+ expectedSnapshot snapshottypes.SnapshotOptions
2271+ expectedErr error
2272+ isSnapshotManagerNil bool
22722273 }{
22732274 "snapshot but no pruning" : {
22742275 NewBaseApp (name , logger , db , nil ,
@@ -2278,14 +2279,26 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
22782279 snapshottypes .NewSnapshotOptions (1500 , 2 ),
22792280 // if no pruning is set, the default is PruneNothing
22802281 nil ,
2282+ false ,
2283+ },
2284+ "nil snapshot store" : {
2285+ NewBaseApp (name , logger , db , nil ,
2286+ SetPruning (pruningtypes .NewPruningOptions (pruningtypes .PruningNothing )),
2287+ SetSnapshot (nil , snapshottypes .NewSnapshotOptions (1500 , 2 )),
2288+ ),
2289+ pruningtypes .NewPruningOptions (pruningtypes .PruningNothing ),
2290+ snapshottypes.SnapshotOptions {},
2291+ nil ,
2292+ true ,
22812293 },
22822294 "pruning everything only" : {
22832295 NewBaseApp (name , logger , db , nil ,
22842296 SetPruning (pruningtypes .NewPruningOptions (pruningtypes .PruningEverything )),
22852297 ),
22862298 pruningtypes .NewPruningOptions (pruningtypes .PruningEverything ),
2287- snapshottypes .NewSnapshotOptions ( snapshottypes . SnapshotIntervalOff , 0 ) ,
2299+ snapshottypes.SnapshotOptions {} ,
22882300 nil ,
2301+ true ,
22892302 },
22902303 "pruning nothing only" : {
22912304 NewBaseApp (name , logger , db , nil ,
@@ -2294,6 +2307,7 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
22942307 pruningtypes .NewPruningOptions (pruningtypes .PruningNothing ),
22952308 snapshottypes .NewSnapshotOptions (snapshottypes .SnapshotIntervalOff , 0 ),
22962309 nil ,
2310+ true ,
22972311 },
22982312 "pruning default only" : {
22992313 NewBaseApp (name , logger , db , nil ,
@@ -2302,6 +2316,7 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
23022316 pruningtypes .NewPruningOptions (pruningtypes .PruningDefault ),
23032317 snapshottypes .NewSnapshotOptions (snapshottypes .SnapshotIntervalOff , 0 ),
23042318 nil ,
2319+ true ,
23052320 },
23062321 "pruning custom only" : {
23072322 NewBaseApp (name , logger , db , nil ,
@@ -2310,6 +2325,7 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
23102325 pruningtypes .NewCustomPruningOptions (10 , 10 ),
23112326 snapshottypes .NewSnapshotOptions (snapshottypes .SnapshotIntervalOff , 0 ),
23122327 nil ,
2328+ true ,
23132329 },
23142330 "pruning everything and snapshots" : {
23152331 NewBaseApp (name , logger , db , nil ,
@@ -2319,6 +2335,7 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
23192335 pruningtypes .NewPruningOptions (pruningtypes .PruningEverything ),
23202336 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23212337 nil ,
2338+ false ,
23222339 },
23232340 "pruning nothing and snapshots" : {
23242341 NewBaseApp (name , logger , db , nil ,
@@ -2328,6 +2345,7 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
23282345 pruningtypes .NewPruningOptions (pruningtypes .PruningNothing ),
23292346 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23302347 nil ,
2348+ false ,
23312349 },
23322350 "pruning default and snapshots" : {
23332351 NewBaseApp (name , logger , db , nil ,
@@ -2337,6 +2355,7 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
23372355 pruningtypes .NewPruningOptions (pruningtypes .PruningDefault ),
23382356 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23392357 nil ,
2358+ false ,
23402359 },
23412360 "pruning custom and snapshots" : {
23422361 NewBaseApp (name , logger , db , nil ,
@@ -2346,6 +2365,7 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
23462365 pruningtypes .NewCustomPruningOptions (10 , 10 ),
23472366 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23482367 nil ,
2368+ false ,
23492369 },
23502370 "error custom pruning 0 interval" : {
23512371 NewBaseApp (name , logger , db , nil ,
@@ -2355,6 +2375,7 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
23552375 pruningtypes .NewCustomPruningOptions (10 , 0 ),
23562376 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23572377 pruningtypes .ErrPruningIntervalZero ,
2378+ false ,
23582379 },
23592380 "error custom pruning too small interval" : {
23602381 NewBaseApp (name , logger , db , nil ,
@@ -2364,6 +2385,7 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
23642385 pruningtypes .NewCustomPruningOptions (10 , 9 ),
23652386 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23662387 pruningtypes .ErrPruningIntervalTooSmall ,
2388+ false ,
23672389 },
23682390 "error custom pruning too small keep recent" : {
23692391 NewBaseApp (name , logger , db , nil ,
@@ -2373,15 +2395,17 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
23732395 pruningtypes .NewCustomPruningOptions (9 , 10 ),
23742396 snapshottypes .NewSnapshotOptions (1500 , 2 ),
23752397 pruningtypes .ErrPruningKeepRecentTooSmall ,
2398+ false ,
23762399 },
2377- "snapshot zero interval - manager not set" : {
2400+ "snapshot zero interval - manager is set" : {
23782401 NewBaseApp (name , logger , db , nil ,
23792402 SetPruning (pruningtypes .NewCustomPruningOptions (10 , 10 )),
23802403 SetSnapshot (snapshotStore , snapshottypes .NewSnapshotOptions (0 , 2 )),
23812404 ),
23822405 pruningtypes .NewCustomPruningOptions (10 , 10 ),
2383- snapshottypes .NewSnapshotOptions (snapshottypes .SnapshotIntervalOff , 0 ),
2406+ snapshottypes .NewSnapshotOptions (snapshottypes .SnapshotIntervalOff , 2 ),
23842407 nil ,
2408+ false ,
23852409 },
23862410 "snapshot zero keep recent - allowed" : {
23872411 NewBaseApp (name , logger , db , nil ,
@@ -2391,6 +2415,7 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
23912415 pruningtypes .NewCustomPruningOptions (10 , 10 ),
23922416 snapshottypes .NewSnapshotOptions (1500 , 0 ), // 0 snapshot-keep-recent means keep all
23932417 nil ,
2418+ false ,
23942419 },
23952420 }
23962421
@@ -2407,7 +2432,7 @@ func TestBaseApp_Init_PruningAndSnapshot(t *testing.T) {
24072432 actualPruning := tc .bapp .cms .GetPruning ()
24082433 require .Equal (t , tc .expectedPruning , actualPruning )
24092434
2410- if tc .expectedSnapshot . Interval == snapshottypes . SnapshotIntervalOff {
2435+ if tc .isSnapshotManagerNil {
24112436 require .Nil (t , tc .bapp .snapshotManager )
24122437 continue
24132438 }
0 commit comments