arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2407.04250cs.SE
收藏

智能合约的有效定向测试

Effective Targeted Testing of Smart Contracts

Mahdi Fooladgar, Fathiyeh Faghih

AI总结:

本文提出智能合约定向测试框架Griffin,采用定向符号执行和增强版控制流图CFG+生成测试数据,用于杀死变异体、验证告警和生成反例,实验证明其能在合理时间内有效到达目标行。

摘要:

智能合约是部署在区块链网络上并由矿工运行的自主且不可变的代码片段。它们于2014年由以太坊首次引入,此后被用于各种应用,如证券型代币、投票、赌博、非同质化代币、自主身份、盘点、去中心化金融、去中心化交易所和原子交换。由于智能合约是不可变的,其缺陷无法修复,这可能导致重大的经济损失。虽然许多研究人员专注于测试智能合约,但我们最近的工作突显了测试充分性与测试数据生成之间的差距,尽管这两个领域都有大量努力。我们的框架Griffin通过采用定向符号执行技术生成测试数据来解决这一不足。该工具可用于多种应用,例如杀死变异测试中存活的变异体、验证静态分析告警、为安全条件创建反例以及到达手动选择的代码行。本文讨论了智能合约在定向符号执行中与传统软件的不同之处,以及这些差异如何影响工具结构,从而使我们提出了一种针对Solidity智能合约的增强版控制流图,称为CFG+。我们还讨论了Griffin如何利用自定义启发式来探索程序空间,并在考虑安全条件的同时,在合理的执行时间内找到到达目标行的测试数据。我们基于现实世界缺陷和相关工具的测试套件,对大量智能合约、目标行和安全条件进行了实验。评估结果表明,Griffin能够在合理的时间范围内有效识别所需的测试数据。

英文摘要:

Smart contracts are autonomous and immutable pieces of code that are deployed on blockchain networks and run by miners. They were first introduced by Ethereum in 2014 and have since been used for various applications such as security tokens, voting, gambling, non-fungible tokens, self-sovereign identities, stock taking, decentralized finances, decentralized exchanges, and atomic swaps. Since smart contracts are immutable, their bugs cannot be fixed, which may lead to significant monetary losses. While many researchers have focused on testing smart contracts, our recent work has highlighted a gap between test adequacy and test data generation, despite numerous efforts in both fields. Our framework, Griffin, tackles this deficiency by employing a targeted symbolic execution technique for generating test data. This tool can be used in diverse applications, such as killing the survived mutants in mutation testing, validating static analysis alarms, creating counter-examples for safety conditions, and reaching manually selected lines of code. This paper discusses how smart contracts differ from legacy software in targeted symbolic execution and how these differences can affect the tool structure, leading us to propose an enhanced version of the control-flow graph for Solidity smart contracts called CFG+. We also discuss how Griffin can utilize custom heuristics to explore the program space and find the test data that reaches a target line while considering a safety condition in a reasonable execution time. We conducted experiments involving an extensive set of smart contracts, target lines, and safety conditions based on real-world faults and test suites from related tools. The results of our evaluation demonstrate that Griffin can effectively identify the required test data within a reasonable timeframe.

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

↑