Skip to content

Commit ab0db5f

Browse files
committed
test(event): fix EventPluginLoader singleton pollution between tests
FilterQueryTest.testMatchFilter() sets filterQuery={fromBlock=100, toBlock=190} on the EventPluginLoader singleton with no cleanup. With forkEvery=100, tests sharing the same JVM inherit this stale state, causing matchFilter() to return false for block 1 and skipping processTrigger() entirely (0/293 instructions covered). Add @after teardown in FilterQueryTest to reset filterQuery to null, and add a defensive reset in BlockEventGetTest.@before as a guard against any other preceding test leaving dirty singleton state.
1 parent 12ab2c2 commit ab0db5f

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

framework/src/test/java/org/tron/common/logsfilter/FilterQueryTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.util.List;
1818
import java.util.Map;
1919
import lombok.extern.slf4j.Slf4j;
20+
import org.junit.After;
2021
import org.junit.Assert;
2122
import org.junit.Test;
2223
import org.tron.common.logsfilter.capsule.ContractEventTriggerCapsule;
@@ -28,6 +29,11 @@
2829
@Slf4j
2930
public class FilterQueryTest {
3031

32+
@After
33+
public void tearDown() {
34+
EventPluginLoader.getInstance().setFilterQuery(null);
35+
}
36+
3137
@Test
3238
public synchronized void testParseFilterQueryBlockNumber() {
3339
assertEquals(LATEST_BLOCK_NUM, parseToBlockNumber(EMPTY));

framework/src/test/java/org/tron/core/event/BlockEventGetTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public static void init() {
9090

9191
@Before
9292
public void before() throws IOException {
93+
EventPluginLoader.getInstance().setFilterQuery(null);
9394
Args.getInstance().setNodeListenPort(10000 + port.incrementAndGet());
9495

9596
dbManager = context.getBean(Manager.class);

0 commit comments

Comments
 (0)