@@ -420,6 +420,48 @@ func (suite *TendermintTestSuite) TestUpdateState() {
420
420
suite .Require ().False (found )
421
421
}, true ,
422
422
},
423
+ {
424
+ "success with pruned consensus state using duplicate header" , func () {
425
+ // this height will be expired and pruned
426
+ err := path .EndpointA .UpdateClient ()
427
+ suite .Require ().NoError (err )
428
+ pruneHeight = path .EndpointA .GetClientState ().GetLatestHeight ().(clienttypes.Height )
429
+
430
+ // assert that a consensus state exists at the prune height
431
+ consensusState , found := path .EndpointA .Chain .GetConsensusState (path .EndpointA .ClientID , pruneHeight )
432
+ suite .Require ().True (found )
433
+ suite .Require ().NotNil (consensusState )
434
+
435
+ // Increment the time by a week
436
+ suite .coordinator .IncrementTimeBy (7 * 24 * time .Hour )
437
+
438
+ // create the consensus state that can be used as trusted height for next update
439
+ err = path .EndpointA .UpdateClient ()
440
+ suite .Require ().NoError (err )
441
+
442
+ // Increment the time by another week, then update the client.
443
+ // This will cause the first two consensus states to become expired.
444
+ suite .coordinator .IncrementTimeBy (7 * 24 * time .Hour )
445
+ err = path .EndpointA .UpdateClient ()
446
+ suite .Require ().NoError (err )
447
+
448
+ // use the same header which just updated the client
449
+ clientMessage , err = path .EndpointA .Chain .ConstructUpdateTMClientHeader (path .EndpointA .Counterparty .Chain , path .EndpointA .ClientID )
450
+ suite .Require ().NoError (err )
451
+ },
452
+ func () {
453
+ tmHeader , ok := clientMessage .(* ibctm.Header )
454
+ suite .Require ().True (ok )
455
+
456
+ clientState := path .EndpointA .GetClientState ()
457
+ suite .Require ().True (clientState .GetLatestHeight ().EQ (tmHeader .GetHeight ())) // new update, updated client state should have changed
458
+ suite .Require ().True (clientState .GetLatestHeight ().EQ (consensusHeights [0 ]))
459
+
460
+ // ensure consensus state was pruned
461
+ _ , found := path .EndpointA .Chain .GetConsensusState (path .EndpointA .ClientID , pruneHeight )
462
+ suite .Require ().False (found )
463
+ }, true ,
464
+ },
423
465
{
424
466
"invalid ClientMessage type" , func () {
425
467
clientMessage = & ibctm.Misbehaviour {}
0 commit comments