Writing Your Own Tests
Adding a Compilation Test
- Create a new Solidity file in
examples/orexamples/new/. - The E2E test suite automatically picks up files in these directories.
- Run
cargo test --test e2e_compilation_teststo verify.
Adding a Smoke Test
- Create a new script in
examples/following the pattern of existing scripts. - The script should:
- Create a temporary directory and clean up on exit
- Resolve
neo-solcandneoxpbinaries - Write a test contract inline
- Compile, deploy, invoke, and validate
- Add a Make target in the
Makefile. - Add the target to
test-deploy-smoke-fulldependencies.
Adding a Unit Test
Add #[test] functions in the relevant module or create a new test file in tests/:
rust
#[test]
fn test_my_feature() {
let source = r#"
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract Test {
function foo() public pure returns (uint256) {
return 42;
}
}
"#;
// Use the compiler API to compile and validate
// ...
}