Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] #4259: Make Action and Filter non-generic types #4375

Merged
merged 2 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion 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::TriggeringEventFilterBox>,
crate::data_model::trigger::Trigger,
crate::data_model::prelude::Numeric,
}

Expand Down
4 changes: 1 addition & 3 deletions client/tests/integration/domain_owner_permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,7 @@ fn domain_owner_trigger_permissions() -> Result<()> {
trigger_instructions,
Repeats::from(2_u32),
bob_id,
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new().for_trigger(trigger_id.clone()),
),
ExecuteTriggerEventFilter::new().for_trigger(trigger_id.clone()),
),
));
test_client.submit_blocking(register_trigger)?;
Expand Down
16 changes: 6 additions & 10 deletions client/tests/integration/events/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ fn trigger_completion_success_should_produce_event() -> Result<()> {
vec![InstructionBox::from(instruction)],
Repeats::Indefinitely,
asset_id.account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(asset_id.account_id),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(asset_id.account_id),
),
));
test_client.submit_blocking(register_trigger)?;
Expand Down Expand Up @@ -69,11 +67,9 @@ fn trigger_completion_failure_should_produce_event() -> Result<()> {
vec![InstructionBox::from(instruction)],
Repeats::Indefinitely,
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
));
test_client.submit_blocking(register_trigger)?;
Expand Down
87 changes: 33 additions & 54 deletions client/tests/integration/triggers/by_call_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use iroha_client::{
data_model::{
prelude::*,
query::error::{FindError, QueryExecutionFail},
transaction::Executable,
transaction::{Executable, WasmSmartContract},
},
};
use iroha_data_model::{events::TriggeringEventFilterBox, transaction::WasmSmartContract};
use iroha_genesis::GenesisNetwork;
use iroha_logger::info;
use test_network::*;
Expand Down Expand Up @@ -124,11 +123,9 @@ fn trigger_failure_should_not_cancel_other_triggers_execution() -> Result<()> {
bad_trigger_instructions,
Repeats::Indefinitely,
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(bad_trigger_id.clone())
.under_authority(account_id.clone()),
),
ExecuteTriggerEventFilter::new()
.for_trigger(bad_trigger_id.clone())
.under_authority(account_id.clone()),
),
));
test_client.submit(register_bad_trigger)?;
Expand All @@ -143,7 +140,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
TriggeringEventFilterBox::Time(TimeEventFilter::new(ExecutionTime::PreCommit)),
TimeEventFilter::new(ExecutionTime::PreCommit),
),
));
test_client.submit_blocking(register_trigger)?;
Expand Down Expand Up @@ -180,11 +177,9 @@ fn trigger_should_not_be_executed_with_zero_repeats_count() -> Result<()> {
trigger_instructions,
Repeats::from(1_u32),
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
));
test_client.submit_blocking(register_trigger)?;
Expand Down Expand Up @@ -245,11 +240,9 @@ fn trigger_should_be_able_to_modify_its_own_repeats_count() -> Result<()> {
trigger_instructions,
Repeats::from(1_u32),
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
));
test_client.submit_blocking(register_trigger)?;
Expand Down Expand Up @@ -289,11 +282,9 @@ fn unregister_trigger() -> Result<()> {
Vec::<InstructionBox>::new(),
Repeats::Indefinitely,
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
);
let register_trigger = Register::trigger(trigger.clone());
Expand Down Expand Up @@ -367,11 +358,9 @@ fn trigger_in_genesis_using_base64() -> Result<()> {
.wrap_err("Can't deserialize wasm using base64")?,
Repeats::Indefinitely,
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id.clone()),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id.clone()),
),
);

