-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Shanin Roman <[email protected]>
- Loading branch information
Showing
4 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ mod by_call_trigger; | |
mod data_trigger; | ||
mod event_trigger; | ||
mod time_trigger; | ||
mod trigger_rollback; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use std::str::FromStr as _; | ||
|
||
use eyre::Result; | ||
use iroha_client::client::QueryResult; | ||
use iroha_data_model::{prelude::*, query::asset::FindAllAssetsDefinitions, trigger::TriggerId}; | ||
use test_network::*; | ||
|
||
#[test] | ||
fn failed_trigger_revert() -> Result<()> { | ||
let (_rt, _peer, client) = <PeerBuilder>::new().with_port(11_110).start_with_runtime(); | ||
wait_for_genesis_committed(&[client.clone()], 0); | ||
|
||
//When | ||
let trigger_id = TriggerId::from_str("trigger")?; | ||
let account_id = AccountId::from_str("alice@wonderland")?; | ||
let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland")?; | ||
let create_asset = RegisterExpr::new(AssetDefinition::quantity(asset_definition_id.clone())); | ||
let instructions: [InstructionExpr; 2] = [create_asset.into(), Fail::new("Always fail").into()]; | ||
let register_trigger = RegisterExpr::new(Trigger::new( | ||
trigger_id.clone(), | ||
Action::new( | ||
instructions, | ||
Repeats::Indefinitely, | ||
account_id.clone(), | ||
TriggeringFilterBox::ExecuteTrigger(ExecuteTriggerEventFilter::new( | ||
trigger_id.clone(), | ||
account_id, | ||
)), | ||
), | ||
)); | ||
let _ = client.submit_blocking(register_trigger); | ||
|
||
let call_trigger = ExecuteTriggerExpr::new(trigger_id); | ||
client.submit_blocking(call_trigger)?; | ||
|
||
//Then | ||
let request = FindAllAssetsDefinitions; | ||
let query_result = client.request(request)?.collect::<QueryResult<Vec<_>>>()?; | ||
assert!(query_result | ||
.iter() | ||
.all(|asset_definition| asset_definition.id() != &asset_definition_id)); | ||
Ok(()) | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters