Skip to content

Commit

Permalink
Small fixes to test and imports (#857)
Browse files Browse the repository at this point in the history
* fixes and some test changes

* idk

* my reset of test

* fmt

* Apply suggestions from code review

Co-authored-by: Thoralf-M <[email protected]>

* updated cost

---------

Co-authored-by: Thibault Martinez <[email protected]>
Co-authored-by: Thoralf-M <[email protected]>
  • Loading branch information
3 people authored Jul 24, 2023
1 parent a3f31af commit cc28bfd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
3 changes: 1 addition & 2 deletions sdk/src/wallet/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,8 @@ pub(crate) mod dto {
use serde::Deserialize;

use super::*;
use crate::client::secret::SecretManage;
#[cfg(feature = "storage")]
use crate::wallet::storage::StorageOptions;
use crate::{client::secret::SecretManage, wallet::storage::StorageOptions};

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down
1 change: 1 addition & 0 deletions sdk/tests/client/addresses.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "stronghold")]
use crypto::keys::bip39::Mnemonic;
#[cfg(feature = "stronghold")]
use iota_sdk::client::secret::stronghold::StrongholdSecretManager;
Expand Down
8 changes: 5 additions & 3 deletions sdk/tests/wallet/address_generation.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

#[cfg(feature = "ledger_nano")]
use std::sync::{Arc, Mutex};

#[cfg(feature = "stronghold")]
use crypto::keys::bip39::Mnemonic;
#[cfg(feature = "ledger_nano")]
use iota_sdk::client::secret::ledger_nano::LedgerSecretManager;
#[cfg(feature = "stronghold")]
use iota_sdk::client::secret::stronghold::StrongholdSecretManager;
#[cfg(feature = "ledger_nano")]
use iota_sdk::client::secret::{ledger_nano::LedgerSecretManager, GenerateAddressOptions};
#[cfg(feature = "events")]
use iota_sdk::wallet::events::{WalletEvent, WalletEventType};
use iota_sdk::{
client::{
constants::IOTA_COIN_TYPE,
secret::{mnemonic::MnemonicSecretManager, GenerateAddressOptions, SecretManager},
secret::{mnemonic::MnemonicSecretManager, SecretManager},
Error as ClientError,
},
types::block::address::ToBech32Ext,
Expand Down
41 changes: 24 additions & 17 deletions sdk/tests/wallet/output_preparation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async fn output_preparation() -> Result<()> {
assets: None,
features: Some(Features {
metadata: Some(prefix_hex::encode(b"Hello world")),
tag: None,
tag: Some(prefix_hex::encode(b"My Tag")),
issuer: None,
sender: None,
}),
Expand All @@ -112,8 +112,8 @@ async fn output_preparation() -> Result<()> {
assert_eq!(output.amount(), 300000);
// only address condition
assert_eq!(output.unlock_conditions().unwrap().len(), 1);
// metadata feature
assert_eq!(output.features().unwrap().len(), 1);
// metadata and tag features
assert_eq!(output.features().unwrap().len(), 2);

// only send 1 with metadata feature
let output = account
Expand All @@ -124,7 +124,7 @@ async fn output_preparation() -> Result<()> {
assets: None,
features: Some(Features {
metadata: Some(prefix_hex::encode(b"Hello world")),
tag: None,
tag: Some(prefix_hex::encode(b"My Tag")),
issuer: None,
sender: None,
}),
Expand All @@ -134,15 +134,15 @@ async fn output_preparation() -> Result<()> {
None,
)
.await?;
assert_eq!(output.amount(), 48200);
assert_eq!(output.amount(), 49000);
let unlock_conditions = output.unlock_conditions().unwrap();
// address + sdr
assert_eq!(unlock_conditions.len(), 2);
let storage_deposit_return = unlock_conditions.storage_deposit_return().unwrap();
// output amount -1
assert_eq!(storage_deposit_return.amount(), 48199);
// metadata feature
assert_eq!(output.features().unwrap().len(), 1);
assert_eq!(storage_deposit_return.amount(), 48999);
// metadata and tag features
assert_eq!(output.features().unwrap().len(), 2);

let output = account
.prepare_output(
Expand All @@ -152,7 +152,7 @@ async fn output_preparation() -> Result<()> {
assets: None,
features: Some(Features {
metadata: Some(prefix_hex::encode(b"Hello world")),
tag: None,
tag: Some(prefix_hex::encode(b"My Tag")),
issuer: None,
sender: None,
}),
Expand All @@ -166,8 +166,8 @@ async fn output_preparation() -> Result<()> {
// address and storage deposit unlock condition, because of the metadata feature block, 12000 is not enough for the
// required storage deposit
assert_eq!(output.unlock_conditions().unwrap().len(), 2);
// metadata feature
assert_eq!(output.features().unwrap().len(), 1);
// metadata and tag features
assert_eq!(output.features().unwrap().len(), 2);

let output = account
.prepare_output(
Expand All @@ -177,7 +177,7 @@ async fn output_preparation() -> Result<()> {
assets: None,
features: Some(Features {
metadata: Some(prefix_hex::encode(b"Hello world")),
tag: None,
tag: Some(prefix_hex::encode(b"My Tag")),
issuer: None,
sender: None,
}),
Expand All @@ -187,15 +187,15 @@ async fn output_preparation() -> Result<()> {
None,
)
.await?;
assert_eq!(output.amount(), 48200);
assert_eq!(output.amount(), 49000);
let sdr = output.unlock_conditions().unwrap().storage_deposit_return().unwrap();
assert_eq!(sdr.amount(), 48199);
assert_eq!(sdr.amount(), 48999);

// address and storage deposit unlock condition, because of the metadata feature block, 213000 is not enough for the
// required storage deposit
assert_eq!(output.unlock_conditions().unwrap().len(), 2);
// metadata feature
assert_eq!(output.features().unwrap().len(), 1);
// metadata and tag features
assert_eq!(output.features().unwrap().len(), 2);

// Error if this NftId is not in the account
let error = account
Expand Down Expand Up @@ -328,7 +328,10 @@ async fn output_preparation() -> Result<()> {
issuer: Some(issuer_and_sender_address),
sender: Some(issuer_and_sender_address),
}),
unlocks: None,
unlocks: Some(Unlocks {
expiration_unix_time: Some(1),
timelock_unix_time: Some(1),
}),
storage_deposit: None,
},
None,
Expand All @@ -346,6 +349,10 @@ async fn output_preparation() -> Result<()> {
assert_eq!(issuer_feature.address(), issuer_and_sender_address.inner());
let sender_feature = features.sender().unwrap();
assert_eq!(sender_feature.address(), issuer_and_sender_address.inner());
// Unlocks
let conditions = output.unlock_conditions().unwrap();
assert!(conditions.is_time_locked(0));
assert!(conditions.is_expired(2));

// nft with expiration
let output = account
Expand Down

0 comments on commit cc28bfd

Please sign in to comment.