@@ -505,6 +505,34 @@ func TestPrettifyStruct(t *testing.T) {
505505 t .Log ("MetaBlock" , prettified )
506506
507507 })
508+
509+ t .Run ("with headers V3" , func (t * testing.T ) {
510+ t .Parallel ()
511+
512+ header := & block.HeaderV3 {}
513+ prettified , err := common .PrettifyStruct (header )
514+ require .NoError (t , err )
515+ t .Log ("HeaderV3" , prettified )
516+
517+ meta := & block.MetaBlockV3 {}
518+ prettified , err = common .PrettifyStruct (meta )
519+ require .NoError (t , err )
520+ t .Log ("MetaBlockV3" , prettified )
521+ })
522+
523+ t .Run ("with complete headers V3" , func (t * testing.T ) {
524+ t .Parallel ()
525+
526+ header := createMockShardHeaderV3 ()
527+ prettified , err := common .PrettifyStruct (header )
528+ require .NoError (t , err )
529+ t .Log ("HeaderV3" , prettified )
530+
531+ meta := createMockMetaHeaderV3 ()
532+ prettified , err = common .PrettifyStruct (meta )
533+ require .NoError (t , err )
534+ t .Log ("MetaBlockV3" , prettified )
535+ })
508536}
509537
510538func TestGetLastBaseExecutionResultHandler (t * testing.T ) {
@@ -689,6 +717,184 @@ func TestPrepareLogEventsKey(t *testing.T) {
689717 require .Equal (t , "logsLogsX" , string (logs ))
690718}
691719
720+ func createMockMetaHeaderV3 () * block.MetaBlockV3 {
721+ return & block.MetaBlockV3 {
722+ Nonce : 42 ,
723+ Epoch : 2 ,
724+ Round : 15 ,
725+ TimestampMs : 123456789 ,
726+ PrevHash : []byte ("prev_hash" ),
727+ PrevRandSeed : []byte ("prev_seed" ),
728+ RandSeed : []byte ("new_seed" ),
729+ ChainID : []byte ("chain-id" ),
730+ SoftwareVersion : []byte ("v1.0.0" ),
731+ LeaderSignature : []byte ("leader_signature" ),
732+
733+ MiniBlockHeaders : []block.MiniBlockHeader {
734+ {Hash : []byte ("meta-to-s0" ), SenderShardID : core .MetachainShardId , ReceiverShardID : 0 },
735+ {Hash : []byte ("meta-to-s1" ), SenderShardID : core .MetachainShardId , ReceiverShardID : 1 },
736+ },
737+
738+ ShardInfo : []block.ShardData {
739+ {
740+ ShardID : 0 ,
741+ Round : 10 ,
742+ Nonce : 41 ,
743+ Epoch : 1 ,
744+ HeaderHash : []byte ("shard0-hash" ),
745+ ShardMiniBlockHeaders : []block.MiniBlockHeader {
746+ {SenderShardID : 0 , ReceiverShardID : 1 , Hash : []byte ("s0-to-s1" )},
747+ },
748+ },
749+ {
750+ ShardID : 1 ,
751+ Round : 11 ,
752+ Nonce : 40 ,
753+ Epoch : 1 ,
754+ HeaderHash : []byte ("shard1-hash" ),
755+ ShardMiniBlockHeaders : []block.MiniBlockHeader {
756+ {SenderShardID : 1 , ReceiverShardID : 0 , Hash : []byte ("s1-to-s0" )},
757+ },
758+ },
759+ },
760+ ShardInfoProposal : []block.ShardDataProposal {
761+ {ShardID : 0 , HeaderHash : []byte ("shard-0-hash" ), Nonce : 41 , Round : 10 , Epoch : 1 },
762+ {ShardID : 1 , HeaderHash : []byte ("shard-1-hash" ), Nonce : 40 , Round : 11 , Epoch : 1 },
763+ },
764+ ExecutionResults : []* block.MetaExecutionResult {
765+ {
766+ ExecutionResult : & block.BaseMetaExecutionResult {
767+ BaseExecutionResult : & block.BaseExecutionResult {
768+ HeaderHash : []byte ("hdr-hash-10" ),
769+ HeaderNonce : 39 ,
770+ HeaderRound : 10 ,
771+ HeaderEpoch : 1 ,
772+ RootHash : []byte ("root-hash-10" ),
773+ },
774+ AccumulatedFeesInEpoch : big .NewInt (1000 ),
775+ DevFeesInEpoch : big .NewInt (100 ),
776+ ValidatorStatsRootHash : []byte ("validator-stats-root-hash" ),
777+ },
778+ AccumulatedFees : big .NewInt (1000 ),
779+ DeveloperFees : big .NewInt (100 ),
780+ ReceiptsHash : []byte ("receipts hash" ),
781+ },
782+ {
783+ ExecutionResult : & block.BaseMetaExecutionResult {
784+ BaseExecutionResult : & block.BaseExecutionResult {
785+ HeaderHash : []byte ("hdr-hash-11" ),
786+ HeaderNonce : 40 ,
787+ HeaderRound : 11 ,
788+ HeaderEpoch : 1 ,
789+ RootHash : []byte ("root-hash-11" ),
790+ },
791+ AccumulatedFeesInEpoch : big .NewInt (2000 ),
792+ DevFeesInEpoch : big .NewInt (200 ),
793+ ValidatorStatsRootHash : []byte ("validator-stats-root-hash-1" ),
794+ },
795+ AccumulatedFees : big .NewInt (2000 ),
796+ DeveloperFees : big .NewInt (200 ),
797+ ReceiptsHash : []byte ("receipts-hash-1" ),
798+ },
799+ {
800+ ExecutionResult : & block.BaseMetaExecutionResult {
801+ BaseExecutionResult : & block.BaseExecutionResult {
802+ HeaderHash : []byte ("hdr-hash-last" ),
803+ HeaderNonce : 41 ,
804+ HeaderRound : 12 ,
805+ HeaderEpoch : 2 ,
806+ RootHash : []byte ("root-hash-last" ),
807+ },
808+ AccumulatedFeesInEpoch : big .NewInt (3000 ),
809+ DevFeesInEpoch : big .NewInt (300 ),
810+ ValidatorStatsRootHash : []byte ("validator-stats-root-hash-2" ),
811+ },
812+ AccumulatedFees : big .NewInt (3000 ),
813+ DeveloperFees : big .NewInt (300 ),
814+ ReceiptsHash : []byte ("receipts-hash-2" ),
815+ },
816+ },
817+
818+ LastExecutionResult : & block.MetaExecutionResultInfo {
819+ NotarizedInRound : 14 ,
820+ ExecutionResult : & block.BaseMetaExecutionResult {
821+ BaseExecutionResult : & block.BaseExecutionResult {
822+ HeaderHash : []byte ("hdr-hash-last" ),
823+ HeaderNonce : 41 ,
824+ HeaderRound : 12 ,
825+ HeaderEpoch : 2 ,
826+ RootHash : []byte ("root-hash-last" ),
827+ },
828+ AccumulatedFeesInEpoch : big .NewInt (3000 ),
829+ DevFeesInEpoch : big .NewInt (300 ),
830+ ValidatorStatsRootHash : []byte ("validator-stats-root-hash-2" ),
831+ },
832+ },
833+ }
834+ }
835+
836+ func createMockShardHeaderV3 () * block.HeaderV3 {
837+ var hdrNonce = uint64 (56 )
838+ var hdrRound = uint64 (67 )
839+ var hdrEpoch = uint32 (78 )
840+ return & block.HeaderV3 {
841+ Nonce : hdrNonce ,
842+ PrevHash : []byte ("prev hash" ),
843+ PrevRandSeed : []byte ("prev rand seed" ),
844+ RandSeed : []byte ("rand seed" ),
845+ ShardID : uint32 (1 ),
846+ TimestampMs : 0 ,
847+ Round : hdrRound ,
848+ Epoch : hdrEpoch ,
849+ BlockBodyType : block .TxBlock ,
850+ LeaderSignature : []byte ("signature" ),
851+ MiniBlockHeaders : nil ,
852+ PeerChanges : nil ,
853+ MetaBlockHashes : nil ,
854+ TxCount : 0 ,
855+ ChainID : []byte ("chain ID" ),
856+ SoftwareVersion : []byte ("version" ),
857+ LastExecutionResult : & block.ExecutionResultInfo {
858+ ExecutionResult : & block.BaseExecutionResult {
859+ HeaderHash : []byte ("header hash" ),
860+ HeaderNonce : hdrNonce - 1 ,
861+ HeaderRound : hdrRound - 1 ,
862+ HeaderEpoch : hdrEpoch ,
863+ RootHash : []byte ("root hash" ),
864+ },
865+ NotarizedInRound : hdrRound - 1 ,
866+ },
867+ ExecutionResults : []* block.ExecutionResult {
868+ {
869+ BaseExecutionResult : & block.BaseExecutionResult {
870+ HeaderHash : []byte ("header hash" ),
871+ HeaderNonce : hdrNonce - 3 ,
872+ HeaderRound : hdrRound - 3 ,
873+ HeaderEpoch : hdrEpoch - 1 ,
874+ RootHash : []byte ("root hash" ),
875+ },
876+ },
877+ {
878+ BaseExecutionResult : & block.BaseExecutionResult {
879+ HeaderHash : []byte ("header hash" ),
880+ HeaderNonce : hdrNonce - 2 ,
881+ HeaderRound : hdrRound - 2 ,
882+ HeaderEpoch : hdrEpoch - 1 ,
883+ RootHash : []byte ("root hash" ),
884+ },
885+ },
886+ {
887+ BaseExecutionResult : & block.BaseExecutionResult {
888+ HeaderHash : []byte ("header hash" ),
889+ HeaderNonce : hdrNonce - 1 ,
890+ HeaderRound : hdrRound - 1 ,
891+ HeaderEpoch : hdrEpoch ,
892+ RootHash : []byte ("root hash" ),
893+ },
894+ },
895+ },
896+ }
897+ }
692898func TestGetMiniBlockHeadersFromExecResult (t * testing.T ) {
693899 t .Parallel ()
694900
0 commit comments