Skip to content

Commit

Permalink
test and lint fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
PoulavBhowmick03 committed Oct 26, 2024
1 parent 918e34e commit 101c2c7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/events/events.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,4 @@ pub mod Events {
event_attendance_details
}
}
}
}
31 changes: 15 additions & 16 deletions tests/test_contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn test_event_count_increase() {
let event_dispatcher = IEventDispatcher { contract_address: event_contract_address };

start_cheat_caller_address(event_contract_address, USER_ONE.try_into().unwrap());

let initial_event_id = event_dispatcher.add_event("Blockchain Conference", "Tech Park");
assert(initial_event_id == 1, 'First event ID incorrect');

Expand All @@ -88,22 +88,21 @@ fn test_event_emission() {

start_cheat_caller_address(event_contract_address, USER_ONE.try_into().unwrap());

let event_name = "Devcon";
let event_location = "Barcelona";
let expected_event_id = 1;
// Add event with string literals
let event_id = event_dispatcher.add_event("Devcon", "Barcelona");
assert(event_id == 1, 'Event ID mismatch');

// Get event details and compare them separately
let event_details = event_dispatcher.event_details(event_id);

let event_id = event_dispatcher.add_event(event_name, event_location);
// Compare each field independently
let name_matches = event_details.name == "Devcon";
let location_matches = event_details.location == "Barcelona";

// Check if event ID is correct
assert(event_id == expected_event_id, 'Event ID mismatch');
assert(name_matches, 'Event name mismatch');
assert(location_matches, 'Event location mismatch');
assert(event_details.event_id == event_id, 'Event ID mismatch in details');
assert(!event_details.is_closed, 'Event should not be closed');

// Verify event details
let emitted_event = event_dispatcher.event_details(event_id);

assert(emitted_event.name == event_name, 'Event name mismatch');
// assert(emitted_event.location == event_location, 'Event location mismatch');
// assert(emitted_event.event_id == event_id, 'Event ID mismatch in details');
// assert(!emitted_event.is_closed, 'Event should not be closed');

stop_cheat_caller_address(event_contract_address);
}
}

0 comments on commit 101c2c7

Please sign in to comment.