Rename Wallet's id to keypair

This commit is contained in:
Greg Fitzgerald 2019-04-02 07:08:11 -06:00
parent d228b6467c
commit dd4c512954
4 changed files with 82 additions and 67 deletions

View File

@ -58,17 +58,17 @@ pub fn parse_args(matches: &ArgMatches<'_>) -> Result<WalletConfig, Box<dyn erro
path.to_str().unwrap() path.to_str().unwrap()
}; };
let id = read_keypair(id_path).or_else(|err| { let keypair = read_keypair(id_path).or_else(|err| {
Err(WalletError::BadParameter(format!( Err(WalletError::BadParameter(format!(
"{}: Unable to open keypair file: {}", "{}: Unable to open keypair file: {}",
err, id_path err, id_path
))) )))
})?; })?;
let command = parse_command(&id.pubkey(), &matches)?; let command = parse_command(&keypair.pubkey(), &matches)?;
Ok(WalletConfig { Ok(WalletConfig {
id, keypair,
command, command,
drone_host, drone_host,
drone_port, drone_port,

View File

@ -81,7 +81,7 @@ impl error::Error for WalletError {
} }
pub struct WalletConfig { pub struct WalletConfig {
pub id: Keypair, pub keypair: Keypair,
pub command: WalletCommand, pub command: WalletCommand,
pub drone_host: Option<IpAddr>, pub drone_host: Option<IpAddr>,
pub drone_port: u16, pub drone_port: u16,
@ -99,7 +99,7 @@ impl Default for WalletConfig {
drone_host: None, drone_host: None,
drone_port: DRONE_PORT, drone_port: DRONE_PORT,
host: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), host: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
id: Keypair::new(), keypair: Keypair::new(),
rpc_client: None, rpc_client: None,
rpc_host: None, rpc_host: None,
rpc_port: DEFAULT_RPC_PORT, rpc_port: DEFAULT_RPC_PORT,
@ -266,17 +266,17 @@ fn process_airdrop(
"Requesting airdrop of {:?} lamports from {}", "Requesting airdrop of {:?} lamports from {}",
lamports, drone_addr lamports, drone_addr
); );
let previous_balance = match rpc_client.retry_get_balance(&config.id.pubkey(), 5)? { let previous_balance = match rpc_client.retry_get_balance(&config.keypair.pubkey(), 5)? {
Some(lamports) => lamports, Some(lamports) => lamports,
None => Err(WalletError::RpcRequestError( None => Err(WalletError::RpcRequestError(
"Received result of an unexpected type".to_string(), "Received result of an unexpected type".to_string(),
))?, ))?,
}; };
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config.id.pubkey(), lamports)?; request_and_confirm_airdrop(&rpc_client, &drone_addr, &config.keypair.pubkey(), lamports)?;
let current_balance = rpc_client let current_balance = rpc_client
.retry_get_balance(&config.id.pubkey(), 5)? .retry_get_balance(&config.keypair.pubkey(), 5)?
.unwrap_or(previous_balance); .unwrap_or(previous_balance);
if current_balance < previous_balance { if current_balance < previous_balance {
@ -334,18 +334,18 @@ fn process_configure_staking(
let mut ixs = vec![]; let mut ixs = vec![];
if let Some(delegate_id) = delegate_option { if let Some(delegate_id) = delegate_option {
ixs.push(VoteInstruction::new_delegate_stake( ixs.push(VoteInstruction::new_delegate_stake(
&config.id.pubkey(), &config.keypair.pubkey(),
&delegate_id, &delegate_id,
)); ));
} }
if let Some(authorized_voter_id) = authorized_voter_option { if let Some(authorized_voter_id) = authorized_voter_option {
ixs.push(VoteInstruction::new_authorize_voter( ixs.push(VoteInstruction::new_authorize_voter(
&config.id.pubkey(), &config.keypair.pubkey(),
&authorized_voter_id, &authorized_voter_id,
)); ));
} }
let mut tx = Transaction::new_signed_instructions(&[&config.id], ixs, recent_blockhash); let mut tx = Transaction::new_signed_instructions(&[&config.keypair], ixs, recent_blockhash);
let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.id)?; let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.keypair)?;
Ok(signature_str.to_string()) Ok(signature_str.to_string())
} }
@ -356,9 +356,9 @@ fn process_create_staking(
lamports: u64, lamports: u64,
) -> ProcessResult { ) -> ProcessResult {
let recent_blockhash = rpc_client.get_recent_blockhash()?; let recent_blockhash = rpc_client.get_recent_blockhash()?;
let ixs = VoteInstruction::new_account(&config.id.pubkey(), voting_account_id, lamports); let ixs = VoteInstruction::new_account(&config.keypair.pubkey(), voting_account_id, lamports);
let mut tx = Transaction::new_signed_instructions(&[&config.id], ixs, recent_blockhash); let mut tx = Transaction::new_signed_instructions(&[&config.keypair], ixs, recent_blockhash);
let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.id)?; let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.keypair)?;
Ok(signature_str.to_string()) Ok(signature_str.to_string())
} }
@ -367,7 +367,7 @@ fn process_deploy(
config: &WalletConfig, config: &WalletConfig,
program_location: &str, program_location: &str,
) -> ProcessResult { ) -> ProcessResult {
let balance = rpc_client.retry_get_balance(&config.id.pubkey(), 5)?; let balance = rpc_client.retry_get_balance(&config.keypair.pubkey(), 5)?;
if let Some(lamports) = balance { if let Some(lamports) = balance {
if lamports < 1 { if lamports < 1 {
Err(WalletError::DynamicProgramError( Err(WalletError::DynamicProgramError(
@ -391,7 +391,7 @@ fn process_deploy(
})?; })?;
let mut tx = SystemTransaction::new_program_account( let mut tx = SystemTransaction::new_program_account(
&config.id, &config.keypair,
&program_id.pubkey(), &program_id.pubkey(),
blockhash, blockhash,
1, 1,
@ -401,7 +401,7 @@ fn process_deploy(
); );
trace!("Creating program account"); trace!("Creating program account");
rpc_client rpc_client
.send_and_confirm_transaction(&mut tx, &config.id) .send_and_confirm_transaction(&mut tx, &config.keypair)
.map_err(|_| { .map_err(|_| {
WalletError::DynamicProgramError("Program allocate space failed".to_string()) WalletError::DynamicProgramError("Program allocate space failed".to_string())
})?; })?;
@ -450,21 +450,21 @@ fn process_pay(
let blockhash = rpc_client.get_recent_blockhash()?; let blockhash = rpc_client.get_recent_blockhash()?;
if timestamp == None && *witnesses == None { if timestamp == None && *witnesses == None {
let mut tx = SystemTransaction::new_move(&config.id, to, lamports, blockhash, 0); let mut tx = SystemTransaction::new_move(&config.keypair, to, lamports, blockhash, 0);
let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.id)?; let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.keypair)?;
Ok(signature_str.to_string()) Ok(signature_str.to_string())
} else if *witnesses == None { } else if *witnesses == None {
let dt = timestamp.unwrap(); let dt = timestamp.unwrap();
let dt_pubkey = match timestamp_pubkey { let dt_pubkey = match timestamp_pubkey {
Some(pubkey) => pubkey, Some(pubkey) => pubkey,
None => config.id.pubkey(), None => config.keypair.pubkey(),
}; };
let contract_state = Keypair::new(); let contract_state = Keypair::new();
// Initializing contract // Initializing contract
let ixs = BudgetInstruction::new_on_date( let ixs = BudgetInstruction::new_on_date(
&config.id.pubkey(), &config.keypair.pubkey(),
to, to,
&contract_state.pubkey(), &contract_state.pubkey(),
dt, dt,
@ -472,8 +472,8 @@ fn process_pay(
cancelable, cancelable,
lamports, lamports,
); );
let mut tx = Transaction::new_signed_instructions(&[&config.id], ixs, blockhash); let mut tx = Transaction::new_signed_instructions(&[&config.keypair], ixs, blockhash);
let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.id)?; let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.keypair)?;
Ok(json!({ Ok(json!({
"signature": signature_str, "signature": signature_str,
@ -495,15 +495,15 @@ fn process_pay(
// Initializing contract // Initializing contract
let ixs = BudgetInstruction::new_when_signed( let ixs = BudgetInstruction::new_when_signed(
&config.id.pubkey(), &config.keypair.pubkey(),
to, to,
&contract_state.pubkey(), &contract_state.pubkey(),
&witness, &witness,
cancelable, cancelable,
lamports, lamports,
); );
let mut tx = Transaction::new_signed_instructions(&[&config.id], ixs, blockhash); let mut tx = Transaction::new_signed_instructions(&[&config.keypair], ixs, blockhash);
let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.id)?; let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.keypair)?;
Ok(json!({ Ok(json!({
"signature": signature_str, "signature": signature_str,
@ -517,10 +517,13 @@ fn process_pay(
fn process_cancel(rpc_client: &RpcClient, config: &WalletConfig, pubkey: &Pubkey) -> ProcessResult { fn process_cancel(rpc_client: &RpcClient, config: &WalletConfig, pubkey: &Pubkey) -> ProcessResult {
let blockhash = rpc_client.get_recent_blockhash()?; let blockhash = rpc_client.get_recent_blockhash()?;
let ix = let ix = BudgetInstruction::new_apply_signature(
BudgetInstruction::new_apply_signature(&config.id.pubkey(), pubkey, &config.id.pubkey()); &config.keypair.pubkey(),
let mut tx = Transaction::new_signed_instructions(&[&config.id], vec![ix], blockhash); pubkey,
let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.id)?; &config.keypair.pubkey(),
);
let mut tx = Transaction::new_signed_instructions(&[&config.keypair], vec![ix], blockhash);
let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.keypair)?;
Ok(signature_str.to_string()) Ok(signature_str.to_string())
} }
@ -537,17 +540,17 @@ fn process_time_elapsed(
pubkey: &Pubkey, pubkey: &Pubkey,
dt: DateTime<Utc>, dt: DateTime<Utc>,
) -> ProcessResult { ) -> ProcessResult {
let balance = rpc_client.retry_get_balance(&config.id.pubkey(), 5)?; let balance = rpc_client.retry_get_balance(&config.keypair.pubkey(), 5)?;
if let Some(0) = balance { if let Some(0) = balance {
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config.id.pubkey(), 1)?; request_and_confirm_airdrop(&rpc_client, &drone_addr, &config.keypair.pubkey(), 1)?;
} }
let blockhash = rpc_client.get_recent_blockhash()?; let blockhash = rpc_client.get_recent_blockhash()?;
let ix = BudgetInstruction::new_apply_timestamp(&config.id.pubkey(), pubkey, to, dt); let ix = BudgetInstruction::new_apply_timestamp(&config.keypair.pubkey(), pubkey, to, dt);
let mut tx = Transaction::new_signed_instructions(&[&config.id], vec![ix], blockhash); let mut tx = Transaction::new_signed_instructions(&[&config.keypair], vec![ix], blockhash);
let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.id)?; let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.keypair)?;
Ok(signature_str.to_string()) Ok(signature_str.to_string())
} }
@ -559,16 +562,16 @@ fn process_witness(
to: &Pubkey, to: &Pubkey,
pubkey: &Pubkey, pubkey: &Pubkey,
) -> ProcessResult { ) -> ProcessResult {
let balance = rpc_client.retry_get_balance(&config.id.pubkey(), 5)?; let balance = rpc_client.retry_get_balance(&config.keypair.pubkey(), 5)?;
if let Some(0) = balance { if let Some(0) = balance {
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config.id.pubkey(), 1)?; request_and_confirm_airdrop(&rpc_client, &drone_addr, &config.keypair.pubkey(), 1)?;
} }
let blockhash = rpc_client.get_recent_blockhash()?; let blockhash = rpc_client.get_recent_blockhash()?;
let ix = BudgetInstruction::new_apply_signature(&config.id.pubkey(), pubkey, to); let ix = BudgetInstruction::new_apply_signature(&config.keypair.pubkey(), pubkey, to);
let mut tx = Transaction::new_signed_instructions(&[&config.id], vec![ix], blockhash); let mut tx = Transaction::new_signed_instructions(&[&config.keypair], vec![ix], blockhash);
let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.id)?; let signature_str = rpc_client.send_and_confirm_transaction(&mut tx, &config.keypair)?;
Ok(signature_str.to_string()) Ok(signature_str.to_string())
} }
@ -576,7 +579,7 @@ fn process_witness(
pub fn process_command(config: &WalletConfig) -> ProcessResult { pub fn process_command(config: &WalletConfig) -> ProcessResult {
if let WalletCommand::Address = config.command { if let WalletCommand::Address = config.command {
// Get address of this client // Get address of this client
return Ok(format!("{}", config.id.pubkey())); return Ok(format!("{}", config.keypair.pubkey()));
} }
let drone_addr = config.drone_addr(); let drone_addr = config.drone_addr();
@ -1167,11 +1170,11 @@ mod tests {
let keypair = Keypair::new(); let keypair = Keypair::new();
let pubkey = keypair.pubkey().to_string(); let pubkey = keypair.pubkey().to_string();
config.id = keypair; config.keypair = keypair;
config.command = WalletCommand::Address; config.command = WalletCommand::Address;
assert_eq!(process_command(&config).unwrap(), pubkey); assert_eq!(process_command(&config).unwrap(), pubkey);
config.command = WalletCommand::Balance(config.id.pubkey()); config.command = WalletCommand::Balance(config.keypair.pubkey());
assert_eq!(process_command(&config).unwrap(), "50 lamports"); assert_eq!(process_command(&config).unwrap(), "50 lamports");
let process_id = Pubkey::new_rand(); let process_id = Pubkey::new_rand();
@ -1204,7 +1207,7 @@ mod tests {
10, 10,
bob_pubkey, bob_pubkey,
Some(dt), Some(dt),
Some(config.id.pubkey()), Some(config.keypair.pubkey()),
None, None,
None, None,
); );
@ -1227,7 +1230,7 @@ mod tests {
None, None,
None, None,
Some(vec![witness]), Some(vec![witness]),
Some(config.id.pubkey()), Some(config.keypair.pubkey()),
); );
let result = process_command(&config); let result = process_command(&config);
let json: Value = serde_json::from_str(&result.unwrap()).unwrap(); let json: Value = serde_json::from_str(&result.unwrap()).unwrap();
@ -1277,7 +1280,7 @@ mod tests {
config.command = WalletCommand::Airdrop(50); config.command = WalletCommand::Airdrop(50);
assert!(process_command(&config).is_err()); assert!(process_command(&config).is_err());
config.command = WalletCommand::Balance(config.id.pubkey()); config.command = WalletCommand::Balance(config.keypair.pubkey());
assert!(process_command(&config).is_err()); assert!(process_command(&config).is_err());
let any_signature = Signature::new(&bs58::decode(SIGNATURE).into_vec().unwrap()); let any_signature = Signature::new(&bs58::decode(SIGNATURE).into_vec().unwrap());
@ -1300,7 +1303,7 @@ mod tests {
10, 10,
bob_pubkey, bob_pubkey,
Some(dt), Some(dt),
Some(config.id.pubkey()), Some(config.keypair.pubkey()),
None, None,
None, None,
); );
@ -1312,7 +1315,7 @@ mod tests {
None, None,
None, None,
Some(vec![witness]), Some(vec![witness]),
Some(config.id.pubkey()), Some(config.keypair.pubkey()),
); );
assert!(process_command(&config).is_err()); assert!(process_command(&config).is_err());

View File

@ -37,10 +37,14 @@ fn test_wallet_timestamp_tx() {
config_witness.drone_port = drone_addr.port(); config_witness.drone_port = drone_addr.port();
config_witness.rpc_port = leader_data.rpc.port(); config_witness.rpc_port = leader_data.rpc.port();
assert_ne!(config_payer.id.pubkey(), config_witness.id.pubkey()); assert_ne!(
config_payer.keypair.pubkey(),
config_witness.keypair.pubkey()
);
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config_payer.id.pubkey(), 50).unwrap(); request_and_confirm_airdrop(&rpc_client, &drone_addr, &config_payer.keypair.pubkey(), 50)
check_balance(50, &rpc_client, &config_payer.id.pubkey()); .unwrap();
check_balance(50, &rpc_client, &config_payer.keypair.pubkey());
// Make transaction (from config_payer to bob_pubkey) requiring timestamp from config_witness // Make transaction (from config_payer to bob_pubkey) requiring timestamp from config_witness
let date_string = "\"2018-09-19T17:30:59Z\""; let date_string = "\"2018-09-19T17:30:59Z\"";
@ -49,7 +53,7 @@ fn test_wallet_timestamp_tx() {
10, 10,
bob_pubkey, bob_pubkey,
Some(dt), Some(dt),
Some(config_witness.id.pubkey()), Some(config_witness.keypair.pubkey()),
None, None,
None, None,
); );
@ -62,7 +66,7 @@ fn test_wallet_timestamp_tx() {
.expect("base58-encoded public key"); .expect("base58-encoded public key");
let process_id = Pubkey::new(&process_id_vec); let process_id = Pubkey::new(&process_id_vec);
check_balance(40, &rpc_client, &config_payer.id.pubkey()); // config_payer balance check_balance(40, &rpc_client, &config_payer.keypair.pubkey()); // config_payer balance
check_balance(10, &rpc_client, &process_id); // contract balance check_balance(10, &rpc_client, &process_id); // contract balance
check_balance(0, &rpc_client, &bob_pubkey); // recipient balance check_balance(0, &rpc_client, &bob_pubkey); // recipient balance
@ -70,7 +74,7 @@ fn test_wallet_timestamp_tx() {
config_witness.command = WalletCommand::TimeElapsed(bob_pubkey, process_id, dt); config_witness.command = WalletCommand::TimeElapsed(bob_pubkey, process_id, dt);
process_command(&config_witness).unwrap(); process_command(&config_witness).unwrap();
check_balance(40, &rpc_client, &config_payer.id.pubkey()); // config_payer balance check_balance(40, &rpc_client, &config_payer.keypair.pubkey()); // config_payer balance
check_balance(0, &rpc_client, &process_id); // contract balance check_balance(0, &rpc_client, &process_id); // contract balance
check_balance(10, &rpc_client, &bob_pubkey); // recipient balance check_balance(10, &rpc_client, &bob_pubkey); // recipient balance
@ -97,9 +101,13 @@ fn test_wallet_witness_tx() {
config_witness.drone_port = drone_addr.port(); config_witness.drone_port = drone_addr.port();
config_witness.rpc_port = leader_data.rpc.port(); config_witness.rpc_port = leader_data.rpc.port();
assert_ne!(config_payer.id.pubkey(), config_witness.id.pubkey()); assert_ne!(
config_payer.keypair.pubkey(),
config_witness.keypair.pubkey()
);
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config_payer.id.pubkey(), 50).unwrap(); request_and_confirm_airdrop(&rpc_client, &drone_addr, &config_payer.keypair.pubkey(), 50)
.unwrap();
// Make transaction (from config_payer to bob_pubkey) requiring witness signature from config_witness // Make transaction (from config_payer to bob_pubkey) requiring witness signature from config_witness
config_payer.command = WalletCommand::Pay( config_payer.command = WalletCommand::Pay(
@ -107,7 +115,7 @@ fn test_wallet_witness_tx() {
bob_pubkey, bob_pubkey,
None, None,
None, None,
Some(vec![config_witness.id.pubkey()]), Some(vec![config_witness.keypair.pubkey()]),
None, None,
); );
let sig_response = process_command(&config_payer); let sig_response = process_command(&config_payer);
@ -119,7 +127,7 @@ fn test_wallet_witness_tx() {
.expect("base58-encoded public key"); .expect("base58-encoded public key");
let process_id = Pubkey::new(&process_id_vec); let process_id = Pubkey::new(&process_id_vec);
check_balance(40, &rpc_client, &config_payer.id.pubkey()); // config_payer balance check_balance(40, &rpc_client, &config_payer.keypair.pubkey()); // config_payer balance
check_balance(10, &rpc_client, &process_id); // contract balance check_balance(10, &rpc_client, &process_id); // contract balance
check_balance(0, &rpc_client, &bob_pubkey); // recipient balance check_balance(0, &rpc_client, &bob_pubkey); // recipient balance
@ -127,7 +135,7 @@ fn test_wallet_witness_tx() {
config_witness.command = WalletCommand::Witness(bob_pubkey, process_id); config_witness.command = WalletCommand::Witness(bob_pubkey, process_id);
process_command(&config_witness).unwrap(); process_command(&config_witness).unwrap();
check_balance(40, &rpc_client, &config_payer.id.pubkey()); // config_payer balance check_balance(40, &rpc_client, &config_payer.keypair.pubkey()); // config_payer balance
check_balance(0, &rpc_client, &process_id); // contract balance check_balance(0, &rpc_client, &process_id); // contract balance
check_balance(10, &rpc_client, &bob_pubkey); // recipient balance check_balance(10, &rpc_client, &bob_pubkey); // recipient balance
@ -154,9 +162,13 @@ fn test_wallet_cancel_tx() {
config_witness.drone_port = drone_addr.port(); config_witness.drone_port = drone_addr.port();
config_witness.rpc_port = leader_data.rpc.port(); config_witness.rpc_port = leader_data.rpc.port();
assert_ne!(config_payer.id.pubkey(), config_witness.id.pubkey()); assert_ne!(
config_payer.keypair.pubkey(),
config_witness.keypair.pubkey()
);
request_and_confirm_airdrop(&rpc_client, &drone_addr, &config_payer.id.pubkey(), 50).unwrap(); request_and_confirm_airdrop(&rpc_client, &drone_addr, &config_payer.keypair.pubkey(), 50)
.unwrap();
// Make transaction (from config_payer to bob_pubkey) requiring witness signature from config_witness // Make transaction (from config_payer to bob_pubkey) requiring witness signature from config_witness
config_payer.command = WalletCommand::Pay( config_payer.command = WalletCommand::Pay(
@ -164,8 +176,8 @@ fn test_wallet_cancel_tx() {
bob_pubkey, bob_pubkey,
None, None,
None, None,
Some(vec![config_witness.id.pubkey()]), Some(vec![config_witness.keypair.pubkey()]),
Some(config_payer.id.pubkey()), Some(config_payer.keypair.pubkey()),
); );
let sig_response = process_command(&config_payer).unwrap(); let sig_response = process_command(&config_payer).unwrap();
@ -176,7 +188,7 @@ fn test_wallet_cancel_tx() {
.expect("base58-encoded public key"); .expect("base58-encoded public key");
let process_id = Pubkey::new(&process_id_vec); let process_id = Pubkey::new(&process_id_vec);
check_balance(40, &rpc_client, &config_payer.id.pubkey()); // config_payer balance check_balance(40, &rpc_client, &config_payer.keypair.pubkey()); // config_payer balance
check_balance(10, &rpc_client, &process_id); // contract balance check_balance(10, &rpc_client, &process_id); // contract balance
check_balance(0, &rpc_client, &bob_pubkey); // recipient balance check_balance(0, &rpc_client, &bob_pubkey); // recipient balance
@ -184,7 +196,7 @@ fn test_wallet_cancel_tx() {
config_payer.command = WalletCommand::Cancel(process_id); config_payer.command = WalletCommand::Cancel(process_id);
process_command(&config_payer).unwrap(); process_command(&config_payer).unwrap();
check_balance(50, &rpc_client, &config_payer.id.pubkey()); // config_payer balance check_balance(50, &rpc_client, &config_payer.keypair.pubkey()); // config_payer balance
check_balance(0, &rpc_client, &process_id); // contract balance check_balance(0, &rpc_client, &process_id); // contract balance
check_balance(0, &rpc_client, &bob_pubkey); // recipient balance check_balance(0, &rpc_client, &bob_pubkey); // recipient balance

View File

@ -24,7 +24,7 @@ fn test_wallet_request_airdrop() {
let rpc_client = RpcClient::new_socket(leader_data.rpc); let rpc_client = RpcClient::new_socket(leader_data.rpc);
let balance = rpc_client let balance = rpc_client
.retry_get_balance(&bob_config.id.pubkey(), 1) .retry_get_balance(&bob_config.keypair.pubkey(), 1)
.unwrap() .unwrap()
.unwrap(); .unwrap();
assert_eq!(balance, 50); assert_eq!(balance, 50);