[solana-test-validator] add support for keypair file parsing for --bpf-program address argument (#20962)
(cherry picked from commit 58aa2b964b
)
Co-authored-by: Paul Schaaf <paulsimonschaaf@gmail.com>
This commit is contained in:
@ -155,13 +155,14 @@ fn main() {
|
|||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("bpf_program")
|
Arg::with_name("bpf_program")
|
||||||
.long("bpf-program")
|
.long("bpf-program")
|
||||||
.value_name("ADDRESS BPF_PROGRAM.SO")
|
.value_name("ADDRESS_OR_PATH BPF_PROGRAM.SO")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.number_of_values(2)
|
.number_of_values(2)
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.help(
|
.help(
|
||||||
"Add a BPF program to the genesis configuration. \
|
"Add a BPF program to the genesis configuration. \
|
||||||
If the ledger already exists then this parameter is silently ignored",
|
If the ledger already exists then this parameter is silently ignored. \
|
||||||
|
First argument can be a public key or path to file that can be parsed as a keypair",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
@ -403,10 +404,13 @@ fn main() {
|
|||||||
for address_program in values.chunks(2) {
|
for address_program in values.chunks(2) {
|
||||||
match address_program {
|
match address_program {
|
||||||
[address, program] => {
|
[address, program] => {
|
||||||
let address = address.parse::<Pubkey>().unwrap_or_else(|err| {
|
let address = address
|
||||||
println!("Error: invalid address {}: {}", address, err);
|
.parse::<Pubkey>()
|
||||||
exit(1);
|
.or_else(|_| read_keypair_file(address).map(|keypair| keypair.pubkey()))
|
||||||
});
|
.unwrap_or_else(|err| {
|
||||||
|
println!("Error: invalid address {}: {}", address, err);
|
||||||
|
exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
let program_path = PathBuf::from(program);
|
let program_path = PathBuf::from(program);
|
||||||
if !program_path.exists() {
|
if !program_path.exists() {
|
||||||
|
Reference in New Issue
Block a user