Skip to content

Commit 59ea298

Browse files
committed
update testcase
1 parent 84775df commit 59ea298

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

common/src/test/java/org/tron/core/config/args/VmConfigTest.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import static org.junit.Assert.assertEquals;
44
import static org.junit.Assert.assertFalse;
5+
import static org.junit.Assert.assertThrows;
56
import static org.junit.Assert.assertTrue;
67

78
import com.typesafe.config.Config;
89
import com.typesafe.config.ConfigFactory;
10+
import org.junit.Assert;
911
import org.junit.Test;
1012

1113
public class VmConfigTest {
@@ -99,7 +101,7 @@ public void testEstimateEnergyMaxRetryBoundaryValues() {
99101

100102
@Test
101103
public void testConstantCallTimeoutDefaultWhenAbsent() {
102-
// No path in the config, no entry in reference.conf -> default 0L kept,
104+
// reference.conf default is 0; absence of a user override keeps that default;
103105
// no validation triggered.
104106
VmConfig vm = VmConfig.fromConfig(withRef());
105107
assertEquals(0L, vm.getConstantCallTimeoutMs());
@@ -121,24 +123,18 @@ public void testConstantCallTimeoutAcceptsAnyPositiveValue() {
121123

122124
@Test
123125
public void testConstantCallTimeoutNegativeRejected() {
124-
try {
126+
IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> {
125127
VmConfig.fromConfig(withRef("vm { constantCallTimeoutMs = -1 }"));
126-
org.junit.Assert.fail("expected IllegalArgumentException for negative ms");
127-
} catch (IllegalArgumentException ex) {
128-
org.junit.Assert.assertTrue(ex.getMessage(),
129-
ex.getMessage().contains("constantCallTimeoutMs"));
130-
}
128+
});
129+
Assert.assertTrue(thrown.getMessage().contains("constantCallTimeoutMs"));
131130
}
132131

133132
@Test
134133
public void testConstantCallTimeoutOverflowRejected() {
135134
long value = Long.MAX_VALUE / 1000 + 1L;
136-
try {
135+
IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> {
137136
VmConfig.fromConfig(withRef("vm { constantCallTimeoutMs = " + value + " }"));
138-
org.junit.Assert.fail("expected IllegalArgumentException for overflowing ms");
139-
} catch (IllegalArgumentException ex) {
140-
org.junit.Assert.assertTrue(ex.getMessage(),
141-
ex.getMessage().contains("deadline conversion"));
142-
}
137+
});
138+
Assert.assertTrue(thrown.getMessage().contains("deadline conversion"));
143139
}
144140
}

0 commit comments

Comments
 (0)