@@ -561,3 +561,93 @@ func TestBlockProcessor_PrepareBlockForDBMiniBlocksDetails(t *testing.T) {
561561 },
562562 }, blockResults .Block )
563563}
564+
565+ func TestPrepareExecutionResult (t * testing.T ) {
566+ t .Parallel ()
567+
568+ bp , _ := NewBlockProcessor (& mock.HasherMock {}, & mock.MarshalizerMock {}, & mock.PubkeyConverterMock {})
569+
570+ executionResultHeaderHash := []byte ("h1" )
571+ mb1Hash := []byte ("mb1" )
572+ txHash := []byte ("tx1" )
573+
574+ outportBlockWithHeader := & outport.OutportBlockWithHeader {
575+ Header : & dataBlock.HeaderV3 {
576+ ExecutionResults : []* dataBlock.ExecutionResult {
577+ {
578+ BaseExecutionResult : & dataBlock.BaseExecutionResult {
579+ HeaderHash : executionResultHeaderHash ,
580+ HeaderNonce : 1 ,
581+ HeaderRound : 2 ,
582+ HeaderEpoch : 3 ,
583+ },
584+ MiniBlockHeaders : []dataBlock.MiniBlockHeader {
585+ {
586+ Hash : mb1Hash ,
587+ SenderShardID : 0 ,
588+ ReceiverShardID : 0 ,
589+ Type : dataBlock .TxBlock ,
590+ TxCount : 1 ,
591+ },
592+ },
593+ AccumulatedFees : big .NewInt (1 ),
594+ DeveloperFees : big .NewInt (2 ),
595+ },
596+ },
597+ },
598+ OutportBlock : & outport.OutportBlock {
599+ BlockData : & outport.BlockData {
600+ Results : map [string ]* outport.ExecutionResultData {
601+ hex .EncodeToString (executionResultHeaderHash ): {
602+ Body : & dataBlock.Body {
603+ MiniBlocks : []* dataBlock.MiniBlock {
604+ {
605+ SenderShardID : 0 ,
606+ ReceiverShardID : 0 ,
607+ Type : dataBlock .TxBlock ,
608+ TxHashes : [][]byte {txHash },
609+ },
610+ },
611+ },
612+ TransactionPool : & outport.TransactionPool {
613+ Transactions : map [string ]* outport.TxInfo {
614+ hex .EncodeToString (txHash ): {
615+ Transaction : & transaction.Transaction {},
616+ ExecutionOrder : 2 ,
617+ },
618+ },
619+ },
620+ },
621+ },
622+ },
623+ },
624+ }
625+
626+ results , err := bp .prepareExecutionResults (outportBlockWithHeader )
627+ require .Nil (t , err )
628+ require .Len (t , results , 1 )
629+ results [0 ].UUID = ""
630+ require .Equal (t , & data.ExecutionResult {
631+ Hash : "6831" ,
632+ RootHash : "" ,
633+ NotarizedInBlockHash : "" ,
634+ AccumulatedFees : "1" ,
635+ DeveloperFees : "2" ,
636+ TxCount : 0 ,
637+ GasUsed : 0 ,
638+ Nonce : 1 ,
639+ Round : 2 ,
640+ Epoch : 3 ,
641+ MiniBlocksHashes : []string {"2dae16da63bc04a18cf7609e0a79d7867b11463660dbab048b044b8434bf0a82" },
642+ MiniBlocksDetails : []* data.MiniBlocksDetails {
643+ {
644+ IndexLastProcessedTx : 0 ,
645+ IndexFirstProcessedTx : 0 ,
646+ Type : dataBlock .TxBlock .String (),
647+ ProcessingType : dataBlock .Normal .String (),
648+ TxsHashes : []string {hex .EncodeToString (txHash )},
649+ ExecutionOrderTxsIndices : []int {2 },
650+ },
651+ },
652+ }, results [0 ])
653+ }
0 commit comments