(feature: &str)
| 202 | #[cfg(test)] |
| 203 | #[allow(dead_code)] |
| 204 | fn basic_wallet_ops(feature: &str) { |
| 205 | // Create a temporary directory for testing env |
| 206 | let mut test_dir = std::env::current_dir().unwrap(); |
| 207 | test_dir.push("bdk-testing"); |
| 208 | |
| 209 | let test_dir = temp_dir(); |
| 210 | // let test_dir = test_temp_dir.into_path().to_path_buf(); |
| 211 | |
| 212 | // Create bdk-cli instance |
| 213 | let bdk_cli = BdkCli::new("regtest", Some(test_dir), false, &[feature]).unwrap(); |
| 214 | |
| 215 | // Generate 101 blocks |
| 216 | bdk_cli.node_exec(&["generate", "101"]).unwrap(); |
| 217 | |
| 218 | // Get a bdk address |
| 219 | let bdk_addr_json = bdk_cli.wallet_exec(&["get_new_address"]).unwrap(); |
| 220 | let bdk_addr = get_value(&bdk_addr_json, "address").unwrap(); |
| 221 | |
| 222 | // Send coins from core to bdk |
| 223 | bdk_cli |
| 224 | .node_exec(&["sendtoaddress", &bdk_addr, "1000000000"]) |
| 225 | .unwrap(); |
| 226 | |
| 227 | bdk_cli.node_exec(&["generate", "1"]).unwrap(); |
| 228 | |
| 229 | // Sync the bdk wallet |
| 230 | bdk_cli.wallet_exec(&["sync"]).unwrap(); |
| 231 | |
| 232 | // Get the balance |
| 233 | let balance_json = bdk_cli.wallet_exec(&["get_balance"]).unwrap(); |
| 234 | let confirmed_balance = balance_json |
| 235 | .as_object() |
| 236 | .unwrap() |
| 237 | .get("satoshi") |
| 238 | .unwrap() |
| 239 | .as_object() |
| 240 | .unwrap() |
| 241 | .get("confirmed") |
| 242 | .unwrap() |
| 243 | .as_u64() |
| 244 | .unwrap(); |
| 245 | assert_eq!(confirmed_balance, 1000000000u64); |
| 246 | } |
| 247 | |
| 248 | // #[test] |
| 249 | // #[cfg(feature = "regtest-bitcoin")] |
nothing calls this directly
no test coverage detected