Skip to content

Commit

Permalink
[refactor] #1981, #4195, #3068: Update event filter builder methods n…
Browse files Browse the repository at this point in the history
…aming

Follow the pattern of [event filter] for_X everywhere

Signed-off-by: Nikita Strygin <[email protected]>
  • Loading branch information
DCNick3 committed Mar 13, 2024
1 parent 9f8818b commit 2df70f5
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 79 deletions.
4 changes: 2 additions & 2 deletions client/benches/tps/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ impl MeasurerUnit {
let listener = self.client.clone();
let (init_sender, init_receiver) = mpsc::channel();
let event_filter = PipelineEventFilter::new()
.from_entity_of_kind(PipelineEntityKind::Block)
.with_status(PipelineStatusKind::Committed);
.for_entity(PipelineEntityKind::Block)
.for_status(PipelineStatusKind::Committed);
let blocks_expected = self.config.blocks as usize;
let name = self.name;
let handle = thread::spawn(move || -> Result<()> {
Expand Down
4 changes: 1 addition & 3 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,7 @@ impl Client {
let mut event_iterator = {
let event_iterator_result = tokio::time::timeout_at(
deadline,
self.listen_for_events_async(
PipelineEventFilter::new().from_entity_with_hash(hash.into()),
),
self.listen_for_events_async(PipelineEventFilter::new().for_hash(hash.into())),
)
.await
.map_err(Into::into)
Expand Down
2 changes: 1 addition & 1 deletion client/tests/integration/domain_owner_permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ fn domain_owner_trigger_permissions() -> Result<()> {
Repeats::from(2_u32),
bob_id,
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new().from_trigger(trigger_id.clone()),
ExecuteTriggerEventFilter::new().for_trigger(trigger_id.clone()),
),
),
));
Expand Down
12 changes: 6 additions & 6 deletions client/tests/integration/events/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn trigger_completion_success_should_produce_event() -> Result<()> {
asset_id.account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id.clone())
.for_trigger(trigger_id.clone())
.under_authority(asset_id.account_id),
),
),
Expand All @@ -38,8 +38,8 @@ fn trigger_completion_success_should_produce_event() -> Result<()> {
let mut event_it =
thread_client.listen_for_events(NotificationEventFilter::ByTriggerCompleted(
TriggerCompletedEventFilter::new()
.from_trigger(trigger_id)
.with_outcome(TriggerCompletedOutcomeType::Success),
.for_trigger(trigger_id)
.for_outcome(TriggerCompletedOutcomeType::Success),
))?;
if event_it.next().is_some() {
sender.send(())?;
Expand Down Expand Up @@ -72,7 +72,7 @@ fn trigger_completion_failure_should_produce_event() -> Result<()> {
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id.clone())
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
),
Expand All @@ -87,8 +87,8 @@ fn trigger_completion_failure_should_produce_event() -> Result<()> {
let mut event_it =
thread_client.listen_for_events(NotificationEventFilter::ByTriggerCompleted(
TriggerCompletedEventFilter::new()
.from_trigger(trigger_id)
.with_outcome(TriggerCompletedOutcomeType::Failure),
.for_trigger(trigger_id)
.for_outcome(TriggerCompletedOutcomeType::Failure),
))?;
if event_it.next().is_some() {
sender.send(())?;
Expand Down
10 changes: 5 additions & 5 deletions client/tests/integration/events/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ impl Checker {
.listener
.listen_for_events(
PipelineEventFilter::new()
.from_entity_of_kind(PipelineEntityKind::Transaction)
.with_status(status_kind)
.from_entity_with_hash(*self.hash),
.for_entity(PipelineEntityKind::Transaction)
.for_status(status_kind)
.for_hash(*self.hash),
)
.expect("Failed to create event iterator.");
let event_result = event_iterator.next().expect("Stream closed");
Expand All @@ -101,8 +101,8 @@ fn committed_block_must_be_available_in_kura() {
wait_for_genesis_committed(&[client.clone()], 0);

let event_filter = PipelineEventFilter::new()
.from_entity_of_kind(PipelineEntityKind::Block)
.with_status(PipelineStatusKind::Committed);
.for_entity(PipelineEntityKind::Block)
.for_status(PipelineStatusKind::Committed);
let mut event_iter = client
.listen_for_events(event_filter)
.expect("Failed to subscribe for events");
Expand Down
22 changes: 11 additions & 11 deletions client/tests/integration/triggers/by_call_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn execute_trigger_should_produce_event() -> Result<()> {
let _handle = thread::spawn(move || -> Result<()> {
let mut event_it = thread_client.listen_for_events(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id)
.for_trigger(trigger_id)
.under_authority(account_id),
)?;
if event_it.next().is_some() {
Expand Down Expand Up @@ -126,7 +126,7 @@ fn trigger_failure_should_not_cancel_other_triggers_execution() -> Result<()> {
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(bad_trigger_id.clone())
.for_trigger(bad_trigger_id.clone())
.under_authority(account_id.clone()),
),
),
Expand Down Expand Up @@ -182,7 +182,7 @@ fn trigger_should_not_be_executed_with_zero_repeats_count() -> Result<()> {
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id.clone())
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
),
Expand Down Expand Up @@ -247,7 +247,7 @@ fn trigger_should_be_able_to_modify_its_own_repeats_count() -> Result<()> {
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id.clone())
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
),
Expand Down Expand Up @@ -291,7 +291,7 @@ fn unregister_trigger() -> Result<()> {
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id.clone())
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
),
Expand Down Expand Up @@ -369,7 +369,7 @@ fn trigger_in_genesis_using_base64() -> Result<()> {
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id.clone())
.for_trigger(trigger_id.clone())
.under_authority(account_id.clone()),
),
),
Expand Down Expand Up @@ -420,7 +420,7 @@ fn trigger_should_be_able_to_modify_other_trigger() -> Result<()> {
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id_unregister.clone())
.for_trigger(trigger_id_unregister.clone())
.under_authority(account_id.clone()),
),
),
Expand All @@ -437,7 +437,7 @@ fn trigger_should_be_able_to_modify_other_trigger() -> Result<()> {
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id_to_be_unregistered.clone())
.for_trigger(trigger_id_to_be_unregistered.clone())
.under_authority(account_id),
),
),
Expand Down Expand Up @@ -482,7 +482,7 @@ fn trigger_burn_repetitions() -> Result<()> {
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id.clone())
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
),
Expand Down Expand Up @@ -527,7 +527,7 @@ fn unregistering_one_of_two_triggers_with_identical_wasm_should_not_cause_origin
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id)
.for_trigger(trigger_id)
.under_authority(account_id.clone()),
),
),
Expand Down Expand Up @@ -578,7 +578,7 @@ fn build_register_trigger_isi(
asset_id.account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id)
.for_trigger(trigger_id)
.under_authority(asset_id.account_id),
),
),
Expand Down
6 changes: 3 additions & 3 deletions client/tests/integration/triggers/data_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn must_execute_both_triggers() -> Result<()> {
Repeats::Indefinitely,
account_id.clone(),
TriggeringEventFilterBox::Data(DataEventFilter::Account(
AccountEventFilter::new().only_events(AccountEventSet::Created),
AccountEventFilter::new().for_events(AccountEventSet::Created),
)),
),
));
Expand All @@ -37,7 +37,7 @@ fn must_execute_both_triggers() -> Result<()> {
Repeats::Indefinitely,
account_id,
TriggeringEventFilterBox::Data(DataEventFilter::Domain(
DomainEventFilter::new().only_events(DomainEventSet::Created),
DomainEventFilter::new().for_events(DomainEventSet::Created),
)),
),
));
Expand Down Expand Up @@ -89,7 +89,7 @@ fn domain_scoped_trigger_must_be_executed_only_on_events_in_its_domain() -> Resu
Repeats::Indefinitely,
account_id,
TriggeringEventFilterBox::Data(DataEventFilter::Account(
AccountEventFilter::new().only_events(AccountEventSet::Created),
AccountEventFilter::new().for_events(AccountEventSet::Created),
)),
),
));
Expand Down
2 changes: 1 addition & 1 deletion client/tests/integration/triggers/event_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn test_mint_asset_when_new_asset_definition_created() -> Result<()> {
Repeats::Indefinitely,
account_id,
TriggeringEventFilterBox::Data(DataEventFilter::AssetDefinition(
AssetDefinitionEventFilter::new().only_events(AssetDefinitionEventSet::Created),
AssetDefinitionEventFilter::new().for_events(AssetDefinitionEventSet::Created),
)),
),
));
Expand Down
4 changes: 2 additions & 2 deletions client/tests/integration/triggers/time_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ fn get_block_committed_event_listener(
client: &Client,
) -> Result<impl Iterator<Item = Result<Event>>> {
let block_filter = PipelineEventFilter::new()
.from_entity_of_kind(PipelineEntityKind::Block)
.with_status(PipelineStatusKind::Committed);
.for_entity(PipelineEntityKind::Block)
.for_status(PipelineStatusKind::Committed);
client.listen_for_events(block_filter)
}

Expand Down
2 changes: 1 addition & 1 deletion client/tests/integration/triggers/trigger_rollback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn failed_trigger_revert() -> Result<()> {
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id.clone())
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
),
Expand Down
2 changes: 1 addition & 1 deletion core/src/smartcontracts/isi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ mod tests {
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.from_trigger(trigger_id.clone())
.for_trigger(trigger_id.clone())
.under_authority(account_id.clone()),
),
),
Expand Down
Loading

0 comments on commit 2df70f5

Please sign in to comment.