Overview
Testing is critical for ensuring the security and reliability of the Salud Health smart contract. This guide covers Leo contract testing, integration testing, and end-to-end testing.Leo Contract Tests
Running Tests
Execute the Leo test suite:Test Coverage
The contract includes 17 comprehensive tests:Record Creation
Valid/invalid record types, data encoding, record ID generation
Access Management
Grant access, verify permissions, expiration, revocation
Security
Fake tokens, wrong doctor, unauthorized access, self-grant prevention
Edge Cases
Duration bounds, uniqueness, determinism, access info retrieval
Integration Testing
Test Environment Setup
Set up a test environment for integration testing:Test Record Creation
Test Access Granting
Test Access Verification
Encryption Testing
Test Data Encoding
Test Encryption/Decryption
End-to-End Testing
Test Patient Flow
Test the complete patient journey:Test Doctor Flow
Performance Testing
Transaction Speed
Measure transaction execution time:QR Code Generation
Security Testing
Test Authorization
Test Data Integrity
Test Checklist
Before deploying to production:Functional Tests
Functional Tests
- Patient can create medical record
- QR code generates successfully
- Doctor can scan and verify access
- Access expires correctly
- Revocation works immediately
- Invalid tokens are rejected
Performance Tests
Performance Tests
- Record creation under 30 seconds
- QR generation under 5 seconds
- Access verification under 10 seconds
- No memory leaks
- Handles 100+ records efficiently
Security Tests
Security Tests
- Unauthorized access prevented
- Data integrity verified
- Private keys never exposed
- No XSS vulnerabilities
- CSRF protection enabled
Cross-Platform Tests
Cross-Platform Tests
- Works on iPhone Safari
- Works on Android Chrome
- Works on desktop browsers
- QR scanner functions on mobile
- Wallet connection works
Continuous Integration
Set up automated testing in CI/CD:Next Steps
Architecture
Understand the contract architecture
Deployment
Deploy your tested contract to mainnet