arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.09955cs.SE
收藏

面向智能合约验证的蜕变测试:基于以太坊的众筹合约案例研究

Metamorphic Testing for Smart Contract Validation:A Case Study of Ethereum-Based Crowdfunding Contracts

Irving Jared Villanueva, Madhusudan Srinivasan, Faqeer Ur Rehman

AI总结:

针对智能合约测试中的预言机难题,本研究将蜕变测试应用于以太坊众筹智能合约验证,设计专属蜕变关系并生成用例,经Vertigo工具突变测试验证其可有效检测合约故障,保障区块链智能合约的可靠性与质量。

摘要:

区块链智能合约在金融、医疗、供应链等多个领域的协议自动化与安全保障中发挥着关键作用。尽管应用至关重要,但合约测试的受重视程度往往不及开发工作,而智能合约部署后具有不可篡改性,这会带来重大风险。智能合约测试的一大核心挑战是预言机问题,即确切的预期输出并未明确定义,使得系统性测试工作变得复杂。\n蜕变测试(Metamorphic Testing, MT)通过蜕变关系(Metamorphic Relations, MRs)验证智能合约,以此解决预言机问题。MRs定义了输出应如何随特定的输入修改而变化,以此判定测试是否通过。本研究将MT应用于测试一款基于以太坊的众筹智能合约,聚焦状态转换、捐赠追踪等核心功能。\n我们确定了一组适配智能合约测试的MRs,并为这些MRs生成了测试用例。为评估该方法的有效性,我们使用Vertigo突变测试工具生成了该智能合约的故障版本。实验结果显示,我们的MRs检测出了所生成全部突变体的25.65%,其中效果最佳的MRs突变杀灭率达到89%。这些结果凸显了MT在保障区块链智能合约可靠性与质量方面的效用。

英文摘要:

Blockchain smart contracts play a crucial role in automating and securing agreements in diverse domains such as finance, healthcare, and supply chains. Despite their critical applications, testing these contracts often receives less attention than their development, leaving significant risks due to the immutability of smart contracts post-deployment. A key challenge in the testing of smart contracts is the oracle problem, where the exact expected outcomes are not well defined, complicating systematic testing efforts. Metamorphic Testing (MT) addresses the oracle problem by using Metamorphic Relations (MRs) to validate smart contracts. MRs define how output should change relative to specific input modifications, determining whether the tests pass or fail. In this work, we apply MT to test an Ethereum-based crowdfunding smart contract, focusing on core functionalities such as state transitions and donation tracking. We identify a set of MRs tailored for smart contract testing and generate test cases for these MRs. To assess the effectiveness of this approach, we use the Vertigo mutation testing tool to create faulty versions of the smart contract. The experimental results show that our MRs detected 25.65% of the total mutants generated, with the most effective MRs achieving a mutant-killing rate of 89%. These results highlight the utility of MT to ensure the reliability and quality of blockchain-based smart contracts.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