Skip to content

Commit

Permalink
Fix for tests
Browse files Browse the repository at this point in the history
Signed-off-by: s8sato <49983831+s8sato@users.noreply.github.com>
  • Loading branch information
s8sato committed Dec 21, 2021
1 parent 4c413ab commit 8877c65
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions client/tests/integration_tests/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ use tokio::runtime::Runtime;
const BURN_REJECTION_REASON: &str = "Failed to pass first check with Can\'t burn assets from another account. \
and second check with Account does not have the needed permission token: \
PermissionToken { name: \"can_burn_user_assets\", params: {\"asset_id\": Id(AssetId(Id { definition_id: \
DefinitionId { name: \"xor\", domain_name: \"wonderland\" }, account_id: Id { name: \"bob\", domain_name: \"wonderland\" } }))} }..";
DefinitionId { name: \"xor\", domain_id: Id { name: \"wonderland\" } }, account_id: Id { name: \"bob\", domain_id: Id { name: \"wonderland\" } } }))} }..";

const MINT_REJECTION_REASON: &str = "Failed to pass first check with Can\'t transfer assets of the other account. \
and second check with Account does not have the needed permission token: \
PermissionToken { name: \"can_transfer_user_assets\", params: {\"asset_id\": Id(AssetId(Id { definition_id: \
DefinitionId { name: \"xor\", domain_name: \"wonderland\" }, account_id: Id { name: \"bob\", domain_name: \"wonderland\" } }))} }..";
DefinitionId { name: \"xor\", domain_id: Id { name: \"wonderland\" } }, account_id: Id { name: \"bob\", domain_id: Id { name: \"wonderland\" } } }))} }..";

fn get_assets(iroha_client: &mut Client, id: &AccountId) -> Vec<Asset> {
iroha_client
Expand Down
8 changes: 4 additions & 4 deletions core/src/smartcontracts/isi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ mod tests {
let asset_id = AssetId::new(asset_definition_id, account_id.clone());
SetKeyValueBox::new(
IdBox::from(asset_id.clone()),
"Bytes".to_owned(),
Name::test("Bytes"),
vec![1_u32, 2_u32, 3_u32],
)
.execute(account_id, &wsv)?;
Expand All @@ -520,7 +520,7 @@ mod tests {
let account_id = AccountId::test("alice", "wonderland");
SetKeyValueBox::new(
IdBox::from(account_id.clone()),
"Bytes".to_owned(),
Name::test("Bytes"),
vec![1_u32, 2_u32, 3_u32],
)
.execute(account_id.clone(), &wsv)?;
Expand All @@ -545,7 +545,7 @@ mod tests {
let account_id = AccountId::test("alice", "wonderland");
SetKeyValueBox::new(
IdBox::from(definition_id.clone()),
"Bytes".to_owned(),
Name::test("Bytes"),
vec![1_u32, 2_u32, 3_u32],
)
.execute(account_id, &wsv)?;
Expand Down Expand Up @@ -573,7 +573,7 @@ mod tests {
let account_id = AccountId::test("alice", "wonderland");
SetKeyValueBox::new(
IdBox::from(domain_id.clone()),
"Bytes".to_owned(),
Name::test("Bytes"),
vec![1_u32, 2_u32, 3_u32],
)
.execute(account_id, &wsv)?;
Expand Down
2 changes: 1 addition & 1 deletion core/src/smartcontracts/isi/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ mod tests {
)?;
Ok(())
})?;
let bytes = FindAccountKeyValueByIdAndKey::new(ALICE_ID.clone(), "Bytes".to_owned())
let bytes = FindAccountKeyValueByIdAndKey::new(ALICE_ID.clone(), Name::test("Bytes"))
.execute(&wsv)?;
assert_eq!(
bytes,
Expand Down
19 changes: 7 additions & 12 deletions data_model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,7 @@ pub mod transaction;
/// `Name` struct represents type for Iroha Entities names, like [`Domain`](`domain::Domain`)'s name or [`Account`](`account::Account`)'s
/// name.
#[derive(
Debug,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Decode,
Encode,
Deserialize,
Serialize,
IntoSchema,
Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Decode, Encode, Deserialize, Serialize, IntoSchema,
)]
pub struct Name(String);

Expand Down Expand Up @@ -100,6 +89,12 @@ impl str::FromStr for Name {
}
}

impl Debug for Name {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.0)
}
}

impl fmt::Display for Name {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.0)
Expand Down

0 comments on commit 8877c65

Please sign in to comment.