diff --git a/cmd/crates/soroban-test/tests/it/config.rs b/cmd/crates/soroban-test/tests/it/config.rs index dd33713aa1..5704237ed4 100644 --- a/cmd/crates/soroban-test/tests/it/config.rs +++ b/cmd/crates/soroban-test/tests/it/config.rs @@ -42,6 +42,36 @@ fn set_and_remove_network() { }); } +#[test] +fn use_default_futurenet() { + TestEnv::with_default(|sandbox| { + sandbox + .new_assert_cmd("keys") + .args(["generate", "alice", "--network", "futurenet"]) + .assert() + .success(); + let dir = sandbox.dir().join(".soroban").join("network"); + let mut read_dir = std::fs::read_dir(dir).unwrap(); + let file = read_dir.next().unwrap().unwrap(); + assert_eq!(file.file_name().to_str().unwrap(), "futurenet.toml"); + }); +} + +#[test] +fn use_default_testnet() { + TestEnv::with_default(|sandbox| { + sandbox + .new_assert_cmd("keys") + .args(["generate", "alice", "--network", "testnet"]) + .assert() + .success(); + let dir = sandbox.dir().join(".soroban").join("network"); + let mut read_dir = std::fs::read_dir(dir).unwrap(); + let file = read_dir.next().unwrap().unwrap(); + assert_eq!(file.file_name().to_str().unwrap(), "testnet.toml"); + }); +} + fn add_network(sandbox: &TestEnv, name: &str) { sandbox .new_assert_cmd("network") diff --git a/cmd/soroban-cli/src/commands/config/locator.rs b/cmd/soroban-cli/src/commands/config/locator.rs index a5f6b02f17..849ee7a55f 100644 --- a/cmd/soroban-cli/src/commands/config/locator.rs +++ b/cmd/soroban-cli/src/commands/config/locator.rs @@ -204,10 +204,18 @@ impl Args { pub fn read_network(&self, name: &str) -> Result { let res = KeyType::Network.read_with_global(name, &self.local_config()?); if let Err(Error::ConfigMissing(_, _)) = &res { - if name == "futurenet" { - let network = Network::futurenet(); - self.write_network(name, &network)?; - return Ok(network); + match name { + "futurenet" => { + let network = Network::futurenet(); + self.write_network(name, &network)?; + return Ok(network); + } + "testnet" => { + let network = Network::testnet(); + self.write_network(name, &network)?; + return Ok(network); + } + _ => {} } } res diff --git a/cmd/soroban-cli/src/commands/network/mod.rs b/cmd/soroban-cli/src/commands/network/mod.rs index 1184b5b95e..101a2ca89a 100644 --- a/cmd/soroban-cli/src/commands/network/mod.rs +++ b/cmd/soroban-cli/src/commands/network/mod.rs @@ -249,6 +249,12 @@ impl Network { impl Network { pub fn futurenet() -> Self { + Network { + rpc_url: "https://soroban-testnet.stellar.org".to_owned(), + network_passphrase: "Test SDF Network ; September 2015".to_owned(), + } + } + pub fn testnet() -> Self { Network { rpc_url: "https://rpc-futurenet.stellar.org:443".to_owned(), network_passphrase: "Test SDF Future Network ; October 2022".to_owned(),