MT4SC: A User-Behavior-Sequence-Aware Metamorphic Testing Approach for Smart Contracts
Abstract
Smart contracts are essential applications for blockchains, which have been used in a wide variety of fields and are handling large amounts of valuable assets. Once deployed on the blockchain network, smart contracts cannot be altered, thus making the pre-deployment testing of them extremely critical. Nevertheless, the features of smart contracts, especially their transaction-driven nature, pose huge challenges to testing. In particular, since their inputs are not static data but dynamic sequences of user behavior, it is very difficult to obtain a feasible oracle for testing, which refers to the systematic mechanism to verify the correctness of test results given any test input. This is the notorious oracle problem in the context of software testing, for which the metamorphic testing technique has been widely recognized as a simple yet effective solution. In this paper, we develop a comprehensive framework, namely MT4SC, for implementing metamorphic testing on smart contracts. Specifically, we propose a systematic way to construct metamorphic relations, the core component of metamorphic testing, based on the user behavior sequences. A series of experiments have been conducted to evaluate the performance of MT4SC on eight different smart contract scenarios. The experimental results demonstrate MT4SC’s high effectiveness in detecting potential faults in smart contracts, even without the need for test oracles. This study bolsters the research on the testing of smart contracts, thereby improving their quality and ultimately advancing the reliability of blockchains.
Community
0 commentsNo discussion yet
Be the first to share a question or observation.