2
2
3
3
package com .hedera .mirror .importer .reader .block ;
4
4
5
- import static com .hedera .mirror .common .util .DomainUtils .NANOS_PER_SECOND ;
6
5
import static org .assertj .core .api .Assertions .assertThat ;
7
6
import static org .assertj .core .api .Assertions .assertThatThrownBy ;
8
7
19
18
import com .hedera .hapi .block .stream .protoc .RecordFileItem ;
20
19
import com .hedera .hapi .platform .event .legacy .EventTransaction ;
21
20
import com .hedera .mirror .common .domain .DigestAlgorithm ;
21
+ import com .hedera .mirror .common .domain .DomainBuilder ;
22
22
import com .hedera .mirror .common .domain .transaction .BlockFile ;
23
23
import com .hedera .mirror .common .util .DomainUtils ;
24
24
import com .hedera .mirror .importer .TestUtils ;
27
27
import com .hederahashgraph .api .proto .java .AtomicBatchTransactionBody ;
28
28
import com .hederahashgraph .api .proto .java .CryptoTransferTransactionBody ;
29
29
import com .hederahashgraph .api .proto .java .SignedTransaction ;
30
- import com .hederahashgraph .api .proto .java .Timestamp ;
31
30
import com .hederahashgraph .api .proto .java .Transaction ;
32
31
import com .hederahashgraph .api .proto .java .TransactionBody ;
33
32
import java .time .Instant ;
@@ -45,42 +44,42 @@ public class ProtoBlockFileReaderTest {
45
44
46
45
public static final List <BlockFile > TEST_BLOCK_FILES = List .of (
47
46
BlockFile .builder ()
48
- .consensusStart (1743543388185101630L )
49
- .consensusEnd (1743543388372187000L )
50
- .count (5L )
47
+ .consensusStart (1746477299499963486L )
48
+ .consensusEnd (1746477301609588787L )
49
+ .count (6L )
51
50
.digestAlgorithm (DigestAlgorithm .SHA_384 )
52
51
.hash (
53
- "449e750e4da69fecb92234a8dede0ac3e7b53141aecc1a30cba050ec44a729c9b5e5a06607ac6ac8a17110fb99c202ef " )
54
- .index (2301160L )
55
- .name (BlockFile .getBlockStreamFilename (2301160 ))
52
+ "fb31381a223175f1f8730df52be31c318eb093f8029440da2d3f0ed19f29e58af111b5c1600412eed02be1e92b4befb4 " )
53
+ .index (76L )
54
+ .name (BlockFile .getBlockStreamFilename (76 ))
56
55
.previousHash (
57
- "aeb9db588e53e6b3d1d39f1a75dbf7123e95c18cea102380989bdda89079809e2217bfb230eda982e37e36f40e87988a " )
58
- .roundStart (2301161L )
59
- .roundEnd (2301161L )
56
+ "47ad177417a4e6a85c67660dc9abcd5e735ae689f5a3096c68bbdff6b330e7951ddd545cd16445d19118975464380a3b " )
57
+ .roundStart (521L )
58
+ .roundEnd (527L )
60
59
.version (ProtoBlockFileReader .VERSION )
61
60
.build (),
62
61
BlockFile .builder ()
63
- .consensusStart (1743543388490143524L )
64
- .consensusEnd (1743543388704490000L )
65
- .count (4L )
62
+ .consensusStart (1746477301948765000L )
63
+ .consensusEnd (1746477303380786221L )
64
+ .count (3L )
66
65
.digestAlgorithm (DigestAlgorithm .SHA_384 )
67
66
.hash (
68
- "0d2523cc3f44a0ffebd9bcd1950c685deb932e53b7af3e8cd202397ae2d110c3452797eb0ff05cca1ffe9780e31bec34 " )
69
- .index (2301161L )
70
- .name (BlockFile .getBlockStreamFilename (2301161 ))
67
+ "c198f382ba69796c805450842de7f97c91d2a8a7f88f43c977247d15b898b5b09ac7f857fa13fe627f8d15bb68879bb2 " )
68
+ .index (77L )
69
+ .name (BlockFile .getBlockStreamFilename (77 ))
71
70
.previousHash (
72
- "449e750e4da69fecb92234a8dede0ac3e7b53141aecc1a30cba050ec44a729c9b5e5a06607ac6ac8a17110fb99c202ef " )
73
- .roundStart (2301162L )
74
- .roundEnd (2301162L )
71
+ "fb31381a223175f1f8730df52be31c318eb093f8029440da2d3f0ed19f29e58af111b5c1600412eed02be1e92b4befb4 " )
72
+ .roundStart (528L )
73
+ .roundEnd (534L )
75
74
.version (ProtoBlockFileReader .VERSION )
76
75
.build (),
77
76
BlockFile .builder ()
78
- .consensusStart (1741033890694027337L )
79
- .consensusEnd (1741033890694027337L )
80
- .count (0L )
77
+ .consensusStart (1746477093416982857L )
78
+ .consensusEnd (1746477093416983584L )
79
+ .count (728L )
81
80
.digestAlgorithm (DigestAlgorithm .SHA_384 )
82
81
.hash (
83
- "40ecba4f4134cf9e7a6fb643b54cda852ed4dcacee7d339a120165a6552169b52568dcdd921913df69b18074d6fd6cf0 " )
82
+ "958e5fba01f066cdbe2733059b33bf0ebec0fbac5eac5b0806ebc2c792187650e1b0b34a6a4c83025a31c2da787f510d " )
84
83
.index (0L )
85
84
.name (BlockFile .getBlockStreamFilename (0 ))
86
85
.previousHash (
@@ -89,8 +88,8 @@ public class ProtoBlockFileReaderTest {
89
88
.roundEnd (1L )
90
89
.version (ProtoBlockFileReader .VERSION )
91
90
.build ());
92
- private static final long TIMESTAMP = 1738889423L ;
93
91
92
+ private final DomainBuilder domainBuilder = new DomainBuilder ();
94
93
private final ProtoBlockFileReader reader = new ProtoBlockFileReader ();
95
94
96
95
@ ParameterizedTest (name = "{0}" )
@@ -343,16 +342,21 @@ void readBatchTransactionsMissingInnerTransaction() {
343
342
void noEventTransactions () {
344
343
var roundHeader = BlockItem .newBuilder ().setRoundHeader (RoundHeader .getDefaultInstance ());
345
344
var eventHeader = BlockItem .newBuilder ().setEventHeader (EventHeader .getDefaultInstance ());
345
+ // A standalone state changes block item, with consensus timestamp
346
+ var stateChanges = stateChanges ();
346
347
var block = Block .newBuilder ()
347
348
.addItems (blockHeader ())
348
349
.addItems (roundHeader )
349
350
.addItems (eventHeader )
351
+ .addItems (stateChanges )
350
352
.addItems (blockProof ())
351
353
.build ();
352
354
var streamFileData = StreamFileData .from (BlockFile .getBlockStreamFilename (0 ), gzip (block ));
355
+ long timestamp =
356
+ DomainUtils .timestampInNanosMax (stateChanges .getStateChanges ().getConsensusTimestamp ());
353
357
assertThat (reader .read (streamFileData ))
354
- .returns (TIMESTAMP * NANOS_PER_SECOND , BlockFile ::getConsensusEnd )
355
- .returns (TIMESTAMP * NANOS_PER_SECOND , BlockFile ::getConsensusStart )
358
+ .returns (timestamp , BlockFile ::getConsensusEnd )
359
+ .returns (timestamp , BlockFile ::getConsensusStart )
356
360
.returns (0L , BlockFile ::getCount )
357
361
.returns (List .of (), BlockFile ::getItems )
358
362
.returns (ProtoBlockFileReader .VERSION , BlockFile ::getVersion );
@@ -465,8 +469,7 @@ void thrownWhenTransactionBytesCorrupted() {
465
469
466
470
private BlockItem blockHeader () {
467
471
return BlockItem .newBuilder ()
468
- .setBlockHeader (BlockHeader .newBuilder ()
469
- .setFirstTransactionConsensusTime (Timestamp .newBuilder ().setSeconds (TIMESTAMP )))
472
+ .setBlockHeader (BlockHeader .newBuilder ().setBlockTimestamp (domainBuilder .protoTimestamp ()))
470
473
.build ();
471
474
}
472
475
@@ -536,6 +539,12 @@ private byte[] gzip(Block block) {
536
539
return TestUtils .gzip (block .toByteArray ());
537
540
}
538
541
542
+ private BlockItem stateChanges () {
543
+ return BlockItem .newBuilder ()
544
+ .setStateChanges (StateChanges .newBuilder ().setConsensusTimestamp (domainBuilder .protoTimestamp ()))
545
+ .build ();
546
+ }
547
+
539
548
@ SneakyThrows
540
549
private static Stream <Arguments > readTestArgumentsProvider () {
541
550
return TEST_BLOCK_FILES .stream ().map (blockFile -> {
0 commit comments