Skip to content

Commit 4433c52

Browse files
committed
fix(test): define constant for repeated string literal
Replace duplicated miner string literal with MINER_LABEL constant to fix SonarQube code smell. Relates tronprotocol#6624
1 parent 39dd708 commit 4433c52

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

framework/src/test/java/org/tron/core/metrics/prometheus/PrometheusApiServiceTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040

4141
@Slf4j(topic = "metric")
4242
public class PrometheusApiServiceTest extends BaseTest {
43+
44+
private static final String MINER_LABEL = "miner";
45+
4346
static LocalDateTime localDateTime = LocalDateTime.now();
4447
@Resource
4548
private DposSlot dposSlot;
@@ -87,7 +90,7 @@ protected void check(byte[] address, Map<ByteString, String> witnessAndAccount)
8790
// Query histogram bucket le="0.0" for empty blocks
8891
Double emptyBlock = CollectorRegistry.defaultRegistry.getSampleValue(
8992
"tron:block_transaction_count_bucket",
90-
new String[] {"miner", "le"}, new String[] {minerBase58, "0.0"});
93+
new String[] {MINER_LABEL, "le"}, new String[] {minerBase58, "0.0"});
9194

9295
Assert.assertNotNull("Empty block bucket should exist for miner: " + minerBase58, emptyBlock);
9396
Assert.assertEquals("Should have 1 empty block", 1, emptyBlock.intValue());
@@ -125,7 +128,7 @@ protected void check(byte[] address, Map<ByteString, String> witnessAndAccount)
125128
// Collect empty blocks count from histogram bucket
126129
Double witnessEmptyBlock = CollectorRegistry.defaultRegistry.getSampleValue(
127130
"tron:block_transaction_count_bucket",
128-
new String[] {"miner", "le"}, new String[] {witnessBase58, "0.0"});
131+
new String[] {MINER_LABEL, "le"}, new String[] {witnessBase58, "0.0"});
129132
Assert.assertNotNull("Empty block bucket should exist for witness: " + witnessBase58,
130133
witnessEmptyBlock);
131134
totalNewWitnessEmptyBlocks += witnessEmptyBlock;

0 commit comments

Comments
 (0)