Skip to content

Commit

Permalink
replace deal_id with id in market events
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 committed Nov 1, 2023
1 parent 405597c commit d750564
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 36 deletions.
12 changes: 4 additions & 8 deletions actors/market/src/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,24 @@ pub fn deal_published(
.typ("deal-published")
.field_indexed("client", &client)
.field_indexed("provider", &provider)
.field_indexed("deal_id", &deal_id)
.field_indexed("id", &deal_id)
.build()?,
)
}

/// Indicates a deal has been activated.
pub fn deal_activated(rt: &impl Runtime, deal_id: DealID) -> Result<(), ActorError> {
rt.emit_event(
&EventBuilder::new().typ("deal-activated").field_indexed("deal_id", &deal_id).build()?,
)
rt.emit_event(&EventBuilder::new().typ("deal-activated").field_indexed("id", &deal_id).build()?)
}

/// Indicates a deal has been terminated.
pub fn deal_terminated(rt: &impl Runtime, deal_id: DealID) -> Result<(), ActorError> {
rt.emit_event(
&EventBuilder::new().typ("deal-terminated").field_indexed("deal_id", &deal_id).build()?,
&EventBuilder::new().typ("deal-terminated").field_indexed("id", &deal_id).build()?,
)
}

/// Indicates a deal has been completed successfully.
pub fn deal_completed(rt: &impl Runtime, deal_id: DealID) -> Result<(), ActorError> {
rt.emit_event(
&EventBuilder::new().typ("deal-completed").field_indexed("deal_id", &deal_id).build()?,
)
rt.emit_event(&EventBuilder::new().typ("deal-completed").field_indexed("id", &deal_id).build()?)
}
12 changes: 2 additions & 10 deletions actors/market/tests/cron_tick_deal_expiry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ fn expired_deal_should_unlock_the_remaining_client_and_provider_locked_balance_a

// move the current epoch so that deal is expired
rt.expect_emitted_event(
EventBuilder::new()
.typ("deal-completed")
.field_indexed("deal_id", &deal_id)
.build()
.unwrap(),
EventBuilder::new().typ("deal-completed").field_indexed("id", &deal_id).build().unwrap(),
);
rt.set_epoch(END_EPOCH + 1000);
cron_tick(&rt);
Expand Down Expand Up @@ -213,11 +209,7 @@ fn all_payments_are_made_for_a_deal_client_withdraws_collateral_and_client_accou
// move the current epoch so that deal is expired
rt.set_epoch(END_EPOCH + 100);
rt.expect_emitted_event(
EventBuilder::new()
.typ("deal-completed")
.field_indexed("deal_id", &deal_id)
.build()
.unwrap(),
EventBuilder::new().typ("deal-completed").field_indexed("id", &deal_id).build().unwrap(),
);
cron_tick(&rt);
assert_eq!(deal_proposal.client_collateral, get_balance(&rt, &CLIENT_ADDR).balance);
Expand Down
11 changes: 4 additions & 7 deletions actors/market/tests/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ pub fn batch_activate_deals_raw(
rt.expect_emitted_event(
EventBuilder::new()
.typ("deal-activated")
.field_indexed("deal_id", &deal_id)
.field_indexed("id", &deal_id)
.build()
.unwrap(),
);
Expand Down Expand Up @@ -528,7 +528,7 @@ pub fn cron_tick_and_assert_balances(
rt.expect_emitted_event(
EventBuilder::new()
.typ("deal-completed")
.field_indexed("deal_id", &deal_id)
.field_indexed("id", &deal_id)
.build()
.unwrap(),
);
Expand Down Expand Up @@ -730,7 +730,7 @@ pub fn publish_deals(
.typ("deal-published")
.field_indexed("client", &deal.client.id().unwrap())
.field_indexed("provider", &deal.provider.id().unwrap())
.field_indexed("deal_id", &deal_id)
.field_indexed("id", &deal_id)
.build()
.unwrap(),
);
Expand Down Expand Up @@ -1197,10 +1197,7 @@ pub fn terminate_deals_raw(

for deal_id in terminated_deals {
rt.expect_emitted_event(
EventBuilder::new()
.typ("deal-terminated")
.field_indexed("deal_id", &deal_id)
.build()?,
EventBuilder::new().typ("deal-terminated").field_indexed("id", &deal_id).build()?,
);
}

Expand Down
14 changes: 5 additions & 9 deletions actors/market/tests/market_actor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ fn provider_and_client_addresses_are_resolved_before_persisting_state_and_sent_t
.typ("deal-published")
.field_indexed("client", &client_resolved.id().unwrap())
.field_indexed("provider", &provider_resolved.id().unwrap())
.field_indexed("deal_id", &deal_id)
.field_indexed("id", &deal_id)
.build()
.unwrap(),
);
Expand Down Expand Up @@ -1937,11 +1937,7 @@ fn locked_fund_tracking_states() {
);

rt.expect_emitted_event(
EventBuilder::new()
.typ("deal-completed")
.field_indexed("deal_id", &deal_id2)
.build()
.unwrap(),
EventBuilder::new().typ("deal-completed").field_indexed("id", &deal_id2).build().unwrap(),
);
cron_tick(&rt);
assert_locked_fund_states(&rt, csf, plc, clc);
Expand Down Expand Up @@ -2158,7 +2154,7 @@ fn insufficient_client_balance_in_a_batch() {
.typ("deal-published")
.field_indexed("client", &deal2.client.id().unwrap())
.field_indexed("provider", &deal2.provider.id().unwrap())
.field_indexed("deal_id", &next_deal_id)
.field_indexed("id", &next_deal_id)
.build()
.unwrap(),
);
Expand Down Expand Up @@ -2307,7 +2303,7 @@ fn insufficient_provider_balance_in_a_batch() {
.typ("deal-published")
.field_indexed("client", &deal2.client.id().unwrap())
.field_indexed("provider", &deal2.provider.id().unwrap())
.field_indexed("deal_id", &next_deal_id)
.field_indexed("id", &next_deal_id)
.build()
.unwrap(),
);
Expand Down Expand Up @@ -2459,7 +2455,7 @@ fn psd_restricted_correctly() {
.typ("deal-published")
.field_indexed("client", &deal.client.id().unwrap())
.field_indexed("provider", &deal.provider.id().unwrap())
.field_indexed("deal_id", &next_deal_id)
.field_indexed("id", &next_deal_id)
.build()
.unwrap(),
);
Expand Down
2 changes: 1 addition & 1 deletion actors/market/tests/on_miner_sectors_terminate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fn terminate_valid_deals_along_with_expired_and_cleaned_up_deal() {
rt.expect_emitted_event(
EventBuilder::new()
.typ("deal-completed")
.field_indexed("deal_id", &deal_ids[1])
.field_indexed("id", &deal_ids[1])
.build()
.unwrap(),
);
Expand Down
2 changes: 1 addition & 1 deletion actors/market/tests/publish_storage_deals_failures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ fn fail_when_deals_have_different_providers() {
.typ("deal-published")
.field_indexed("client", &deal1.client.id().unwrap())
.field_indexed("provider", &deal1.provider.id().unwrap())
.field_indexed("deal_id", &next_deal_id)
.field_indexed("id", &next_deal_id)
.build()
.unwrap(),
);
Expand Down

0 comments on commit d750564

Please sign in to comment.