beekeeper
beekeeper copied to clipboard
Add Pause/Unpause Commands for Staking Contract Testing
Add Pause/Unpause Commands for Staking Contract Testing
Problem
Currently, testing stake withdrawal functionality in beekeeper requires manual intervention to pause/unpause the staking contract. The withdrawal behavior is designed as a security feature where withdrawals are only allowed when the contract is paused, but this makes automated testing difficult.
Current Behavior
stake withdrawfails with "contract is not paused" error during normal operation- This is expected security behavior - withdrawals are only allowed when the staking contract is paused
- Manual pause/unpause requires direct contract interaction or admin access
Proposed Solution
Add two new commands to the stake subcommand:
# Pause the staking contract to allow withdrawals
./dist/beekeeper stake pause --cluster-name <cluster>
# Unpause the staking contract to resume normal operations
./dist/beekeeper stake unpause --cluster-name <cluster>
Use Cases
- Testing withdrawal functionality - Pause contract, test withdrawals, then unpause
- Integration testing - Automated testing of complete stake lifecycle
- Development/debugging - Easier testing of stake-related features
- Emergency scenarios - Quick contract pause/unpause for testing
Implementation Details
- Commands should use the same contract configuration as the existing stake check
- Include proper error handling and transaction confirmation
- Add status checks to prevent redundant operations
- Require admin privileges (same as current stake check)
Example Usage
# Test complete withdrawal flow
./dist/beekeeper stake pause --cluster-name local-dns
./dist/beekeeper stake withdraw --cluster-name local-dns # Now succeeds
./dist/beekeeper stake unpause --cluster-name local-dns
Security Considerations
- Commands require admin/owner privileges
- Should include clear warnings about contract state changes
- Consider adding confirmation prompts for production use