Add get_balance() and get_account_data() to SyncClient

Migrate tests to use them.
This commit is contained in:
Greg Fitzgerald
2019-04-03 16:36:10 -06:00
parent 5cd7bccdf3
commit 167f5bdc58
8 changed files with 104 additions and 81 deletions

View File

@ -73,7 +73,8 @@ mod tests {
) -> Result<()> {
let ixs = vote_instruction::create_account(&from_keypair.pubkey(), vote_id, lamports);
let message = Message::new(ixs);
bank_client.send_message(&[from_keypair], message)
bank_client.send_message(&[from_keypair], message)?;
Ok(())
}
fn create_vote_account_with_delegate(
@ -88,7 +89,8 @@ mod tests {
let delegate_ix = vote_instruction::delegate_stake(&vote_id, delegate_id);
ixs.push(delegate_ix);
let message = Message::new(ixs);
bank_client.send_message(&[&from_keypair, vote_keypair], message)
bank_client.send_message(&[&from_keypair, vote_keypair], message)?;
Ok(())
}
fn submit_vote(
@ -97,7 +99,8 @@ mod tests {
tick_height: u64,
) -> Result<()> {
let vote_ix = vote_instruction::vote(&vote_keypair.pubkey(), Vote::new(tick_height));
bank_client.send_instruction(&vote_keypair, vote_ix)
bank_client.send_instruction(&vote_keypair, vote_ix)?;
Ok(())
}
#[test]
@ -111,8 +114,8 @@ mod tests {
create_vote_account(&bank_client, &from_keypair, &vote_id, 100).unwrap();
submit_vote(&bank_client, &vote_keypair, 0).unwrap();
let vote_account = bank.get_account(&vote_id).unwrap();
let vote_state = VoteState::deserialize(&vote_account.data).unwrap();
let vote_account_data = bank_client.get_account_data(&vote_id).unwrap();
let vote_state = VoteState::deserialize(&vote_account_data).unwrap();
assert_eq!(vote_state.votes.len(), 1);
}
@ -154,8 +157,8 @@ mod tests {
let result = bank_client.send_message(&[&mallory_keypair], message);
// And ensure there's no vote.
let vote_account = bank.get_account(&vote_id).unwrap();
let vote_state = VoteState::deserialize(&vote_account.data).unwrap();
let vote_account_data = bank_client.get_account_data(&vote_id).unwrap();
let vote_state = VoteState::deserialize(&vote_account_data).unwrap();
assert_eq!(vote_state.votes.len(), 0);
assert_eq!(