Prerequisites
- Completed Part 1: Minimal Smart Contract
- Basic understanding of Go and Rust testing frameworks
- Familiarity with Neutron’s custom modules
Setting Up the Test Environment
1. Install Test Dependencies
2. Basic Test Setup
Createchain_test.go
:
Testing Neutron Modules
1. Oracle Module Tests
2. Cron Module Tests
3. ICQ Module Tests
Testing IBC Functionality
1. IBC Transfer Tests
2. Contract IBC Tests
Multi-Chain Integration Tests
1. Set Up Multi-Chain Environment
Performance and Load Testing
1. Transaction Throughput Tests
2. Contract Gas Usage Tests
Running the Tests
1. Basic Test Execution
2. Parallel Test Execution
3. Continuous Integration
Create.github/workflows/integration-tests.yml
:
Best Practices
- Isolation: Each test should be independent and not rely on state from other tests
- Cleanup: Always clean up resources after tests complete
- Deterministic: Tests should produce consistent results across runs
- Fast Feedback: Keep test execution time reasonable
- Clear Assertions: Use descriptive error messages in assertions
Troubleshooting
Test Network Startup Fails
Test Network Startup Fails
Check port availability and ensure no other test networks are running:
IBC Tests Timeout
IBC Tests Timeout
Increase timeout values for IBC operations and ensure relayer is properly configured.
Flaky Tests
Flaky Tests
Add proper waiting mechanisms and avoid hard-coded delays. Use event-based waiting instead.