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: unnest integration tests #5169

Merged
merged 1 commit into from
Oct 21, 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@
- hyperledger#1998 Add filters to queries.
- hyperledger#2276 Include current Block hash into BlockHeaderValue.
- hyperledger#2161 Handle id and shared FFI fns.
- add handle id and implement FFI equivalents of shared traits (Clone, Eq, Ord)
- add handle id and implement FFI equivalents of shared traits (Clone, Eq, Ord)
- hyperledger#1638 `configuration` return doc sub-tree.
- hyperledger#2132 Add `endpointN` proc macro.
- hyperledger#2257 Revoke<Role> emits RoleRevoked event.
Expand Down
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.
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.
Empty file.
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.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
8 changes: 5 additions & 3 deletions crates/iroha_core/benches/blocks/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ use iroha_data_model::{
ChainId,
};
use iroha_executor_data_model::permission::{
account::CanUnregisterAccount, asset_definition::CanUnregisterAssetDefinition,
domain::CanUnregisterDomain,
account::CanUnregisterAccount,
asset_definition::CanUnregisterAssetDefinition,
domain::{CanRegisterDomain, CanUnregisterDomain},
};

/// Create block
Expand Down Expand Up @@ -75,7 +76,8 @@ pub fn populate_state(
asset_definitions: &[AssetDefinitionId],
owner_id: &AccountId,
) -> Vec<InstructionBox> {
let mut instructions: Vec<InstructionBox> = Vec::new();
let mut instructions: Vec<InstructionBox> =
vec![Grant::account_permission(CanRegisterDomain, owner_id.clone()).into()];

for domain_id in domains {
let domain = Domain::new(domain_id.clone());
Expand Down
7 changes: 3 additions & 4 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"]
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
12 changes: 7 additions & 5 deletions crates/iroha_core/benches/kura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ async fn measure_block_size_for_n_executors(n_executors: u32) {
};
let tx = AcceptedTransaction::accept(tx, &chain_id, max_clock_drift, tx_limits)
.expect("Failed to accept Transaction.");
let (peer_public_key, peer_private_key) = KeyPair::random().into_parts();
let peer_id = PeerId::new("127.0.0.1:8080".parse().unwrap(), peer_public_key);
let peer_key_pair = KeyPair::random();
let peer_id = PeerId::new(
"127.0.0.1:8080".parse().unwrap(),
peer_key_pair.public_key().clone(),
);
let topology = Topology::new(vec![peer_id]);
let mut block = {
let unverified_block = BlockBuilder::new(vec![tx])
.chain(0, state.view().latest_block().as_deref())
.sign(&peer_private_key)
.sign(peer_key_pair.private_key())
.unpack(|_| {});

let mut state_block = state.block(unverified_block.header());
Expand All @@ -64,9 +67,8 @@ async fn measure_block_size_for_n_executors(n_executors: u32) {
block
};

let key_pair = KeyPair::random();
for _ in 1..n_executors {
block.sign(&key_pair, &topology);
block.sign(&peer_key_pair, &topology);
}
let mut block_store = BlockStore::new(dir.path());
block_store.create_files_if_they_do_not_exist().unwrap();
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
12 changes: 0 additions & 12 deletions gitchangelog-clean.py
mversic marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

Loading