diff --git a/src/events/events.cairo b/src/events/events.cairo index fa4e991..178074d 100644 --- a/src/events/events.cairo +++ b/src/events/events.cairo @@ -210,9 +210,13 @@ pub mod Events { }; event_details } + fn event_owner(self: @ContractState, event_id: u256) -> ContractAddress { - get_caller_address() + let event_owners = self.event_owners.read(event_id); + + event_owners } + fn attendee_event_details(self: @ContractState, event_id: u256) -> EventRegistration { let event_attendance_details = EventRegistration { attendee_address: get_caller_address(), diff --git a/tests/test_contract.cairo b/tests/test_contract.cairo index 91d5a1d..6418b86 100644 --- a/tests/test_contract.cairo +++ b/tests/test_contract.cairo @@ -186,3 +186,21 @@ fn test_event_emission() { stop_cheat_caller_address(event_contract_address); } + +#[test] +#[available_gas(2000000)] +fn test_event_owner() { + let event_contract_address = __setup__(); + let event_dispatcher = IEventDispatcher { contract_address: event_contract_address }; + + let user_address: ContractAddress = USER_ONE.try_into().unwrap(); + + start_cheat_caller_address(event_contract_address, user_address); + + let event_id = event_dispatcher.add_event("bitcoin dev meetup", "Dan Marna road"); + assert(event_id == 1, 'Event was not created'); + + let retrieved_owner = event_dispatcher.event_owner(1); + assert(retrieved_owner == user_address, 'Wrong owner returned'); + stop_cheat_caller_address(event_contract_address); +}