PlatON Tech-Column|Automated Testing of Smart Contracts with PlatON (II)
Recall that in the last issue we explained the introduction of automation testing related to PlatON, this time we will explain what testing work is done in PlatON for smart contracts. First of all, we need to understand what a smart contract is, essentially, a smart contract is a piece of program that automates the processing of traditional contracts in the form of computer instructions. In simple terms, a smart contract is a piece of code that triggers the execution of a transaction between two parties on a blockchain asset. So here are a few questions to illustrate PlatON’s smart contract testing. This is the second part of the article.
Smart Contracts Automation Framework
When we chose to carry out smart contract test automation, we took into account the ease of subsequent test developers in assembling use cases and subsequent integration of more modules, we chose a more widely used JUnit test framework as the basis for extensions, the framework can also be integrated with most java IDEs and tools, and there are also many third-party extensions and enhancement packages supported for developers to extend later.
The PlatON smart contract testing framework was initially designed to meet the following aspects.
Support for source code compilation — As the contract needs to be compiled and deployed before it can be invoked during testing, in order to simplify the tedious process of compiling a batch of test contracts and facilitate testers to manage and update the test contract code, we need to integrate the contract compilation process into our framework’s internal implementation.
Support for data reuse — PlatON smart contracts are tested against the adaptability of the chain itself. In this validation process, different solidity versions of features and compiler versions are adapted, where the same case is repeated for each version to ensure that PlatON functionality does not differ between versions.
Introduction to framework modules
The framework is supported by maven calls to the contract compiler solc to compile the source code of the test contract to generate the corresponding .abi and bin files.
PlatON SDK, provides the ability to freely assemble and send transactions, and when we need to construct special transactions, we will dive directly into the SDK layer and then construct them.
Command line tool for platon-sdk that provides wallet management, generates Solidity contracts corresponding to the java skeleton, generates WASM contracts corresponding to the java skeleton.
A data-driven approach to managing test cases based on the JUnit test framework specification, and then generating test execution cases through the corresponding modules.
Store test data and test contracts and compiler versions, test cases are managed in a data-driven way and then executed by assembling the set of test cases.
Smart contract testing integration into Jenkins for CI/CD implementation
In order to get into testing earlier in the process, find problems earlier, and quickly complete feature regressions during version iterations, and put more effort into test development for the current version, PlatON introduced CI/CD to bridge the smart contract framework and automated deployment, enabling the task of automatically completing version regressions after version lift testing.
(To be continued)