Optimizing Smart Contract Testing via Neural-MCTS Test Prioritization
摘要
Smart contracts, as self-executing programs deployed on blockchain platforms, demand a high degree of reliability due to their immutable nature. Ensuring their correctness before deployment is crucial, as subsequent modifications are costly or impossible. By introducing artificial faults into contracts’ code and measuring the ability of tests to detect them, mutation testing offers a rigorous approach to assessing the quality of test suites. However, the large number of mutants and exhaustive test executions required make mutation testing a resource-intensive operation. In this paper, we introduce ASCENT, a novel test prioritization technique designed to reduce the computational cost of mutation testing in Solidity-based decentralized applications. Unlike traditional methods that rely on prior domain knowledge or static heuristics, often yielding inconsistent performance across different Systems Under Test (SUTs), ASCENT utilizes a Neural Monte Carlo Tree Search (Neural-MCTS) algorithm to dynamically learn and adapt test execution strategies in real-time. By mapping test methods to MCTS states and using the number of tests required to kill a mutant as a reward signal, ASCENT incrementally refines a policy that prioritizes the most impactful tests early in the process. Our evaluation on five open-source Solidity projects, tested through the HardHat framework, shows that ASCENT consistently reduces the number of executed tests needed for effective mutation detection. Additionally, it achieves this without requiring prior knowledge of the SUT and maintains stable performance across projects of varying sizes and complexity.