# Pattern-Based Test Suite Reduction Method for Smart Contracts
## 1 Introduction  
Testing helps verify that the software is working properly and is one of the key disciplines in the software development process. A test case specifies input data, execution conditions, a testing procedure, and anticipated results for test execution to achieve a specific software testing goal [1]. Preparing tests, conducting them, and maintaining the test suite usually require many activities and constitute a significant part of the project budget. In the context of smart contracts, a test suite is a collection of test cases that verify the operation of a smart contract containing a specific set of verification rules. Moreover, the iterative nature of software development requires the use of regression testing where the same test cases are executed repeatedly. Test suite minimization has been an important research topic for many years. This technique is often called test suite reduction or test case reduction. [PERSON] et al. [2] revealed that well-established approaches to test suite reduction use heuristics, genetic algorithms, and integer linear programming. Recently, [PERSON] et al. [3] reviewed works published on test set reduction methods. They confirmed that greedy genetic algorithms are still often used. However, they indicated the use of two more methods: clustering and search. The aim of test suite reduction is the minimization of the test suite size. But the test suite must be representative. So, attention is paid to the quality of the reduced test set. The topic of the adequacy of test suite reduction methods was extensively discussed by [PERSON] et al. [4]. However, minimizing a test suite must not reflect on its quality. Therefore, the test suite is also subject to qualitative assessment. Recently, [PERSON] et al. [5] reviewed the literature on quality evaluation methods of test artifacts. They have identified nine test suite quality attributes: coverage, maintainability, portability, usability, reliability, fault detection, diversity, efficiency, and complexity. Current research underlines the importance of the simplicity or ease of obtaining a reduced set of tests. [PERSON] and [PERSON] [6] emphasized this in their work on removing redundant trace refusals from a complete test suite. They aimed to propose a method for obtaining a small but not necessarily minimal test suite in a simple manner. The goal of the method, proposed in this article, was to obtain a minimal test suite for a smart contract while ensuring full coverage of verification rules. It is crucial to know the mechanism for evaluating logical conditions in the expression that determines the possibility of executing transactions between blockchain network nodes. The method does not require knowledge of specific verification rules, only the mechanism of their processing. This mechanism is defined by the adopted smart contract design pattern. The contribution of the paper includes the following:  
* a detailed description of the smart contract test suite reduction method \(k+1\),
* analytical formulas for calculating the level of test case reduction accompanied by examples of such computations,
* method of constructing a test dataset that reuses test transactions among test cases,
* method of constructing test software using object-oriented and functional programming mechanisms,
* performing tests and analysis of the results obtained. The idea of the method has been presented by [PERSON] in communication [7]. The current research paper details the working mechanism of the smart contract test pattern. The benefits of using the pattern are illustrated using the example of a broader logical expression. Moreover, dedicated software was designed for testing smart contracts. This resulted from the need to obtain high-precision measurements of the execution time of a single test. The test software dynamically constructs the test suite employing logical conditions expressed by lambda expressions. Such a design approach eliminates the need to create classes for verification rules.