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] #2001: EvaluatesTo static type checking #2582

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/src/torii/mod.rs
Expand Up @@ -124,7 +124,7 @@ impl Error {
Config(_) => StatusCode::NOT_FOUND,
PushIntoQueue(err) => match **err {
queue::Error::Full => StatusCode::INTERNAL_SERVER_ERROR,
queue::Error::SignatureCondition(_) => StatusCode::UNAUTHORIZED,
queue::Error::SignatureCondition { .. } => StatusCode::UNAUTHORIZED,
_ => StatusCode::BAD_REQUEST,
},
#[cfg(feature = "telemetry")]
Expand Down
11 changes: 6 additions & 5 deletions client/benches/tps/lib.rs
Expand Up @@ -215,11 +215,12 @@ impl MeasurerUnit {
}

fn mint_or_burn(&self) -> Instruction {
let is_running_out: Expression = Less::new(
Expression::Query(FindAssetQuantityById::new(asset_id(self.name)).into()),
Value::U32(100),
)
.into();
let is_running_out = Less::new(
EvaluatesTo::new_unchecked(
Expression::Query(FindAssetQuantityById::new(asset_id(self.name)).into()).into(),
),
100_u32,
);
let supply_roses = MintBox::new(Value::U32(100), asset_id(self.name));
let burn_a_rose = BurnBox::new(Value::U32(1), asset_id(self.name));

Expand Down
11 changes: 6 additions & 5 deletions client/tests/integration/multisignature_transaction.rs
Expand Up @@ -5,13 +5,14 @@ use std::{str::FromStr as _, thread, time::Duration};
use iroha_client::client::{self, Client};
use iroha_config::client::Configuration as ClientConfiguration;
use iroha_core::prelude::*;
use iroha_data_model::{account::TRANSACTION_SIGNATORIES_VALUE, prelude::*};
use iroha_data_model::{account::TRANSACTION_SIGNATORIES_VALUE, prelude::*, val_vec};
use iroha_primitives::small::SmallStr;
use test_network::*;

use super::Configuration;

#[allow(clippy::too_many_lines)]
#[ignore = "Multisignature is not working for now. See #2595"]
Arjentix marked this conversation as resolved.
Show resolved Hide resolved
#[test]
fn multisignature_transactions_should_wait_for_all_signatures() {
let (_rt, network, _) = <Network>::start_test_with_runtime(4, 1);
Expand All @@ -24,16 +25,16 @@ fn multisignature_transactions_should_wait_for_all_signatures() {
let asset_definition_id = AssetDefinitionId::from_str("camomile#wonderland").expect("Valid");
let create_asset = RegisterBox::new(AssetDefinition::quantity(asset_definition_id.clone()));
let set_signature_condition = MintBox::new(
SignatureCheckCondition(
SignatureCheckCondition(EvaluatesTo::new_unchecked(
ContainsAll::new(
ContextValue::new(TRANSACTION_SIGNATORIES_VALUE),
vec![
EvaluatesTo::new_unchecked(ContextValue::new(TRANSACTION_SIGNATORIES_VALUE).into()),
val_vec![
alice_key_pair.public_key().clone(),
key_pair_2.public_key().clone(),
],
)
.into(),
),
)),
IdBox::AccountId(alice_id.clone()),
);

Expand Down
3 changes: 1 addition & 2 deletions client/tests/integration/permissions.rs
Expand Up @@ -120,8 +120,7 @@ fn permissions_disallow_asset_burn() {
let alice_id = "alice@wonderland".parse().expect("Valid");
let bob_id: <Account as Identifiable>::Id = "bob@wonderland".parse().expect("Valid");
let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid");
let create_asset =
RegisterBox::new(AssetDefinition::quantity(asset_definition_id.clone()).build());
let create_asset = RegisterBox::new(AssetDefinition::quantity(asset_definition_id.clone()));
let register_bob = RegisterBox::new(Account::new(bob_id.clone(), []));

let alice_start_assets = get_assets(&mut iroha_client, &alice_id);
Expand Down
12 changes: 9 additions & 3 deletions client_cli/src/main.rs
Expand Up @@ -385,7 +385,9 @@ mod account {
let file = File::open(s).wrap_err(err_msg)?;
let condition: Box<Expression> =
serde_json::from_reader(file).wrap_err(deser_err_msg)?;
Ok(Self(SignatureCheckCondition(condition.into())))
Ok(Self(SignatureCheckCondition(EvaluatesTo::new_unchecked(
condition,
))))
}
}

Expand All @@ -406,8 +408,12 @@ mod account {
condition: Signature(condition),
metadata: Metadata(metadata),
} = self;
submit(MintBox::new(account, condition), cfg, metadata)
.wrap_err("Failed to set signature condition")
submit(
MintBox::new(account, EvaluatesTo::new_unchecked(condition.into())),
cfg,
metadata,
)
.wrap_err("Failed to set signature condition")
}
}

Expand Down
22 changes: 17 additions & 5 deletions core/src/genesis.rs
Expand Up @@ -381,9 +381,10 @@ impl RawGenesisDomainBuilder {
/// Should only be used for testing.
#[must_use]
pub fn with_account_without_public_key(mut self, account_name: Name) -> Self {
let account_id = AccountId::new(account_name, self.domain_id.clone());
self.transaction
.isi
.push(RegisterBox::new(AccountId::new(account_name, self.domain_id.clone())).into());
.push(RegisterBox::new(Account::new(account_id, [])).into());
self
}

Expand Down Expand Up @@ -465,12 +466,19 @@ mod tests {
);
assert_eq!(
finished_genesis_block.transactions[0].isi[1],
RegisterBox::new(AccountId::new("alice".parse().unwrap(), domain_id.clone()))
.into()
RegisterBox::new(Account::new(
AccountId::new("alice".parse().unwrap(), domain_id.clone()),
[]
))
.into()
);
assert_eq!(
finished_genesis_block.transactions[0].isi[2],
RegisterBox::new(AccountId::new("bob".parse().unwrap(), domain_id)).into()
RegisterBox::new(Account::new(
AccountId::new("bob".parse().unwrap(), domain_id),
[]
))
.into()
);
}
{
Expand All @@ -481,7 +489,11 @@ mod tests {
);
assert_eq!(
finished_genesis_block.transactions[0].isi[4],
RegisterBox::new(AccountId::new("Cheshire_Cat".parse().unwrap(), domain_id)).into()
RegisterBox::new(Account::new(
AccountId::new("Cheshire_Cat".parse().unwrap(), domain_id),
[]
))
.into()
);
}
{
Expand Down