Skip to main content
QUICK REVIEW

[Paper Review] ADF-GA: Data Flow Criterion Based Test Case Generation for Ethereum Smart Contracts

Pengcheng Zhang, Jianan Yu|arXiv (Cornell University)|Feb 29, 2020
Software Testing and Debugging TechniquesComputer Science25 references5 citations
TL;DR

This paper proposes ADF-GA, a genetic algorithm-based test case generation approach for Ethereum smart contracts that targets full data flow coverage using the all-uses criterion. By constructing a control flow graph, performing data flow analysis to identify definition-use pairs (dup), and employing a weighted fitness function to prioritize coverage of require statement-related dup, ADF-GA achieves higher test coverage with fewer iterations than baseline methods.

ABSTRACT

Testing is an important technique to improve the quality of Ethereum smart contract programs. However, current work on testing smart contract only focus on static problems of smart contract programs. A data flow oriented test case generation approach for dynamic testing of smart contract programs is still missing. To address this problem, this paper proposes a novel test case generation approach, called ADF-GA (All-uses Data Flow criterion based test case generation using Genetic Algorithm), for Solidity based Ethereum smart contract programs. ADF-GA aims to efficiently generate a valid set of test cases via three stages. First, the corresponding program control flow graph is constructed from the source codes. Second, the generated control flow graph is analyzed to obtain the variable information in the Solidity programs, locate the require statements, and also get the definition-use pairs to be tested. Finally, a genetic algorithm is used to generate test cases, in which an improved fitness function is proposed to calculate the definition-use pairs coverage of each test case with program instrumentation. Experimental studies are performed on several representative Solidity programs. The results show that ADF-GA can effectively generate test cases, achieve better coverage, and reduce the number of iterations in genetic algorithm.

Motivation & Objective

  • Address the lack of dynamic, data flow-oriented testing techniques for Ethereum smart contracts.
  • Overcome the limitation of existing approaches that focus only on static analysis or known vulnerability patterns.
  • Develop a test case generation method tailored to Solidity’s unique features, especially the require statement.
  • Improve test coverage by emphasizing definition-use pair (dup) coverage, particularly for require-related logic.
  • Optimize the genetic algorithm process to reduce convergence time and improve efficiency in test case generation.

Proposed method

  • Construct a control flow graph (CFG) from Solidity source code as an intermediate representation.
  • Perform data flow analysis to extract variable definitions, uses, and all definition-use pairs (dup), including those involving require statements.
  • Design a chromosome encoding scheme to represent test case inputs in the genetic algorithm framework.
  • Implement a custom fitness function that assigns higher weights to require-related dup to guide evolutionary selection.
  • Use genetic operations (selection, crossover, mutation) to evolve test cases toward maximizing dup coverage.
  • Instrument the smart contract code to measure actual dup coverage during test execution and feed back to the fitness function.

Experimental results

Research questions

  • RQ1Can a data flow criterion-based test case generation approach effectively improve coverage in Ethereum smart contract testing?
  • RQ2How does the inclusion of a weighted fitness function for require statement-related dup impact test case generation efficiency and coverage?
  • RQ3To what extent does ADF-GA outperform traditional genetic algorithm-based approaches (e.g., GA-C#) in terms of coverage and convergence speed?
  • RQ4What parameter settings (e.g., ε) in the fitness function yield optimal coverage and performance in ADF-GA?
  • RQ5Can ADF-GA generate test cases that achieve higher definition-use pair coverage than random testing or baseline GA approaches?

Key findings

  • ADF-GA achieved the highest coverage of both normal dup (N_dup) and require-related dup (R_dup) across all 11 evaluated smart contracts compared to random testing (RT) and GA-C#.
  • When ε was set to 0.45, ADF-GA achieved optimal coverage, with 11.36 and 7.45 iterations required to reach maximum R_dup and N_dup coverage, respectively.
  • ADF-GA required only 7.45 iterations to match the best coverage achieved by GA-C#, while GA-C# needed 11.36 iterations to reach its first maximum fitness value.
  • The number of total iterations in ADF-GA was slightly fewer than in GA-C# for most contracts, indicating improved convergence efficiency.
  • The improved fitness function in ADF-GA effectively prioritized require-related dup, resulting in better differentiation and selection of high-impact test cases.
  • In all tested contracts, ADF-GA achieved equal or higher N_dup and R_dup coverage than GA-C#, demonstrating the effectiveness of the weighted fitness function.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.