diff --git a/src/lib.cairo b/src/lib.cairo index ae40474..0b490cb 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -349,6 +349,7 @@ pub mod PushComm { fn add_delegate(ref self: ContractState, delegate: ContractAddress) { let channel = get_caller_address(); self.delegated_notification_senders.entry(channel).write(delegate, true); + self._subscribe(channel, delegate); self.emit(AddDelegate { channel: channel, delegate: delegate }); } diff --git a/tests/test_channel_delegate.cairo b/tests/test_channel_delegate.cairo index de60bbc..e847675 100644 --- a/tests/test_channel_delegate.cairo +++ b/tests/test_channel_delegate.cairo @@ -33,6 +33,10 @@ fn test_channel_delegate() { ] ); + // user should be subscribed to the channel + let is_user_subscribed = push_comm.is_user_subscribed(CHANNEL_ADDRESS, USER_1()); + assert(is_user_subscribed, 'Delegate should be subscribed'); + // Delegate can send the notification cheat_caller_address(contract_address, USER_1(), CheatSpan::TargetCalls(1)); let is_success = push_comm.send_notification(CHANNEL_ADDRESS, USER_1(), identity.clone());