[TEST]: expand test coverage for execute_edit_permission_transaction #149
Conversation
|
""" WalkthroughThe changes make the fields of the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (15)
|
|
@codebestia kindly review :) |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/tests/actions/test_member_permission_tx.cairo (1)
334-355: Consider removing or fixing the commented-out test.The commented-out transaction approval event test references a
date_approvedfield that may not exist on the transaction object. Either fix this test or remove it to keep the codebase clean.-// #[test] -// fn test_event_emitted_transaction_approved() { -// let mock_contract = deploy_mock_contract(); -// let caller = proposer(); -// let member = member_to_edit(); -// let new_permissions: u8 = 6; -// start_cheat_caller_address(mock_contract.contract_address, caller); -// mock_contract.add_member_pub(caller); -// mock_contract.add_member_pub(member); -// mock_contract.assign_proposer_permission_pub(caller); -// let tx_id = mock_contract.propose_edit_permission_transaction_pub(member, new_permissions); -// let mut spy = spy_events(); -// mock_contract.approve_transaction_pub(tx_id, caller); -// stop_cheat_caller_address(mock_contract.contract_address); -// let expected_event = spherre::tests::mocks::mock_account_data::Event::AccountDataEvent( -// spherre::account_data::Event::TransactionApproved { -// transaction_id: tx_id, -// date_approved: mock_contract.get_transaction_pub(tx_id).date_approved, -// } -// ); -// spy.assert_emitted(@array![(mock_contract.contract_address, expected_event)]); -// }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/account_data.cairo(1 hunks)src/tests/actions/test_member_permission_tx.cairo(2 hunks)
🔇 Additional comments (4)
src/account_data.cairo (1)
122-125: LGTM! Event field visibility change supports enhanced testing.Making the
TransactionExecutedevent struct fields publicly accessible is appropriate for enabling direct event field access in tests. This change aligns well with the expanded test coverage in the test file.src/tests/actions/test_member_permission_tx.cairo (3)
2-9: LGTM! Imports properly support event testing functionality.The added imports for event spying traits and event types are correctly structured and necessary for the new event verification tests.
230-331: Excellent edge case test coverage!These comprehensive edge case tests effectively validate all failure scenarios for
execute_edit_permission_transaction:
- Transaction existence validation
- Transaction type validation
- Permission requirements (executor)
- Member existence validation
- Permission mask validation
- Transaction approval status
The added voter permission assignments (lines 251, 270) are necessary fixes for proper test setup.
357-411: Excellent event emission test coverage!Both event emission tests are well-implemented:
test_event_emitted_transaction_executedproperly verifies theTransactionExecutedevent with correct transaction datatest_event_emitted_permission_edit_executedeffectively tests thePermissionEditExecutedeventThe tests follow good practices with proper setup, event spying, and assertion patterns. The voter permission fix on line 368 maintains consistency with other test improvements.
codebestia
left a comment
There was a problem hiding this comment.
LGTM!
Thank you for contribution @martinvibes
Description 📝
Expand & Refactor Permission Edit Transaction Tests
Summary:
Related Issues 🔗
closes #146
Changes Made 🚀
Screenshots/Screen-record (if applicable) 🖼
Checklist ✅
Additional Notes 🗒
Summary by CodeRabbit
Bug Fixes
Tests