summaryrefslogtreecommitdiff
path: root/impls/monero.rs/tests
diff options
context:
space:
mode:
authorsneurlax <sneurlax@gmail.com>2024-10-16 22:13:29 -0500
committersneurlax <sneurlax@gmail.com>2024-10-16 22:13:29 -0500
commit7a90b8ffbcfd812c2fb2df83b66450522903d1cc (patch)
treeea441f22ea17b51d073f2f44c0ad80f4424489c3 /impls/monero.rs/tests
parentff39a2876b6708dafefe84d6a04237fa13b64303 (diff)
add get_balance
Diffstat (limited to 'impls/monero.rs/tests')
-rw-r--r--impls/monero.rs/tests/integration_tests.rs44
1 files changed, 39 insertions, 5 deletions
diff --git a/impls/monero.rs/tests/integration_tests.rs b/impls/monero.rs/tests/integration_tests.rs
index 6aeeab0..ec7cae2 100644
--- a/impls/monero.rs/tests/integration_tests.rs
+++ b/impls/monero.rs/tests/integration_tests.rs
@@ -88,7 +88,7 @@ fn test_wallet_manager_creation() {
let wallet_path = temp_dir.path().join("test_wallet");
let wallet_str = wallet_path.to_str().expect("Failed to convert wallet path to string");
- let wallet_result = manager.create_wallet(wallet_str, "password123", "English", NetworkType::Mainnet);
+ let wallet_result = manager.create_wallet(wallet_str, "password", "English", NetworkType::Mainnet);
assert!(wallet_result.is_ok(), "WalletManager creation seems to have failed");
teardown(&temp_dir).expect("Failed to clean up after test");
@@ -119,7 +119,7 @@ fn test_get_seed() {
let wallet_str = wallet_path.to_str().expect("Failed to convert wallet path to string");
let wallet = manager
- .create_wallet(wallet_str, "password123", "English", NetworkType::Mainnet)
+ .create_wallet(wallet_str, "password", "English", NetworkType::Mainnet)
.expect("Failed to create wallet");
// Test getting seed without offset.
@@ -151,7 +151,7 @@ fn test_get_address() {
let wallet_str = wallet_path.to_str().expect("Failed to convert wallet path to string");
let wallet = manager
- .create_wallet(wallet_str, "password123", "English", NetworkType::Mainnet)
+ .create_wallet(wallet_str, "password", "English", NetworkType::Mainnet)
.expect("Failed to create wallet");
println!("Attempting to get address...");
let start = Instant::now();
@@ -173,7 +173,7 @@ fn test_is_deterministic() {
let wallet_str = wallet_path.to_str().expect("Failed to convert wallet path to string");
let wallet = manager
- .create_wallet(wallet_str, "password123", "English", NetworkType::Mainnet)
+ .create_wallet(wallet_str, "password", "English", NetworkType::Mainnet)
.expect("Failed to create wallet");
println!("Checking if wallet is deterministic...");
let start = Instant::now();
@@ -221,7 +221,7 @@ fn test_multiple_address_generation() {
let wallet_str = wallet_path.to_str().expect("Failed to convert wallet path to string");
let wallet = manager
- .create_wallet(wallet_str, "password123", "English", NetworkType::Mainnet)
+ .create_wallet(wallet_str, "password", "English", NetworkType::Mainnet)
.expect("Failed to create wallet");
for i in 0..5 {
@@ -305,3 +305,37 @@ fn test_open_wallet_integration() {
// Clean up.
teardown(&temp_dir).expect("Failed to clean up after test");
}
+
+#[test]
+fn test_get_balance_integration() {
+ println!("Running test_get_balance_integration");
+ let (manager, temp_dir) = setup().expect("Failed to set up test environment");
+
+ // Construct the full path for the wallet within temp_dir.
+ let wallet_path = temp_dir.path().join("test_wallet");
+ let wallet_str = wallet_path.to_str().expect("Failed to convert wallet path to string");
+
+ // Create the wallet.
+ let wallet = manager
+ .create_wallet(wallet_str, "password", "English", NetworkType::Mainnet)
+ .expect("Failed to create wallet");
+
+ // Fetch the balance.
+ println!("Fetching wallet balance...");
+ let start = Instant::now();
+ let balance_result = wallet.get_balance(0); // Account index 0
+ println!("Fetching balance took {:?}", start.elapsed());
+
+ assert!(balance_result.is_ok(), "Failed to fetch balance: {:?}", balance_result.err());
+
+ let balance = balance_result.unwrap();
+ println!("Balance: {:?}", balance);
+
+ // Ensure the balance values make sense.
+ // assert!(balance.balance >= 0, "Balance should be non-negative");
+ // assert!(balance.unlocked_balance >= 0, "Unlocked balance should be non-negative");
+ // These assertions are meaningless with the constraints of the type.
+ // TODO: Test with scanning integration.
+
+ teardown(&temp_dir).expect("Failed to clean up after test");
+}