Skip to content

Commit 473b2fc

Browse files
committed
add unitest
1 parent 9eb1694 commit 473b2fc

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

examples/wallets/src/lib.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,31 @@ mod tests {
115115
Ok(())
116116
}
117117

118+
119+
#[tokio::test]
120+
async fn create_and_store_mnemonic_wallet_with_address_named_keystore() -> Result<()> {
121+
// ANCHOR: create_and_store_mnemonic_wallet_with_address_named_keystore
122+
use fuels::prelude::*;
123+
124+
let dir = std::env::temp_dir();
125+
126+
let phrase =
127+
"oblige salon price punch saddle immune slogan rare snap desert retire surprise";
128+
129+
// Use the test helper to setup a test provider.
130+
let provider = setup_test_provider(vec![], vec![], None, None).await?;
131+
132+
// Create first account from mnemonic phrase.
133+
let wallet = WalletUnlocked::new_from_mnemonic_phrase(phrase, Some(provider))?;
134+
135+
let password = "my_master_password";
136+
137+
// Encrypts and stores it on disk. Can be recovered using `Wallet::load_keystore`.
138+
let _uuid = wallet.encrypt_with_name(&dir, password, wallet.clone().address())?;
139+
// ANCHOR_END: create_and_store_mnemonic_wallet_with_address_named_keystore
140+
Ok(())
141+
}
142+
118143
#[tokio::test]
119144
async fn wallet_transfer() -> Result<()> {
120145
// ANCHOR: wallet_transfer

0 commit comments

Comments
 (0)