Expand Down Expand Up @@ -418,11 +407,9 @@ fn trigger_should_be_able_to_modify_other_trigger() -> Result<()> {
trigger_unregister_instructions,
Repeats::from(1_u32),
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id_unregister.clone())
.under_authority(account_id.clone()),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id_unregister.clone())
.under_authority(account_id.clone()),
),
));
test_client.submit_blocking(register_trigger)?;
Expand All @@ -435,11 +422,9 @@ fn trigger_should_be_able_to_modify_other_trigger() -> Result<()> {
trigger_should_be_unregistered_instructions,
Repeats::from(1_u32),
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id_to_be_unregistered.clone())
.under_authority(account_id),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id_to_be_unregistered.clone())
.under_authority(account_id),
),
));
test_client.submit_blocking(register_trigger)?;
Expand Down Expand Up @@ -480,11 +465,9 @@ fn trigger_burn_repetitions() -> Result<()> {
trigger_instructions,
Repeats::from(1_u32),
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
));
test_client.submit_blocking(register_trigger)?;
Expand Down Expand Up @@ -525,11 +508,9 @@ fn unregistering_one_of_two_triggers_with_identical_wasm_should_not_cause_origin
wasm.clone(),
Repeats::Indefinitely,
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id)
.under_authority(account_id.clone()),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id)
.under_authority(account_id.clone()),
),
)
};
Expand Down Expand Up @@ -567,7 +548,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<TriggeringEventFilterBox>> {
) -> Register<Trigger> {
let trigger_id: TriggerId = TRIGGER_NAME.parse().expect("Valid");

Register::trigger(Trigger::new(
Expand All @@ -576,11 +557,9 @@ fn build_register_trigger_isi(
trigger_instructions,
Repeats::Indefinitely,
asset_id.account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id)
.under_authority(asset_id.account_id),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id)
.under_authority(asset_id.account_id),
),
))
}
12 changes: 3 additions & 9 deletions client/tests/integration/triggers/data_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ fn must_execute_both_triggers() -> Result<()> {
[instruction.clone()],
Repeats::Indefinitely,
account_id.clone(),
TriggeringEventFilterBox::Data(DataEventFilter::Account(
AccountEventFilter::new().for_events(AccountEventSet::Created),
)),
AccountEventFilter::new().for_events(AccountEventSet::Created),
),
));
test_client.submit_blocking(register_trigger)?;
Expand All @@ -36,9 +34,7 @@ fn must_execute_both_triggers() -> Result<()> {
[instruction],
Repeats::Indefinitely,
account_id,
TriggeringEventFilterBox::Data(DataEventFilter::Domain(
DomainEventFilter::new().for_events(DomainEventSet::Created),
)),
DomainEventFilter::new().for_events(DomainEventSet::Created),
),
));
test_client.submit_blocking(register_trigger)?;
Expand Down Expand Up @@ -88,9 +84,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,
TriggeringEventFilterBox::Data(DataEventFilter::Account(
AccountEventFilter::new().for_events(AccountEventSet::Created),
)),
AccountEventFilter::new().for_events(AccountEventSet::Created),
),
));
test_client.submit_blocking(register_trigger)?;
Expand Down
4 changes: 1 addition & 3 deletions client/tests/integration/triggers/event_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ fn test_mint_asset_when_new_asset_definition_created() -> Result<()> {
vec![instruction],
Repeats::Indefinitely,
account_id,
TriggeringEventFilterBox::Data(DataEventFilter::AssetDefinition(
AssetDefinitionEventFilter::new().for_events(AssetDefinitionEventSet::Created),
)),
AssetDefinitionEventFilter::new().for_events(AssetDefinitionEventSet::Created),
),
));
test_client.submit(register_trigger)?;
Expand Down
8 changes: 4 additions & 4 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(),
TriggeringEventFilterBox::Time(TimeEventFilter::new(ExecutionTime::Schedule(schedule))),
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(),
TriggeringEventFilterBox::Time(TimeEventFilter::new(ExecutionTime::Schedule(schedule))),
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(),
TriggeringEventFilterBox::Time(TimeEventFilter::new(ExecutionTime::PreCommit)),
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(),
TriggeringEventFilterBox::Time(TimeEventFilter::new(ExecutionTime::Schedule(schedule))),
TimeEventFilter::new(ExecutionTime::Schedule(schedule)),
),
));
test_client.submit(register_trigger)?;
Expand Down
8 changes: 3 additions & 5 deletions client/tests/integration/triggers/trigger_rollback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ fn failed_trigger_revert() -> Result<()> {
instructions,
Repeats::Indefinitely,
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id),
),
));
let _ = client.submit_blocking(register_trigger);
Expand Down
Binary file modified configs/swarm/executor.wasm
Binary file not shown.
8 changes: 3 additions & 5 deletions core/src/smartcontracts/isi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,9 @@ mod tests {
Vec::<InstructionBox>::new(),
Repeats::Indefinitely,
account_id.clone(),
TriggeringEventFilterBox::ExecuteTrigger(
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(account_id.clone()),
),
ExecuteTriggerEventFilter::new()
.for_trigger(trigger_id.clone())
.under_authority(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::TriggeringEventFilterBox>,
iroha_data_model::trigger::Trigger,
}

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