Skip to content

Commit 6ae74cd

Browse files
committed
Refactored SolidiFIReentrancyTruth test to use ExecutorService directly.
1 parent 8fd9f89 commit 6ae74cd

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/test/java/it/unipr/analysis/cron/checker/SolidiFIReentrancyTruth.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import it.unipr.checker.JumpSolver;
55
import it.unipr.checker.ReentrancyChecker;
66
import it.unipr.frontend.EVMFrontend;
7-
import it.unipr.utils.EVMLiSAExecutor;
87
import it.unipr.utils.MyCache;
98
import it.unive.lisa.LiSA;
109
import it.unive.lisa.analysis.SimpleAbstractState;
@@ -34,10 +33,10 @@ public class SolidiFIReentrancyTruth {
3433
private ConcurrentMap<Integer, Integer> _solidifi = new ConcurrentHashMap<>();
3534

3635
@Test
37-
public void testSolidiFIReentrancyTruth() {
36+
public void testSolidiFIReentrancyTruth() throws InterruptedException {
3837
setSolidifiMap();
39-
List<Future<?>> futures = new ArrayList<>();
40-
EVMLiSAExecutor.setCoresAvailable(Runtime.getRuntime().availableProcessors() - 1);
38+
int cores = Runtime.getRuntime().availableProcessors() - 1;
39+
ExecutorService executor = Executors.newFixedThreadPool(cores > 0 ? cores : 1);
4140

4241
Path solidifiBuggyBytecodesDirPath = Paths
4342
.get("evm-testcases", "ground-truth", "solidifi", "reentrancy-truth", "bytecode");
@@ -46,7 +45,7 @@ public void testSolidiFIReentrancyTruth() {
4645

4746
// Run the benchmark on Buggy contracts
4847
for (String bytecodeFileName : bytecodes) {
49-
futures.add(EVMLiSAExecutor.submit(() -> {
48+
executor.submit(() -> {
5049
try {
5150
String bytecodeFullPath = solidifiBuggyBytecodesDirPath.resolve(bytecodeFileName).toString();
5251

@@ -83,7 +82,7 @@ public void testSolidiFIReentrancyTruth() {
8382
} catch (Exception e) {
8483
log.error("Error processing bytecode {}: {}", bytecodeFileName, e.getMessage(), e);
8584
}
86-
}));
85+
});
8786
}
8887

8988
Path solidifiVanillaBytecodesDirPath = Paths
@@ -93,7 +92,7 @@ public void testSolidiFIReentrancyTruth() {
9392

9493
// Run the benchmark on Vanilla contracts
9594
for (String bytecodeFileName : bytecodes) {
96-
futures.add(EVMLiSAExecutor.submit(() -> {
95+
executor.submit(() -> {
9796
try {
9897
String bytecodeFullPath = solidifiVanillaBytecodesDirPath.resolve(bytecodeFileName).toString();
9998

@@ -130,15 +129,15 @@ public void testSolidiFIReentrancyTruth() {
130129
} catch (Exception e) {
131130
log.error("Error processing bytecode {}: {}", bytecodeFileName, e.getMessage(), e);
132131
}
133-
}));
132+
});
134133
}
135134

136-
log.debug("{} contracts submitted to Thread pool with {} workers.", futures.size(),
137-
EVMLiSAExecutor.getCoresAvailable());
138-
139-
// Wait for completion and shutdown the executor
140-
EVMLiSAExecutor.awaitCompletionFutures(futures, 1, TimeUnit.HOURS);
141-
EVMLiSAExecutor.shutdown();
135+
// Shutdown the executor and wait for completion
136+
executor.shutdown();
137+
if (!executor.awaitTermination(1, TimeUnit.HOURS)) {
138+
log.error("Timeout reached while waiting for thread pool to terminate.");
139+
executor.shutdownNow();
140+
}
142141

143142
log.info("Results buggy: {}", _resultsBuggy);
144143
log.info("Results vanilla: {}", _resultsVanilla);

0 commit comments

Comments
 (0)