Skip to content

Commit

Permalink
fix: fixed delegate not subsribing to the channel automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNilesh committed Nov 19, 2024
1 parent e5ff018 commit e1827e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}

Expand Down
4 changes: 4 additions & 0 deletions tests/test_channel_delegate.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit e1827e4

Please sign in to comment.