Skip to content

Commit 8b7901f

Browse files
committed
test(vm): cover constantCallTimeoutMs explicit-configure validation
1 parent 3c26b26 commit 8b7901f

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,55 @@ public void testEstimateEnergyMaxRetryBoundaryValues() {
8888
assertEquals(3, VmConfig.fromConfig(
8989
withRef("vm { estimateEnergyMaxRetry = 3 }")).getEstimateEnergyMaxRetry());
9090
}
91+
92+
// ===========================================================================
93+
// Constant-call timeout (issue #6681). The validation rule: any positive
94+
// value is accepted, but zero/negative is rejected ONLY when the operator
95+
// explicitly set the property in their config. Absence keeps the in-Java
96+
// default (0L = "share the block-processing deadline").
97+
// ===========================================================================
98+
99+
@Test
100+
public void testConstantCallTimeoutDefaultWhenAbsent() {
101+
// No path in the config, no entry in reference.conf -> default 0L kept,
102+
// no validation triggered.
103+
VmConfig vm = VmConfig.fromConfig(withRef());
104+
assertEquals(0L, vm.getConstantCallTimeoutMs());
105+
}
106+
107+
@Test
108+
public void testConstantCallTimeoutAcceptsAnyPositiveValue() {
109+
assertEquals(1L, VmConfig.fromConfig(
110+
withRef("vm { constantCallTimeoutMs = 1 }")).getConstantCallTimeoutMs());
111+
assertEquals(50L, VmConfig.fromConfig(
112+
withRef("vm { constantCallTimeoutMs = 50 }")).getConstantCallTimeoutMs());
113+
assertEquals(500L, VmConfig.fromConfig(
114+
withRef("vm { constantCallTimeoutMs = 500 }")).getConstantCallTimeoutMs());
115+
assertEquals(5_000L, VmConfig.fromConfig(
116+
withRef("vm { constantCallTimeoutMs = 5000 }")).getConstantCallTimeoutMs());
117+
}
118+
119+
@Test
120+
public void testConstantCallTimeoutZeroRejectedWhenExplicitlyConfigured() {
121+
// Operator wrote `= 0` in config -> treated as a misconfiguration even
122+
// though it equals the in-Java default. Forces an explicit positive value.
123+
try {
124+
VmConfig.fromConfig(withRef("vm { constantCallTimeoutMs = 0 }"));
125+
org.junit.Assert.fail("expected IllegalArgumentException for explicit 0");
126+
} catch (IllegalArgumentException ex) {
127+
org.junit.Assert.assertTrue(ex.getMessage(),
128+
ex.getMessage().contains("constantCallTimeoutMs"));
129+
}
130+
}
131+
132+
@Test
133+
public void testConstantCallTimeoutNegativeRejected() {
134+
try {
135+
VmConfig.fromConfig(withRef("vm { constantCallTimeoutMs = -1 }"));
136+
org.junit.Assert.fail("expected IllegalArgumentException for negative ms");
137+
} catch (IllegalArgumentException ex) {
138+
org.junit.Assert.assertTrue(ex.getMessage(),
139+
ex.getMessage().contains("constantCallTimeoutMs"));
140+
}
141+
}
91142
}

0 commit comments

Comments
 (0)