Implement multisig timelock test#17
Conversation
Add a test for multisig timelock enforcement in transactions.
There was a problem hiding this comment.
Pull Request Overview
This PR implements a test case for multisig timelock enforcement, validating that transactions cannot be executed before the timelock period expires and can be successfully executed afterward.
Key Changes:
- Added
test_multisig_timelock_enforced()function to verify timelock behavior - Test proposes a transaction with a 0.001 hour (3.6 second) timelock, verifies execution is blocked before expiry, and succeeds after waiting
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assert False, "timelock should block execution" | ||
| except Exception as e: | ||
| assert "timelock" in str(e).lower() | ||
| time.sleep(4) |
There was a problem hiding this comment.
The hard-coded sleep duration of 4 seconds creates a magic number. Consider calculating this value based on the timelock_hours parameter (0.001 hours = 3.6 seconds) with a small buffer, e.g., time.sleep(0.001 * 3600 + 0.5), to make the relationship explicit and the test more maintainable.
| def test_multisig_timelock_enforced(): | ||
| s = {"vault": {"ETH":10,"USDC":0}, "spokes": {}, "pending": [], "keys": ["K1","K2","K3"]} | ||
| propose_tx(s, {"type":"fund_spoke","spoke":"PaymentScheduler","asset":"ETH","amount":5.0}, timelock_hours=0.001) |
There was a problem hiding this comment.
The timelock value of 0.001 hours is a magic number that's difficult to interpret. Consider defining it as a named constant like TIMELOCK_HOURS = 0.001 with a comment explaining it equals 3.6 seconds, improving test readability.
| def test_multisig_timelock_enforced(): | |
| s = {"vault": {"ETH":10,"USDC":0}, "spokes": {}, "pending": [], "keys": ["K1","K2","K3"]} | |
| propose_tx(s, {"type":"fund_spoke","spoke":"PaymentScheduler","asset":"ETH","amount":5.0}, timelock_hours=0.001) | |
| # Timelock duration for test: 0.001 hours = 3.6 seconds | |
| TIMELOCK_HOURS = 0.001 | |
| def test_multisig_timelock_enforced(): | |
| s = {"vault": {"ETH":10,"USDC":0}, "spokes": {}, "pending": [], "keys": ["K1","K2","K3"]} | |
| propose_tx(s, {"type":"fund_spoke","spoke":"PaymentScheduler","asset":"ETH","amount":5.0}, timelock_hours=TIMELOCK_HOURS) |
Add a test for multisig timelock enforcement in transactions.