require to account signature (#6658)

* require to signature

* fixing invocation to create_account

* fix create_account references

* address review comment

* whacking bugs in tests

* fixing stake program tests
This commit is contained in:
Parth
2019-11-08 15:57:35 +05:30
committed by GitHub
parent f7b6e777bf
commit 5bd05fba09
29 changed files with 277 additions and 153 deletions

View File

@@ -36,7 +36,13 @@ pub fn create_genesis<T: Client>(from_key: &Keypair, client: &T, amount: u64) ->
as u64,
&solana_sdk::move_loader::id(),
);
client.send_instruction(&from_key, instruction).unwrap();
client
.send_message(
&[&from_key, &libra_genesis_key],
Message::new(vec![instruction]),
)
.unwrap();
let instruction = librapay_instruction::genesis(&libra_genesis_key.pubkey(), amount);
let message = Message::new_with_payer(vec![instruction], Some(&from_key.pubkey()));

View File

@@ -63,32 +63,35 @@ pub fn transfer(
pub fn create_accounts(
from: &Keypair,
tos: &[Pubkey],
to: &[&Keypair],
lamports: u64,
recent_blockhash: Hash,
) -> Transaction {
let instructions = tos
let instructions = to
.iter()
.map(|to| {
system_instruction::create_account(
&from.pubkey(),
to,
&to.pubkey(),
lamports,
400,
&solana_sdk::move_loader::id(),
)
})
.collect();
Transaction::new_signed_instructions(&[from], instructions, recent_blockhash)
let mut from_signers = vec![from];
from_signers.extend_from_slice(to);
Transaction::new_signed_instructions(&from_signers, instructions, recent_blockhash)
}
pub fn create_account(
from: &Keypair,
to: &Pubkey,
to: &Keypair,
lamports: u64,
recent_blockhash: Hash,
) -> Transaction {
create_accounts(from, &[*to], lamports, recent_blockhash)
create_accounts(from, &[to], lamports, recent_blockhash)
}
#[derive(Debug)]
@@ -172,12 +175,7 @@ mod tests {
let from = Keypair::new();
let to = Keypair::new();
let tx = create_accounts(
&mint_keypair,
&[from.pubkey(), to.pubkey()],
1,
bank.last_blockhash(),
);
let tx = create_accounts(&mint_keypair, &[&from, &to], 1, bank.last_blockhash());
bank.process_transaction(&tx).unwrap();
info!(