Skip to content

Commit 6043f0f

Browse files
authored
Stop reading from local config directory. (#2500)
1 parent bed9f6e commit 6043f0f

4 files changed

Lines changed: 279 additions & 32 deletions

File tree

cmd/crates/soroban-test/tests/it/config.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ fn multiple_networks() {
105105
#[test]
106106
fn read_key() {
107107
let sandbox = TestEnv::default();
108-
let dir = sandbox.dir().as_ref();
109-
add_test_id(dir);
110-
let ident_dir = dir.join(".soroban/identity");
108+
let config_dir = sandbox.config_dir();
109+
add_test_id(&config_dir);
110+
let ident_dir = config_dir.join("identity");
111111
assert!(ident_dir.exists());
112112
sandbox
113113
.new_assert_cmd("keys")
@@ -179,17 +179,16 @@ fn generate_key_on_testnet() {
179179
#[test]
180180
fn seed_phrase() {
181181
let sandbox = TestEnv::default();
182-
let dir = sandbox.dir();
182+
let config_dir = sandbox.config_dir();
183183
add_key(
184-
dir,
184+
&config_dir,
185185
"test_seed",
186186
SecretKind::Seed,
187187
"one two three four five six seven eight nine ten eleven twelve",
188188
);
189189

190190
sandbox
191191
.new_assert_cmd("keys")
192-
.current_dir(dir)
193192
.arg("ls")
194193
.assert()
195194
.stdout(predicates::str::contains("test_seed\n"));

cmd/crates/soroban-test/tests/it/util.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ pub fn add_key(dir: &Path, name: &str, kind: SecretKind, data: &str) {
2424
},
2525
};
2626

27-
KeyType::Identity
28-
.write(name, &secret, &dir.join(".soroban"))
29-
.unwrap();
27+
KeyType::Identity.write(name, &secret, dir).unwrap();
3028
}
3129

3230
pub fn add_test_id(dir: &Path) -> String {

cmd/soroban-cli/src/commands/contract/alias/ls.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,19 @@ impl Cmd {
4545

4646
for cfg in config_dirs {
4747
match cfg {
48-
Location::Local(config_dir) => Self::read_from_config_dir(&config_dir, true)?,
49-
Location::Global(config_dir) => Self::read_from_config_dir(&config_dir, false)?,
48+
Location::Local(config_dir) => {
49+
if config_dir.exists() {
50+
print_deprecation_warning(&config_dir);
51+
}
52+
}
53+
Location::Global(config_dir) => Self::read_from_config_dir(&config_dir)?,
5054
}
5155
}
5256

5357
Ok(())
5458
}
5559

56-
fn read_from_config_dir(config_dir: &Path, deprecation_mode: bool) -> Result<(), Error> {
60+
fn read_from_config_dir(config_dir: &Path) -> Result<(), Error> {
5761
let pattern = config_dir
5862
.join("contract-ids")
5963
.join("*.json")
@@ -98,9 +102,6 @@ impl Cmd {
98102
list.sort_by(|a, b| a.alias.cmp(&b.alias));
99103

100104
for entry in list {
101-
if !found && deprecation_mode {
102-
print_deprecation_warning(config_dir);
103-
}
104105
found = true;
105106
println!("{}: {}", entry.alias, entry.contract);
106107
}
@@ -109,7 +110,7 @@ impl Cmd {
109110
}
110111
}
111112

112-
if !found && !deprecation_mode {
113+
if !found {
113114
eprintln!("⚠️ No aliases defined for network");
114115

115116
process::exit(1);

0 commit comments

Comments
 (0)