Skip to content

Commit

Permalink
refactor: unnest integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Marin Veršić <[email protected]>
  • Loading branch information
mversic committed Oct 18, 2024
1 parent 4976419 commit e1bc556
Show file tree
Hide file tree
Showing 51 changed files with 68 additions and 52 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 0 additions & 20 deletions crates/iroha/tests/integration/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/iroha/tests/mod.rs

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
3 changes: 0 additions & 3 deletions crates/iroha_codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,3 @@ parity-scale-codec = { workspace = true }
serde_json = { workspace = true, features = ["std"]}
serde = { workspace = true }
eyre = { workspace = true }

[dev-dependencies]
iroha_test_samples = { workspace = true }
17 changes: 12 additions & 5 deletions crates/iroha_codec/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,22 @@ fn list_types<W: io::Write>(map: &ConverterMap, writer: &mut W) -> Result<()> {
#[cfg(test)]
mod tests {
use iroha_data_model::prelude::*;
use iroha_test_samples::ALICE_ID;

use super::*;

#[test]
fn decode_account_sample() {
let account_id =
"ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
.parse()
.unwrap();
let mut metadata = Metadata::default();
metadata.insert(
"hat".parse().expect("Valid"),
"white".parse::<Json>().expect("Valid"),
);
let account = Account::new(ALICE_ID.clone()).with_metadata(metadata);

let account = Account::new(account_id).with_metadata(metadata);
decode_sample("account.bin", String::from("NewAccount"), &account);
}

Expand All @@ -337,20 +340,24 @@ mod tests {

#[test]
fn decode_trigger_sample() {
let account_id =
"ed0120CE7FA46C9DCE7EA4B125E2E36BDB63EA33073E7590AC92816AE1E861B7048B03@wonderland"
.parse::<AccountId>()
.unwrap();
let rose_definition_id = AssetDefinitionId::new(
"wonderland".parse().expect("Valid"),
"rose".parse().expect("Valid"),
);
let rose_id = AssetId::new(rose_definition_id, ALICE_ID.clone());
let rose_id = AssetId::new(rose_definition_id, account_id.clone());
let trigger_id = "mint_rose".parse().expect("Valid");
let action = Action::new(
vec![Mint::asset_numeric(1u32, rose_id)],
Repeats::Indefinitely,
ALICE_ID.clone(),
account_id,
DomainEventFilter::new().for_events(DomainEventSet::AnyAccount),
);
let trigger = Trigger::new(trigger_id, action);

let trigger = Trigger::new(trigger_id, action);
decode_sample("trigger.bin", String::from("Trigger"), &trigger);
}

Expand Down
9 changes: 4 additions & 5 deletions crates/iroha_core/benches/blocks/apply_blocks.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#[path = "./common/mod.rs"]
mod common;

use common::*;
use eyre::Result;
use iroha_core::{
block::CommittedBlock, prelude::*, state::State, sumeragi::network_topology::Topology,
};
use iroha_data_model::peer::PeerId;
use iroha_test_samples::gen_account_in;

#[path = "./common.rs"]
mod common;

use common::*;

pub struct StateApplyBlocks {
state: State,
blocks: Vec<CommittedBlock>,
Expand Down
File renamed without changes.
9 changes: 4 additions & 5 deletions crates/iroha_core/benches/blocks/validate_blocks.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use iroha_core::{prelude::*, state::State, sumeragi::network_topology::Topology};
use iroha_data_model::{isi::InstructionBox, prelude::*};
use iroha_test_samples::gen_account_in;

#[path = "./common.rs"]
#[path = "./common/mod.rs"]
mod common;

use common::*;
use iroha_core::{prelude::*, state::State, sumeragi::network_topology::Topology};
use iroha_data_model::{isi::InstructionBox, prelude::*};
use iroha_test_samples::gen_account_in;

pub struct StateValidateBlocks {
state: State,
Expand Down
60 changes: 48 additions & 12 deletions crates/iroha_ffi/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,26 @@ pub trait IrTypeFamily {
}

impl<R: Cloned> IrTypeFamily for R {
type Ref<'itm> = &'itm Self where Self: 'itm;
type Ref<'itm>
= &'itm Self
where
Self: 'itm;
// NOTE: Unused
type RefMut<'itm> = () where Self: 'itm;
type RefMut<'itm>
= ()
where
Self: 'itm;
type Box = Box<Self>;
type BoxedSlice = Box<[Self]>;
type RefSlice<'itm> = &'itm [Self] where Self: 'itm;
type RefSlice<'itm>
= &'itm [Self]
where
Self: 'itm;
// NOTE: Unused
type RefMutSlice<'itm> = () where Self: 'itm;
type RefMutSlice<'itm>
= ()
where
Self: 'itm;
type Vec = Vec<Self>;
type Arr<const N: usize> = [Self; N];
}
Expand Down Expand Up @@ -166,22 +178,46 @@ impl IrTypeFamily for Transparent {
type Arr<const N: usize> = Self;
}
impl IrTypeFamily for &Extern {
type Ref<'itm> = &'itm Self where Self: 'itm;
type RefMut<'itm> = &'itm mut Self where Self: 'itm;
type Ref<'itm>
= &'itm Self
where
Self: 'itm;
type RefMut<'itm>
= &'itm mut Self
where
Self: 'itm;
type Box = Box<Self>;
type BoxedSlice = Box<[Self]>;
type RefSlice<'itm> = &'itm [Self] where Self: 'itm;
type RefMutSlice<'itm> = &'itm mut [Self] where Self: 'itm;
type RefSlice<'itm>
= &'itm [Self]
where
Self: 'itm;
type RefMutSlice<'itm>
= &'itm mut [Self]
where
Self: 'itm;
type Vec = Vec<Self>;
type Arr<const N: usize> = [Self; N];
}
impl IrTypeFamily for &mut Extern {
type Ref<'itm> = &'itm Self where Self: 'itm;
type RefMut<'itm> = &'itm mut Self where Self: 'itm;
type Ref<'itm>
= &'itm Self
where
Self: 'itm;
type RefMut<'itm>
= &'itm mut Self
where
Self: 'itm;
type Box = Box<Self>;
type BoxedSlice = Box<[Self]>;
type RefSlice<'itm> = &'itm [Self] where Self: 'itm;
type RefMutSlice<'itm> = &'itm mut [Self] where Self: 'itm;
type RefSlice<'itm>
= &'itm [Self]
where
Self: 'itm;
type RefMutSlice<'itm>
= &'itm mut [Self]
where
Self: 'itm;
type Vec = Vec<Self>;
type Arr<const N: usize> = [Self; N];
}
Expand Down

0 comments on commit e1bc556

Please sign in to comment.