Skip to content

Commit

Permalink
[refactor] #1981, #4195: Rename FilterBox and TriggeringFilterBox to …
Browse files Browse the repository at this point in the history
…EventFilterBox and TriggeringEventFilterBox

To make it consistent with the renamed EventFilter trait

Signed-off-by: Nikita Strygin <[email protected]>
  • Loading branch information
DCNick3 committed Mar 18, 2024
1 parent 8954f6a commit da4dbdb
Show file tree
Hide file tree
Showing 30 changed files with 198 additions and 192 deletions.
12 changes: 6 additions & 6 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl_query_output! {
crate::data_model::metadata::MetadataValueBox,
crate::data_model::query::TransactionQueryOutput,
crate::data_model::permission::PermissionTokenSchema,
crate::data_model::trigger::Trigger<crate::data_model::events::TriggeringFilterBox>,
crate::data_model::trigger::Trigger<crate::data_model::events::TriggeringEventFilterBox>,
crate::data_model::prelude::Numeric,
}

Expand Down Expand Up @@ -905,7 +905,7 @@ impl Client {
/// - Forwards from [`events_api::EventIterator::new`]
pub fn listen_for_events(
&self,
event_filter: FilterBox,
event_filter: EventFilterBox,
) -> Result<impl Iterator<Item = Result<Event>>> {
iroha_logger::trace!(?event_filter);
events_api::EventIterator::new(self.events_handler(event_filter)?)
Expand All @@ -918,7 +918,7 @@ impl Client {
/// - Forwards from [`events_api::AsyncEventStream::new`]
pub async fn listen_for_events_async(
&self,
event_filter: FilterBox,
event_filter: EventFilterBox,
) -> Result<AsyncEventStream> {
iroha_logger::trace!(?event_filter, "Async listening with");
events_api::AsyncEventStream::new(self.events_handler(event_filter)?).await
Expand All @@ -929,7 +929,7 @@ impl Client {
/// # Errors
/// Fails if handler construction fails
#[inline]
pub fn events_handler(&self, event_filter: FilterBox) -> Result<events_api::flow::Init> {
pub fn events_handler(&self, event_filter: EventFilterBox) -> Result<events_api::flow::Init> {
events_api::flow::Init::new(
event_filter,
self.headers.clone(),
Expand Down Expand Up @@ -1235,7 +1235,7 @@ pub mod events_api {
/// Initialization struct for Events API flow.
pub struct Init {
/// Event filter
filter: FilterBox,
filter: EventFilterBox,
/// HTTP request headers
headers: HashMap<String, String>,
/// TORII URL
Expand All @@ -1249,7 +1249,7 @@ pub mod events_api {
/// Fails if [`transform_ws_url`] fails.
#[inline]
pub(in super::super) fn new(
filter: FilterBox,
filter: EventFilterBox,
headers: HashMap<String, String>,
url: Url,
) -> Result<Self> {
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,
// FIXME: due to restriction in `ExecuteTriggerEventFilter` it's impossible to execute trigger on behalf of multiple users
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id.clone(),
alice_id,
)),
Expand Down
4 changes: 2 additions & 2 deletions client/tests/integration/events/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn transaction_execution_should_produce_events(
let listener = client.clone();
let (init_sender, init_receiver) = mpsc::channel();
let (event_sender, event_receiver) = mpsc::channel();
let event_filter = FilterBox::Data(DataEventFilter::ByAny);
let event_filter = EventFilterBox::Data(DataEventFilter::ByAny);
thread::spawn(move || -> Result<()> {
let event_iterator = listener.listen_for_events(event_filter)?;
init_sender.send(())?;
Expand Down Expand Up @@ -182,7 +182,7 @@ fn produce_multiple_events() -> Result<()> {
let listener = client.clone();
let (init_sender, init_receiver) = mpsc::channel();
let (event_sender, event_receiver) = mpsc::channel();
let event_filter = FilterBox::Data(DataEventFilter::ByAny);
let event_filter = EventFilterBox::Data(DataEventFilter::ByAny);
thread::spawn(move || -> Result<()> {
let event_iterator = listener.listen_for_events(event_filter)?;
init_sender.send(())?;
Expand Down
4 changes: 2 additions & 2 deletions client/tests/integration/events/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn trigger_completion_success_should_produce_event() -> Result<()> {
vec![InstructionBox::from(instruction)],
Repeats::Indefinitely,
asset_id.account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id.clone(),
asset_id.account_id,
)),
Expand Down Expand Up @@ -70,7 +70,7 @@ fn trigger_completion_failure_should_produce_event() -> Result<()> {
vec![InstructionBox::from(instruction)],
Repeats::Indefinitely,
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id.clone(),
account_id,
)),
Expand Down
2 changes: 1 addition & 1 deletion client/tests/integration/events/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Checker {
thread::spawn(move || {
let mut event_iterator = self
.listener
.listen_for_events(FilterBox::Pipeline(
.listen_for_events(EventFilterBox::Pipeline(
PipelineEventFilter::new()
.entity_kind(PipelineEntityKind::Transaction)
.status_kind(status_kind)
Expand Down
26 changes: 13 additions & 13 deletions client/tests/integration/triggers/by_call_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use iroha_client::{
transaction::Executable,
},
};
use iroha_data_model::{events::TriggeringFilterBox, transaction::WasmSmartContract};
use iroha_data_model::{events::TriggeringEventFilterBox, transaction::WasmSmartContract};
use iroha_genesis::GenesisNetwork;
use iroha_logger::info;
use test_network::*;
Expand Down Expand Up @@ -121,7 +121,7 @@ fn trigger_failure_should_not_cancel_other_triggers_execution() -> Result<()> {
bad_trigger_instructions,
Repeats::Indefinitely,
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
bad_trigger_id.clone(),
account_id.clone(),
)),
Expand All @@ -139,7 +139,7 @@ fn trigger_failure_should_not_cancel_other_triggers_execution() -> Result<()> {
Repeats::Indefinitely,
account_id,
// Time-triggers (which are Pre-commit triggers) will be executed last
TriggeringFilterBox::Time(TimeEventFilter::new(ExecutionTime::PreCommit)),
TriggeringEventFilterBox::Time(TimeEventFilter::new(ExecutionTime::PreCommit)),
),
));
test_client.submit_blocking(register_trigger)?;
Expand Down Expand Up @@ -176,7 +176,7 @@ fn trigger_should_not_be_executed_with_zero_repeats_count() -> Result<()> {
trigger_instructions,
Repeats::from(1_u32),
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id.clone(),
account_id,
)),
Expand Down Expand Up @@ -240,7 +240,7 @@ fn trigger_should_be_able_to_modify_its_own_repeats_count() -> Result<()> {
trigger_instructions,
Repeats::from(1_u32),
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id.clone(),
account_id,
)),
Expand Down Expand Up @@ -283,7 +283,7 @@ fn unregister_trigger() -> Result<()> {
Vec::<InstructionBox>::new(),
Repeats::Indefinitely,
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id.clone(),
account_id,
)),
Expand Down Expand Up @@ -360,7 +360,7 @@ fn trigger_in_genesis_using_base64() -> Result<()> {
.wrap_err("Can't deserialize wasm using base64")?,
Repeats::Indefinitely,
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id.clone(),
account_id.clone(),
)),
Expand Down Expand Up @@ -410,7 +410,7 @@ fn trigger_should_be_able_to_modify_other_trigger() -> Result<()> {
trigger_unregister_instructions,
Repeats::from(1_u32),
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id_unregister.clone(),
account_id.clone(),
)),
Expand All @@ -426,7 +426,7 @@ fn trigger_should_be_able_to_modify_other_trigger() -> Result<()> {
trigger_should_be_unregistered_instructions,
Repeats::from(1_u32),
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id_to_be_unregistered.clone(),
account_id,
)),
Expand Down Expand Up @@ -470,7 +470,7 @@ fn trigger_burn_repetitions() -> Result<()> {
trigger_instructions,
Repeats::from(1_u32),
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id.clone(),
account_id,
)),
Expand Down Expand Up @@ -514,7 +514,7 @@ fn unregistering_one_of_two_triggers_with_identical_wasm_should_not_cause_origin
wasm.clone(),
Repeats::Indefinitely,
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id,
account_id.clone(),
)),
Expand Down Expand Up @@ -555,7 +555,7 @@ fn get_asset_value(client: &mut Client, asset_id: AssetId) -> Numeric {
fn build_register_trigger_isi(
asset_id: AssetId,
trigger_instructions: Vec<InstructionBox>,
) -> Register<Trigger<TriggeringFilterBox>> {
) -> Register<Trigger<TriggeringEventFilterBox>> {
let trigger_id: TriggerId = TRIGGER_NAME.parse().expect("Valid");

Register::trigger(Trigger::new(
Expand All @@ -564,7 +564,7 @@ fn build_register_trigger_isi(
trigger_instructions,
Repeats::Indefinitely,
asset_id.account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id,
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 @@ -23,7 +23,7 @@ fn must_execute_both_triggers() -> Result<()> {
[instruction.clone()],
Repeats::Indefinitely,
account_id.clone(),
TriggeringFilterBox::Data(DataEventFilter::ByAccount(AccountEventFilter {
TriggeringEventFilterBox::Data(DataEventFilter::ByAccount(AccountEventFilter {
id_matcher: None,
event_matcher: Some(AccountEventMatcher::ByCreated),
})),
Expand All @@ -37,7 +37,7 @@ fn must_execute_both_triggers() -> Result<()> {
[instruction],
Repeats::Indefinitely,
account_id,
TriggeringFilterBox::Data(DataEventFilter::ByDomain(DomainEventFilter {
TriggeringEventFilterBox::Data(DataEventFilter::ByDomain(DomainEventFilter {
id_matcher: None,
event_matcher: Some(DomainEventMatcher::ByCreated),
})),
Expand Down Expand Up @@ -90,7 +90,7 @@ fn domain_scoped_trigger_must_be_executed_only_on_events_in_its_domain() -> Resu
[Mint::asset_numeric(1u32, asset_id.clone())],
Repeats::Indefinitely,
account_id,
TriggeringFilterBox::Data(DataEventFilter::ByAccount(AccountEventFilter {
TriggeringEventFilterBox::Data(DataEventFilter::ByAccount(AccountEventFilter {
id_matcher: None,
event_matcher: Some(AccountEventMatcher::ByCreated),
})),
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 @@ -24,7 +24,7 @@ fn test_mint_asset_when_new_asset_definition_created() -> Result<()> {
vec![instruction],
Repeats::Indefinitely,
account_id,
TriggeringFilterBox::Data(DataEventFilter::ByAssetDefinition(
TriggeringEventFilterBox::Data(DataEventFilter::ByAssetDefinition(
AssetDefinitionEventFilter {
id_matcher: None,
event_matcher: Some(AssetDefinitionEventMatcher::ByCreated),
Expand Down
10 changes: 5 additions & 5 deletions client/tests/integration/triggers/time_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn time_trigger_execution_count_error_should_be_less_than_15_percent() -> Result
vec![instruction],
Repeats::Indefinitely,
account_id.clone(),
TriggeringFilterBox::Time(TimeEventFilter::new(ExecutionTime::Schedule(schedule))),
TriggeringEventFilterBox::Time(TimeEventFilter::new(ExecutionTime::Schedule(schedule))),
),
));
test_client.submit(register_trigger)?;
Expand Down Expand Up @@ -110,7 +110,7 @@ fn change_asset_metadata_after_1_sec() -> Result<()> {
vec![instruction],
Repeats::from(1_u32),
account_id.clone(),
TriggeringFilterBox::Time(TimeEventFilter::new(ExecutionTime::Schedule(schedule))),
TriggeringEventFilterBox::Time(TimeEventFilter::new(ExecutionTime::Schedule(schedule))),
),
));
test_client.submit(register_trigger)?;
Expand Down Expand Up @@ -154,7 +154,7 @@ fn pre_commit_trigger_should_be_executed() -> Result<()> {
vec![instruction],
Repeats::Indefinitely,
account_id.clone(),
TriggeringFilterBox::Time(TimeEventFilter::new(ExecutionTime::PreCommit)),
TriggeringEventFilterBox::Time(TimeEventFilter::new(ExecutionTime::PreCommit)),
),
));
test_client.submit(register_trigger)?;
Expand Down Expand Up @@ -229,7 +229,7 @@ fn mint_nft_for_every_user_every_1_sec() -> Result<()> {
WasmSmartContract::from_compiled(wasm),
Repeats::Indefinitely,
alice_id.clone(),
TriggeringFilterBox::Time(TimeEventFilter::new(ExecutionTime::Schedule(schedule))),
TriggeringEventFilterBox::Time(TimeEventFilter::new(ExecutionTime::Schedule(schedule))),
),
));
test_client.submit(register_trigger)?;
Expand Down Expand Up @@ -273,7 +273,7 @@ fn mint_nft_for_every_user_every_1_sec() -> Result<()> {
fn get_block_committed_event_listener(
client: &Client,
) -> Result<impl Iterator<Item = Result<Event>>> {
let block_filter = FilterBox::Pipeline(
let block_filter = EventFilterBox::Pipeline(
PipelineEventFilter::new()
.entity_kind(PipelineEntityKind::Block)
.status_kind(PipelineStatusKind::Committed),
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 @@ -28,7 +28,7 @@ fn failed_trigger_revert() -> Result<()> {
instructions,
Repeats::Indefinitely,
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id.clone(),
account_id,
)),
Expand Down
8 changes: 4 additions & 4 deletions client_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,15 @@ mod events {
impl RunArgs for Args {
fn run(self, context: &mut dyn RunContext) -> Result<()> {
let filter = match self {
Args::Pipeline => FilterBox::Pipeline(PipelineEventFilter::new()),
Args::Data => FilterBox::Data(DataEventFilter::ByAny),
Args::Notification => FilterBox::Notification(NotificationEventFilter::ByAny),
Args::Pipeline => EventFilterBox::Pipeline(PipelineEventFilter::new()),
Args::Data => EventFilterBox::Data(DataEventFilter::ByAny),
Args::Notification => EventFilterBox::Notification(NotificationEventFilter::ByAny),
};
listen(filter, context)
}
}

fn listen(filter: FilterBox, context: &mut dyn RunContext) -> Result<()> {
fn listen(filter: EventFilterBox, context: &mut dyn RunContext) -> Result<()> {
let iroha_client = context.client_from_config();
eprintln!("Listening to events with filter: {filter:?}");
iroha_client
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 @@ -378,7 +378,7 @@ mod tests {
Vec::<InstructionBox>::new(),
Repeats::Indefinitely,
account_id.clone(),
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
TriggeringEventFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new(
trigger_id.clone(),
account_id.clone(),
)),
Expand Down
2 changes: 1 addition & 1 deletion core/src/smartcontracts/isi/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl_lazy! {
iroha_data_model::metadata::MetadataValueBox,
iroha_data_model::query::TransactionQueryOutput,
iroha_data_model::permission::PermissionTokenSchema,
iroha_data_model::trigger::Trigger<iroha_data_model::events::TriggeringFilterBox>,
iroha_data_model::trigger::Trigger<iroha_data_model::events::TriggeringEventFilterBox>,
}

/// Query Request statefully validated on the Iroha node side.
Expand Down
Loading

0 comments on commit da4dbdb

Please sign in to comment.