Skip to content

Commit cd5159c

Browse files
committed
fix lint
1 parent 214bf5f commit cd5159c

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

framework/src/test/java/org/tron/common/utils/ByteArrayTest.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ public void testJsonHexToLong_ValidInputs() {
126126
assertEquals(255L, jsonHexToLong("0xFF"));
127127
assertEquals(0L, jsonHexToLong("0x0"));
128128
assertEquals(1L, jsonHexToLong("0x1"));
129-
129+
130130
// Test large values
131131
assertEquals(4294967295L, jsonHexToLong("0xFFFFFFFF"));
132132

133133
// Test maximum long value
134-
assertEquals(Long.MAX_VALUE, jsonHexToLong("0x7FFFFFFFFFFFFFFF"));
134+
assertEquals(Long.MAX_VALUE, jsonHexToLong("0x7FFFFFFFFFFFFFFF"));
135135
} catch (JsonRpcInvalidParamsException e) {
136136
fail("Exception should not have been thrown for valid hex strings: " + e.getMessage());
137137
}
@@ -141,18 +141,18 @@ public void testJsonHexToLong_ValidInputs() {
141141
public void testJsonHexToLong_InvalidInputs() {
142142
// Test null input
143143
assertThrows(JsonRpcInvalidParamsException.class, () -> jsonHexToLong(null));
144-
144+
145145
// Test missing 0x prefix
146146
assertThrows(JsonRpcInvalidParamsException.class, () -> jsonHexToLong("1A"));
147-
147+
148148
// Test too long input (DDoS protection)
149149
StringBuilder tooLongStr = new StringBuilder("0x");
150150
for (int i = 0; i < 20; i++) {
151151
tooLongStr.append("F");
152152
}
153153
String tooLongHex = tooLongStr.toString(); // 22 characters total, exceeds MAX_HEX_LONG_LENGTH
154154
assertThrows(JsonRpcInvalidParamsException.class, () -> jsonHexToLong(tooLongHex));
155-
155+
156156
// Test invalid hex characters
157157
assertThrows(NumberFormatException.class, () -> jsonHexToLong("0xGG"));
158158
}
@@ -165,10 +165,10 @@ public void testJsonHexToInt_ValidInputs() {
165165
assertEquals(255, jsonHexToInt("0xFF"));
166166
assertEquals(0, jsonHexToInt("0x0"));
167167
assertEquals(1, jsonHexToInt("0x1"));
168-
168+
169169
// Test maximum int value
170170
assertEquals(Integer.MAX_VALUE, jsonHexToInt("0x7FFFFFFF"));
171-
171+
172172
// Test large values
173173
assertEquals(65535, jsonHexToInt("0xFFFF"));
174174
} catch (Exception e) {
@@ -180,18 +180,18 @@ public void testJsonHexToInt_ValidInputs() {
180180
public void testJsonHexToInt_InvalidInputs() {
181181
// Test null input
182182
assertThrows(Exception.class, () -> jsonHexToInt(null));
183-
183+
184184
// Test missing 0x prefix
185185
assertThrows(Exception.class, () -> jsonHexToInt("1A"));
186-
186+
187187
// Test too long input (DDoS protection)
188188
StringBuilder tooLongStr = new StringBuilder("0x");
189189
for (int i = 0; i < 12; i++) {
190190
tooLongStr.append("F");
191191
}
192192
String tooLongHex = tooLongStr.toString(); // 14 characters total, exceeds MAX_HEX_INT_LENGTH
193193
assertThrows(Exception.class, () -> jsonHexToInt(tooLongHex));
194-
194+
195195
// Test invalid hex characters
196196
assertThrows(NumberFormatException.class, () -> jsonHexToInt("0xGG"));
197197
}
@@ -201,10 +201,10 @@ public void testJsonHexToLong_EdgeCases() {
201201
try {
202202
// Test minimum length valid input
203203
assertEquals(0L, jsonHexToLong("0x0"));
204-
204+
205205
// Test a long hex string that's within limits but doesn't overflow
206206
assertEquals(4095L, jsonHexToLong("0xFFF")); // 3 F's = 4095, safe value
207-
207+
208208
// Test length validation - this should pass length check
209209
assertEquals(1048575L, jsonHexToLong("0xFFFFF")); // 5 F's = 1048575, safe value
210210
} catch (JsonRpcInvalidParamsException e) {
@@ -217,10 +217,10 @@ public void testJsonHexToInt_EdgeCases() {
217217
try {
218218
// Test minimum length valid input
219219
assertEquals(0, jsonHexToInt("0x0"));
220-
220+
221221
// Test a hex string that's within limits but doesn't overflow
222222
assertEquals(4095, jsonHexToInt("0xFFF")); // 3 F's = 4095, safe value
223-
223+
224224
// Test length validation - this should pass length check
225225
assertEquals(1048575, jsonHexToInt("0xFFFFF")); // 5 F's = 1048575, safe value
226226
} catch (Exception e) {
@@ -232,13 +232,15 @@ public void testJsonHexToInt_EdgeCases() {
232232
public void testJsonHexToLong_OverflowHandling() {
233233
// Test that Long.parseLong properly handles overflow by throwing NumberFormatException
234234
// This tests values that pass length validation but cause overflow
235-
assertThrows(NumberFormatException.class, () -> jsonHexToLong("0x8000000000000000")); // Long.MAX_VALUE + 1
235+
assertThrows(NumberFormatException.class,
236+
() -> jsonHexToLong("0x8000000000000000")); // Long.MAX_VALUE + 1
236237
}
237238

238239
@Test
239240
public void testJsonHexToInt_OverflowHandling() {
240241
// Test that Integer.parseInt properly handles overflow by throwing NumberFormatException
241242
// This tests values that pass length validation but cause overflow
242-
assertThrows(NumberFormatException.class, () -> jsonHexToInt("0x80000000")); // Integer.MAX_VALUE + 1
243+
assertThrows(NumberFormatException.class,
244+
() -> jsonHexToInt("0x80000000")); // Integer.MAX_VALUE + 1
243245
}
244246
}

0 commit comments

Comments
 (0)