All new functionality must include corresponding tests that verify both success and failure scenarios. When adding new functions or modifying existing behavior, write tests that cover the main functionality as well as edge cases and error conditions.
All new functionality must include corresponding tests that verify both success and failure scenarios. When adding new functions or modifying existing behavior, write tests that cover the main functionality as well as edge cases and error conditions.
Key requirements:
execute_burn
function that “needs to be tested to ensure it works correctly”)Example of comprehensive test coverage:
#[test]
fn execute_burn_works() {
// Test successful burn operation
let result = execute_burn(deps, env, info, amount);
assert!(result.is_ok());
}
#[test]
fn execute_burn_fails_with_invalid_amount() {
// Test edge case with invalid input
let result = execute_burn(deps, env, info, Uint128::zero());
assert!(result.is_err());
}
#[test]
fn validate_sync_committee_bits_length() {
// Test vector length validation
let mut update = valid_update.clone();
update.sync_aggregate.sync_committee_bits.clear();
assert!(validate_update(&update).is_err());
}
This practice prevents issues from reaching production and ensures code reliability through thorough validation of all code paths.
Enter the URL of a public GitHub repository