Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions project_registry/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,32 @@ fn test_score_changed_event_contains_old_and_new_values() {
client.update_impact_score(&id, &80u32, &60u32);
}

#[test]
fn test_score_changed_event_credit_quality_path() {
let (env, _admin, _whitelister, client) = setup();
let creator = Address::generate(&env);
client.set_whitelist(&creator, &true);
let id = client.create_project(
&creator,
&String::from_str(&env, "ipfs://Qm"),
&0u64,
&test_metadata_hash(&env),
);

// Set initial scores
client.update_impact_score(&id, &50u32, &70u32);

// Update only credit quality via the credit-quality path
client.update_credit_quality_score(&id, &85u32);

// Verify ScoreChanged event is emitted
let events = env.events().all().filter_by_contract(&client.address);
assert!(
events.events().len() >= 1,
"update_credit_quality_score should emit at least one event"
);
}

#[test]
fn test_certify_project_emits_event() {
let (env, _admin, whitelister, client) = setup();
Expand Down Expand Up @@ -1641,6 +1667,10 @@ fn test_score_history_multiple_updates_ordered() {
assert_eq!(history.get(0).unwrap().credit_quality, 10); // oldest
assert_eq!(history.get(1).unwrap().credit_quality, 30);
assert_eq!(history.get(2).unwrap().credit_quality, 50); // newest

// Explicit assertion on chronological ordering: timestamps must be strictly increasing
assert!(history.get(0).unwrap().timestamp < history.get(1).unwrap().timestamp);
assert!(history.get(1).unwrap().timestamp < history.get(2).unwrap().timestamp);
}

#[test]
Expand Down
Loading