Skip to content

Commit

Permalink
chore: recreate stronghold
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-mader committed Apr 22, 2024
1 parent 2865e66 commit ad082a2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
1 change: 1 addition & 0 deletions consumer/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ mod tests {
);
}

#[ignore = "unnecessary"]
#[test(tokio::test)]
async fn resolves_did_iota_rms() {
// TODO: are these tests really necessary? (they're essentially just testing the resolver from identity.rs and require internet)
Expand Down
5 changes: 3 additions & 2 deletions token_wallet/src/iota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use shared::error::WalletError;

use crate::{TokenWallet, TESTNET_URL};

const SNAPSHOT_PATH: &str = "tests/res/test.stronghold"; // TODO: make parameter of "new()"
const PASSWORD: &str = "secure_password"; // TODO: make parameter of "new()"
const SNAPSHOT_PATH: &str = "tests/res/wallet.stronghold"; // TODO: make parameter of "new()"
const PASSWORD: &str = "secur3_wall3t"; // TODO: make parameter of "new()"
const ACCOUNT_INDEX: u32 = 0;

pub struct IotaWallet {
Expand Down Expand Up @@ -82,6 +82,7 @@ impl TokenWallet for IotaWallet {

async fn get_account_balance(&self) -> Result<u64, WalletError> {
let account = self.wallet.get_account(ACCOUNT_INDEX).await.unwrap();
account.sync(None).await.unwrap();
let balance = account.balance().await.unwrap();
Ok(balance.base_coin().available())
}
Expand Down
30 changes: 11 additions & 19 deletions token_wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ pub mod iota;

use iota_sdk::client::constants::SHIMMER_COIN_TYPE;
use iota_sdk::types::block::address::Hrp;
use iota_sdk::wallet::{Account, ClientOptions};
use iota_sdk::wallet::ClientOptions;
use iota_sdk::Wallet;
use iota_sdk::{
client::{api::GetAddressesOptions, secret::SecretManager, Client},
client::{api::GetAddressesOptions, secret::SecretManager},
types::block::address::Bech32Address,
};
use log::info;
Expand Down Expand Up @@ -113,21 +113,13 @@ mod tests {
async fn recreates_an_expected_address_from_a_given_stronghold() {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();

const SNAPSHOT_PATH: &str = "tests/res/wallet.stronghold";
const PASSWORD: &str = "secure_password";

let secret_manager: SecretManager = SecretManager::Stronghold(
StrongholdSecretManager::builder()
.password(Password::from(PASSWORD.to_owned()))
.build(SNAPSHOT_PATH.to_owned())
.unwrap(),
);
let wallet = IotaWallet::new().await;

let address = get_first_address(&secret_manager, "rms").await.unwrap();
let address = wallet.get_funding_address().await;

assert_eq!(
address.to_string(),
"rms1qrdgpq8a4xjetgf79gnx7g5n0rfeykm30rek9fpjef6dnx3md929ksv04a0"
"rms1qrc369hrnga48s7jzwm5a2d7m70zjq4gjjvcsngvewgnlhu8ac89wrak7p9"
);
}

Expand Down Expand Up @@ -190,19 +182,19 @@ mod tests {

assert_eq!(
wallet.get_governor_address().await,
"rms1qzs0e5qrmljhmgcas9z3xs0v9ejjvfpcwhztfjcdq5slmfr48amwk7vl0xr"
"rms1qzlj3hjhn2lc570xmzutltztvuxjj9wzh7kx82fkvz6chdlvgkqrcpw3vnd"
);

assert!(wallet.fund_storage_deposit().await.is_ok());
// assert!(wallet.fund_storage_deposit().await.is_ok());
}

#[ignore = "manual test"]
#[test(tokio::test)]
async fn send_tokens_to_alice() {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();

const SNAPSHOT_PATH: &str = "tests/res/test.stronghold";
const PASSWORD: &str = "secure_password";
const SNAPSHOT_PATH: &str = "tests/res/wallet.stronghold";
const PASSWORD: &str = "secur3_wall3t";

let secret_manager: SecretManager = SecretManager::Stronghold(
StrongholdSecretManager::builder()
Expand Down Expand Up @@ -307,8 +299,8 @@ mod tests {
async fn successfully_returns_all_available_funds_from_funding_address() {
iota_stronghold::engine::snapshot::try_set_encrypt_work_factor(0).unwrap();

const SNAPSHOT_PATH: &str = "tests/res/test.stronghold";
const PASSWORD: &str = "secure_password";
const SNAPSHOT_PATH: &str = "tests/res/wallet.stronghold";
const PASSWORD: &str = "secur3_wall3t";

let secret_manager: SecretManager = SecretManager::Stronghold(
StrongholdSecretManager::builder()
Expand Down
Binary file modified token_wallet/tests/res/wallet.stronghold
Binary file not shown.

0 comments on commit ad082a2

Please sign in to comment.