2525import org .tron .common .utils .ByteArray ;
2626import org .tron .common .utils .PublicMethod ;
2727import org .tron .common .utils .Sha256Hash ;
28+ import org .tron .common .utils .StringUtil ;
2829import org .tron .common .utils .Utils ;
2930import org .tron .consensus .dpos .DposSlot ;
3031import org .tron .core .ChainBaseManager ;
@@ -65,7 +66,7 @@ protected static void initParameter(CommonParameter parameter) {
6566 parameter .setMetricsPrometheusEnable (true );
6667 }
6768
68- protected void check () throws Exception {
69+ protected void check (byte [] address ) throws Exception {
6970 Double memoryBytes = CollectorRegistry .defaultRegistry .getSampleValue (
7071 "system_total_physical_memory_bytes" );
7172 Assert .assertNotNull (memoryBytes );
@@ -80,6 +81,17 @@ protected void check() throws Exception {
8081 new String [] {"sync" }, new String [] {"false" });
8182 Assert .assertNotNull (pushBlock );
8283 Assert .assertEquals (pushBlock .intValue (), blocks + 1 );
84+
85+ String minerBase58 = StringUtil .encode58Check (address );
86+ Double emptyBlock = CollectorRegistry .defaultRegistry .getSampleValue (
87+ "tron:block_empty_total" , new String [] {"miner" }, new String [] {minerBase58 });
88+
89+ Assert .assertNotNull (emptyBlock );
90+ // The initial address is in the active witness list along with 2 randomly generated witnesses,
91+ // so it produces blocks every 3 slots. Total empty blocks = 1 (first manual block) + blocks/3
92+ // (from the loop) + 1 if blocks%3 != 0 (partial round)
93+ Assert .assertEquals (emptyBlock .intValue (), 1 + blocks / 3 + (blocks % 3 != 0 ? 1 : 0 ));
94+
8395 Double errorLogs = CollectorRegistry .defaultRegistry .getSampleValue (
8496 "tron:error_info_total" , new String [] {"net" }, new String [] {MetricLabels .UNDEFINED });
8597 Assert .assertNull (errorLogs );
@@ -133,7 +145,7 @@ public void testMetric() throws Exception {
133145 for (int i = 0 ; i < blocks ; i ++) {
134146 generateBlock (witnessAndAccount );
135147 }
136- check ();
148+ check (address );
137149 }
138150
139151 private Map <ByteString , String > addTestWitnessAndAccount () {
0 commit comments