diff --git a/src/events/events.cairo b/src/events/events.cairo index 4318f1d..fdfad9d 100644 --- a/src/events/events.cairo +++ b/src/events/events.cairo @@ -3,7 +3,8 @@ pub mod Events { use core::num::traits::zero::Zero; use chainevents_contracts::base::types::{EventDetails, EventRegistration, EventType}; use chainevents_contracts::base::errors::Errors::{ - ZERO_ADDRESS_OWNER, ZERO_ADDRESS_CALLER, NOT_OWNER, CLOSED_EVENT, ALREADY_REGISTERED, NOT_REGISTERED, ALREADY_RSVP + ZERO_ADDRESS_OWNER, ZERO_ADDRESS_CALLER, NOT_OWNER, CLOSED_EVENT, ALREADY_REGISTERED, + NOT_REGISTERED, ALREADY_RSVP }; use chainevents_contracts::interfaces::IEvent::IEvent; use core::starknet::{ @@ -177,19 +178,17 @@ pub mod Events { fn rsvp_for_event(ref self: ContractState, event_id: u256) { let caller = get_caller_address(); - let attendee_event_details = self.attendee_event_details.entry((event_id, caller)).read(); + let attendee_event_details = self + .attendee_event_details + .entry((event_id, caller)) + .read(); assert(attendee_event_details.attendee_address == caller, NOT_REGISTERED); assert(attendee_event_details.has_rsvp == false, ALREADY_RSVP); self.attendee_event_details.entry((event_id, caller)).has_rsvp.write(true); - self.emit( - RSVPForEvent { - event_id, - attendee_address: caller, - } - ); + self.emit(RSVPForEvent { event_id, attendee_address: caller, }); } fn upgrade_event(ref self: ContractState, event_id: u256, paid_amount: u256) {} diff --git a/tests/test_contract.cairo b/tests/test_contract.cairo index 68a5b6c..a66f134 100644 --- a/tests/test_contract.cairo +++ b/tests/test_contract.cairo @@ -9,7 +9,7 @@ use starknet::{ContractAddress}; use snforge_std::{ declare, start_cheat_caller_address, stop_cheat_caller_address, ContractClassTrait, - DeclareResultTrait, spy_events, EventSpyAssertionsTrait, + DeclareResultTrait, spy_events, EventSpyAssertionsTrait, }; use chainevents_contracts::interfaces::IEvent::{IEventDispatcher, IEventDispatcherTrait}; @@ -104,10 +104,12 @@ fn test_rsvp_for_event_should_emit_event_on_success() { event_dispatcher.register_for_event(event_id); let mut spy = spy_events(); - + event_dispatcher.rsvp_for_event(event_id); - let expected_event = Events::Event::RSVPForEvent(Events::RSVPForEvent { event_id: 1, attendee_address: caller }); + let expected_event = Events::Event::RSVPForEvent( + Events::RSVPForEvent { event_id: 1, attendee_address: caller } + ); spy.assert_emitted(@array![(event_contract_address, expected_event)]); stop_cheat_caller_address(event_contract_address); @@ -132,7 +134,7 @@ fn test_should_panic_on_rsvp_for_event_twice() { start_cheat_caller_address(event_contract_address, caller); event_dispatcher.register_for_event(event_id); - + // first rsvp for event event_dispatcher.rsvp_for_event(event_id); @@ -140,4 +142,4 @@ fn test_should_panic_on_rsvp_for_event_twice() { event_dispatcher.rsvp_for_event(event_id); stop_cheat_caller_address(event_contract_address); -} \ No newline at end of file +}