Skip to content

Commit

Permalink
refactor: streamline GenesisBuilder RawGenesisTransaction `Genesi…
Browse files Browse the repository at this point in the history
…sBlock` flow

Signed-off-by: Shunkichi Sato <49983831+s8sato@users.noreply.github.com>
  • Loading branch information
s8sato committed Oct 24, 2024
1 parent 84b56f6 commit 60f6993
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 234 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

18 changes: 6 additions & 12 deletions crates/iroha_core/src/kura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,10 +817,9 @@ mod tests {
use iroha_data_model::{
account::Account,
domain::{Domain, DomainId},
executor::Executor,
isi::Log,
peer::PeerId,
transaction::{TransactionBuilder, WasmSmartContract},
transaction::TransactionBuilder,
ChainId, Level,
};
use iroha_genesis::GenesisBuilder;
Expand Down Expand Up @@ -1111,16 +1110,11 @@ mod tests {
live_query_store,
);

let executor = {
let executor_blob = std::fs::read("../../defaults/executor.wasm").unwrap();
Executor::new(WasmSmartContract::from_compiled(executor_blob))
};
let genesis = GenesisBuilder::default().build_and_sign(
chain_id.clone(),
executor,
topology.as_ref().to_owned(),
&genesis_key_pair,
);
let executor_path = PathBuf::from("../../defaults/executor.wasm").into();
let genesis = GenesisBuilder::new(chain_id.clone(), executor_path)
.set_topology(topology.as_ref().to_owned())
.build_and_sign(&genesis_key_pair)
.expect("genesis block should be built");

{
let mut state_block = state.block(genesis.0.header());
Expand Down
8 changes: 8 additions & 0 deletions crates/iroha_data_model/src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,14 @@ impl Default for SmartContractParameters {
}
}

impl Extend<Parameter> for Parameters {
fn extend<T: IntoIterator<Item = Parameter>>(&mut self, iter: T) {
for parameter in iter {
self.set_parameter(parameter);
}
}
}

impl Parameters {
/// Convert [`Self`] into iterator of individual parameters
pub fn parameters(&self) -> impl Iterator<Item = Parameter> + '_ {
Expand Down
2 changes: 2 additions & 0 deletions crates/iroha_genesis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ parity-scale-codec = { workspace = true }
[dev-dependencies]
iroha_crypto = { workspace = true, features = ["rand"] }
iroha_test_samples = { workspace = true }

tempfile = { workspace = true }
Loading

0 comments on commit 60f6993

Please sign in to comment.