test-validator: use ADDRESS from account flag
This commit is contained in:
parent
27cee7a7de
commit
4f71ae6102
|
@ -61,7 +61,7 @@ use {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct AccountInfo<'a> {
|
||||
pub address: Pubkey,
|
||||
pub address: Option<Pubkey>,
|
||||
pub filename: &'a str,
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,10 @@ impl TestValidatorGenesis {
|
|||
}
|
||||
Ok(deserialized) => deserialized,
|
||||
};
|
||||
let address = Pubkey::from_str(account_info.keyed_account.pubkey.as_str()).unwrap();
|
||||
|
||||
let address = account.address.unwrap_or_else(|| {
|
||||
Pubkey::from_str(account_info.keyed_account.pubkey.as_str()).unwrap()
|
||||
});
|
||||
let account = account_info
|
||||
.keyed_account
|
||||
.account
|
||||
|
|
|
@ -209,10 +209,12 @@ fn main() {
|
|||
.value_name("ADDRESS FILENAME.JSON")
|
||||
.takes_value(true)
|
||||
.number_of_values(2)
|
||||
.allow_hyphen_values(true)
|
||||
.multiple(true)
|
||||
.help(
|
||||
"Load an account from the provided JSON file (see `solana account --help` on how to dump \
|
||||
an account to file). Files are searched for relatively to CWD and tests/fixtures. \
|
||||
If ADDRESS is omitted via the `-` placeholder, the one in the file will be used. \
|
||||
If the ledger already exists then this parameter is silently ignored",
|
||||
),
|
||||
)
|
||||
|
@ -549,10 +551,14 @@ fn main() {
|
|||
for address_filename in values.chunks(2) {
|
||||
match address_filename {
|
||||
[address, filename] => {
|
||||
let address = address.parse::<Pubkey>().unwrap_or_else(|err| {
|
||||
println!("Error: invalid address {}: {}", address, err);
|
||||
exit(1);
|
||||
});
|
||||
let address = if *address == "-" {
|
||||
None
|
||||
} else {
|
||||
Some(address.parse::<Pubkey>().unwrap_or_else(|err| {
|
||||
println!("Error: invalid address {}: {}", address, err);
|
||||
exit(1);
|
||||
}))
|
||||
};
|
||||
|
||||
accounts_to_load.push(AccountInfo { address, filename });
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue