@@ -401,7 +401,8 @@ func TestProcessorRunnerRunAllProcessorsOnLedgerProtocolVersionNotSupported(t *t
401401 maxBatchSize := 100000
402402
403403 config := Config {
404- NetworkPassphrase : network .PublicNetworkPassphrase ,
404+ NetworkPassphrase : network .PublicNetworkPassphrase ,
405+ SkipProtocolVersionCheck : false ,
405406 }
406407
407408 q := & mockDBQ {}
@@ -411,7 +412,7 @@ func TestProcessorRunnerRunAllProcessorsOnLedgerProtocolVersionNotSupported(t *t
411412 V0 : & xdr.LedgerCloseMetaV0 {
412413 LedgerHeader : xdr.LedgerHeaderHistoryEntry {
413414 Header : xdr.LedgerHeader {
414- LedgerVersion : 200 ,
415+ LedgerVersion : xdr . Uint32 ( MaxSupportedProtocolVersion + 1 ) ,
415416 },
416417 },
417418 },
@@ -444,12 +445,85 @@ func TestProcessorRunnerRunAllProcessorsOnLedgerProtocolVersionNotSupported(t *t
444445 _ , err := runner .RunAllProcessorsOnLedger (ledger )
445446 assert .EqualError (t , err ,
446447 fmt .Sprintf (
447- "Error while checking for supported protocol version: This Horizon version does not support protocol version 200. The latest supported protocol version is %d. Please upgrade to the latest Horizon version." ,
448+ "Error while checking for supported protocol version: This Horizon version does not support protocol version %d. The latest supported protocol version is %d. Please upgrade to the latest Horizon version." ,
449+ MaxSupportedProtocolVersion + 1 ,
448450 MaxSupportedProtocolVersion ,
449451 ),
450452 )
451453}
452454
455+ func TestProcessorRunnerRunAllProcessorsOnLedgerProtocolVersionNotSupportedButAllowed (t * testing.T ) {
456+ ctx := context .Background ()
457+
458+ config := Config {
459+ NetworkPassphrase : network .PublicNetworkPassphrase ,
460+ SkipProtocolVersionCheck : true ,
461+ }
462+
463+ mockSession := & db.MockSession {}
464+ q := & mockDBQ {}
465+ defer mock .AssertExpectationsForObjects (t , q )
466+
467+ ledger := xdr.LedgerCloseMeta {
468+ V0 : & xdr.LedgerCloseMetaV0 {
469+ LedgerHeader : xdr.LedgerHeaderHistoryEntry {
470+ Header : xdr.LedgerHeader {
471+ LedgerVersion : xdr .Uint32 (MaxSupportedProtocolVersion + 1 ),
472+ BucketListHash : xdr .Hash ([32 ]byte {0 , 1 , 2 }),
473+ LedgerSeq : 23 ,
474+ },
475+ },
476+ },
477+ }
478+
479+ // Batches
480+ defer mock .AssertExpectationsForObjects (t , mockTxProcessorBatchBuilders (q , mockSession , ctx )... )
481+ defer mock .AssertExpectationsForObjects (t , mockChangeProcessorBatchBuilders (q , ctx , true )... )
482+ defer mock .AssertExpectationsForObjects (t , mockFilteredOutProcessorsForNoRules (q , mockSession , ctx )... )
483+
484+ mockBatchInsertBuilder := & history.MockLedgersBatchInsertBuilder {}
485+ q .MockQLedgers .On ("NewLedgerBatchInsertBuilder" ).Return (mockBatchInsertBuilder )
486+ mockBatchInsertBuilder .On (
487+ "Add" ,
488+ ledger .V0 .LedgerHeader , 0 , 0 , 0 , 0 , CurrentVersion ).Return (nil ).Once ()
489+ mockBatchInsertBuilder .On (
490+ "Exec" ,
491+ ctx ,
492+ mockSession ,
493+ ).Return (nil ).Once ()
494+
495+ defer mock .AssertExpectationsForObjects (t , mockBatchInsertBuilder )
496+
497+ q .MockQAssetStats .On ("InsertAssetContracts" , ctx , []history.AssetContract (nil )).
498+ Return (nil ).Once ()
499+ q .MockQAssetStats .On ("UpdateAssetContractExpirations" , ctx , []xdr.Hash {}, []uint32 {}).
500+ Return (nil ).Once ()
501+ q .MockQAssetStats .On ("DeleteAssetContractsExpiringAt" , ctx , uint32 (22 )).
502+ Return (int64 (0 ), nil ).Once ()
503+
504+ q .MockQAssetStats .On ("RemoveContractAssetBalances" , ctx , []xdr.Hash (nil )).
505+ Return (nil ).Once ()
506+ q .MockQAssetStats .On ("UpdateContractAssetBalanceAmounts" , ctx , []xdr.Hash {}, []string {}).
507+ Return (nil ).Once ()
508+ q .MockQAssetStats .On ("InsertContractAssetBalances" , ctx , []history.ContractAssetBalance (nil )).
509+ Return (nil ).Once ()
510+ q .MockQAssetStats .On ("UpdateContractAssetBalanceExpirations" , ctx , []xdr.Hash {}, []uint32 {}).
511+ Return (nil ).Once ()
512+ q .MockQAssetStats .On ("DeleteContractAssetBalancesExpiringAt" , ctx , uint32 (22 )).
513+ Return ([]history.ContractAssetBalance {}, nil ).Once ()
514+
515+ runner := ProcessorRunner {
516+ ctx : ctx ,
517+ config : config ,
518+ historyQ : q ,
519+ session : mockSession ,
520+ filters : & MockFilters {},
521+ }
522+
523+ _ , err := runner .RunAllProcessorsOnLedger (ledger )
524+ assert .NoError (t , err )
525+ }
526+
453527func mockTxProcessorBatchBuilders (q * mockDBQ , mockSession * db.MockSession , ctx context.Context ) []interface {} {
454528 // no mocking of builder Add methods needed, the fake ledgers used in tests don't have any operations
455529 // that would trigger the respective processors to invoke Add, each test locally decides to use
0 commit comments