diff --git a/src/timelock.cairo b/src/timelock.cairo index 0bbcbfd..1e6ab51 100644 --- a/src/timelock.cairo +++ b/src/timelock.cairo @@ -144,6 +144,7 @@ pub mod Timelock { let id = to_calls_id(calls); let execution_state = self.execution_state.read(id); + assert(execution_state.executed.is_zero(), 'ALREADY_EXECUTED'); assert(execution_state.canceled.is_zero(), 'HAS_BEEN_CANCELED'); assert(execution_state.created.is_zero(), 'ALREADY_QUEUED'); @@ -164,6 +165,7 @@ pub mod Timelock { let execution_state = self.execution_state.read(id); assert(execution_state.created.is_non_zero(), 'DOES_NOT_EXIST'); assert(execution_state.executed.is_zero(), 'ALREADY_EXECUTED'); + assert(execution_state.canceled.is_zero(), 'ALREADY_CANCELED'); self .execution_state diff --git a/src/timelock_test.cairo b/src/timelock_test.cairo index e34876b..a4b32c7 100644 --- a/src/timelock_test.cairo +++ b/src/timelock_test.cairo @@ -92,6 +92,23 @@ fn test_queue_cancel() { timelock.execute(single_call(transfer_call(token, recipient, 500_u256))); } +#[test] +#[should_panic(expected: ('ALREADY_CANCELED', 'ENTRYPOINT_FAILED'))] +fn test_queue_cancel_twice() { + set_block_timestamp(1); + let timelock = deploy(get_contract_address(), 86400, 3600); + + let token = deploy_token(get_contract_address(), 12345); + token.transfer(timelock.contract_address, 12345); + + let recipient = contract_address_const::<12345>(); + + let id = timelock.queue(single_call(transfer_call(token, recipient, 500_u256))); + + timelock.cancel(id); + timelock.cancel(id); +} + #[test] #[should_panic(expected: ('ALREADY_EXECUTED', 'ENTRYPOINT_FAILED'))] fn test_queue_execute_twice() {