parent
6365c4c061
commit
f079a78c5e
|
@ -236,7 +236,7 @@ fn generate_txs(
|
||||||
.par_iter()
|
.par_iter()
|
||||||
.map(|(id, keypair)| {
|
.map(|(id, keypair)| {
|
||||||
(
|
(
|
||||||
system_transaction::create_user_account(id, &keypair.pubkey(), 1, *blockhash, 0),
|
system_transaction::create_user_account(id, &keypair.pubkey(), 1, *blockhash),
|
||||||
timestamp(),
|
timestamp(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -641,7 +641,7 @@ mod tests {
|
||||||
let key = Keypair::new();
|
let key = Keypair::new();
|
||||||
let to = Pubkey::new_rand();
|
let to = Pubkey::new_rand();
|
||||||
let blockhash = Hash::default();
|
let blockhash = Hash::default();
|
||||||
let tx = system_transaction::create_user_account(&key, &to, 50, blockhash, 0);
|
let tx = system_transaction::create_user_account(&key, &to, 50, blockhash);
|
||||||
|
|
||||||
let signature = rpc_client.send_transaction(&tx);
|
let signature = rpc_client.send_transaction(&tx);
|
||||||
assert_eq!(signature.unwrap(), SIGNATURE.to_string());
|
assert_eq!(signature.unwrap(), SIGNATURE.to_string());
|
||||||
|
@ -690,7 +690,7 @@ mod tests {
|
||||||
let key = Keypair::new();
|
let key = Keypair::new();
|
||||||
let to = Pubkey::new_rand();
|
let to = Pubkey::new_rand();
|
||||||
let blockhash = Hash::default();
|
let blockhash = Hash::default();
|
||||||
let mut tx = system_transaction::create_user_account(&key, &to, 50, blockhash, 0);
|
let mut tx = system_transaction::create_user_account(&key, &to, 50, blockhash);
|
||||||
|
|
||||||
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&key]);
|
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&key]);
|
||||||
result.unwrap();
|
result.unwrap();
|
||||||
|
@ -713,8 +713,8 @@ mod tests {
|
||||||
let blockhash: Hash = "HUu3LwEzGRsUkuJS121jzkPJW39Kq62pXCTmTa1F9jDL"
|
let blockhash: Hash = "HUu3LwEzGRsUkuJS121jzkPJW39Kq62pXCTmTa1F9jDL"
|
||||||
.parse()
|
.parse()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let prev_tx = system_transaction::create_user_account(&key, &to, 50, blockhash, 0);
|
let prev_tx = system_transaction::create_user_account(&key, &to, 50, blockhash);
|
||||||
let mut tx = system_transaction::create_user_account(&key, &to, 50, blockhash, 0);
|
let mut tx = system_transaction::create_user_account(&key, &to, 50, blockhash);
|
||||||
|
|
||||||
rpc_client.resign_transaction(&mut tx, &[&key]).unwrap();
|
rpc_client.resign_transaction(&mut tx, &[&key]).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ fn bench_banking_stage_multi_accounts(bencher: &mut Bencher) {
|
||||||
let (vote_sender, vote_receiver) = channel();
|
let (vote_sender, vote_receiver) = channel();
|
||||||
let bank = Arc::new(Bank::new(&genesis_block));
|
let bank = Arc::new(Bank::new(&genesis_block));
|
||||||
let to_pubkey = Pubkey::new_rand();
|
let to_pubkey = Pubkey::new_rand();
|
||||||
let dummy = system_transaction::transfer(&mint_keypair, &to_pubkey, 1, genesis_block.hash(), 0);
|
let dummy = system_transaction::transfer(&mint_keypair, &to_pubkey, 1, genesis_block.hash());
|
||||||
trace!("txs: {}", txes);
|
trace!("txs: {}", txes);
|
||||||
let transactions: Vec<_> = (0..txes)
|
let transactions: Vec<_> = (0..txes)
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
|
@ -123,7 +123,6 @@ fn bench_banking_stage_multi_accounts(bencher: &mut Bencher) {
|
||||||
&tx.message.account_keys[0],
|
&tx.message.account_keys[0],
|
||||||
mint_total / txes as u64,
|
mint_total / txes as u64,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let x = bank.process_transaction(&fund);
|
let x = bank.process_transaction(&fund);
|
||||||
x.unwrap();
|
x.unwrap();
|
||||||
|
@ -209,7 +208,7 @@ fn bench_banking_stage_multi_programs(bencher: &mut Bencher) {
|
||||||
let (vote_sender, vote_receiver) = channel();
|
let (vote_sender, vote_receiver) = channel();
|
||||||
let bank = Arc::new(Bank::new(&genesis_block));
|
let bank = Arc::new(Bank::new(&genesis_block));
|
||||||
let to_pubkey = Pubkey::new_rand();
|
let to_pubkey = Pubkey::new_rand();
|
||||||
let dummy = system_transaction::transfer(&mint_keypair, &to_pubkey, 1, genesis_block.hash(), 0);
|
let dummy = system_transaction::transfer(&mint_keypair, &to_pubkey, 1, genesis_block.hash());
|
||||||
let transactions: Vec<_> = (0..txes)
|
let transactions: Vec<_> = (0..txes)
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.map(|_| {
|
.map(|_| {
|
||||||
|
@ -246,7 +245,6 @@ fn bench_banking_stage_multi_programs(bencher: &mut Bencher) {
|
||||||
&tx.message.account_keys[0],
|
&tx.message.account_keys[0],
|
||||||
mint_total / txes as u64,
|
mint_total / txes as u64,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
bank.process_transaction(&fund).unwrap();
|
bank.process_transaction(&fund).unwrap();
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn bench_block_to_blobs_to_block(bencher: &mut Bencher) {
|
||||||
let zero = Hash::default();
|
let zero = Hash::default();
|
||||||
let one = hash(&zero.as_ref());
|
let one = hash(&zero.as_ref());
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
let tx0 = system_transaction::transfer(&keypair, &keypair.pubkey(), 1, one, 0);
|
let tx0 = system_transaction::transfer(&keypair, &keypair.pubkey(), 1, one);
|
||||||
let transactions = vec![tx0; 10];
|
let transactions = vec![tx0; 10];
|
||||||
let entries = next_entries(&zero, 1, transactions);
|
let entries = next_entries(&zero, 1, transactions);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ fn bench_sigverify_stage(bencher: &mut Bencher) {
|
||||||
&to_keypair.pubkey(),
|
&to_keypair.pubkey(),
|
||||||
amount,
|
amount,
|
||||||
Hash::default(),
|
Hash::default(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
tx
|
tx
|
||||||
})
|
})
|
||||||
|
|
|
@ -947,23 +947,21 @@ mod tests {
|
||||||
&keypair.pubkey(),
|
&keypair.pubkey(),
|
||||||
2,
|
2,
|
||||||
start_hash,
|
start_hash,
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
bank.process_transaction(&fund_tx).unwrap();
|
bank.process_transaction(&fund_tx).unwrap();
|
||||||
|
|
||||||
// good tx
|
// good tx
|
||||||
let to = Pubkey::new_rand();
|
let to = Pubkey::new_rand();
|
||||||
let tx = system_transaction::create_user_account(&mint_keypair, &to, 1, start_hash, 0);
|
let tx = system_transaction::create_user_account(&mint_keypair, &to, 1, start_hash);
|
||||||
|
|
||||||
// good tx, but no verify
|
// good tx, but no verify
|
||||||
let to2 = Pubkey::new_rand();
|
let to2 = Pubkey::new_rand();
|
||||||
let tx_no_ver =
|
let tx_no_ver = system_transaction::create_user_account(&keypair, &to2, 2, start_hash);
|
||||||
system_transaction::create_user_account(&keypair, &to2, 2, start_hash, 0);
|
|
||||||
|
|
||||||
// bad tx, AccountNotFound
|
// bad tx, AccountNotFound
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
let to3 = Pubkey::new_rand();
|
let to3 = Pubkey::new_rand();
|
||||||
let tx_anf = system_transaction::create_user_account(&keypair, &to3, 1, start_hash, 0);
|
let tx_anf = system_transaction::create_user_account(&keypair, &to3, 1, start_hash);
|
||||||
|
|
||||||
// send 'em over
|
// send 'em over
|
||||||
let packets = to_packets(&[tx_no_ver, tx_anf, tx]);
|
let packets = to_packets(&[tx_no_ver, tx_anf, tx]);
|
||||||
|
@ -1038,7 +1036,6 @@ mod tests {
|
||||||
&alice.pubkey(),
|
&alice.pubkey(),
|
||||||
2,
|
2,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let packets = to_packets(&[tx]);
|
let packets = to_packets(&[tx]);
|
||||||
|
@ -1054,7 +1051,6 @@ mod tests {
|
||||||
&mint_keypair.pubkey(),
|
&mint_keypair.pubkey(),
|
||||||
1,
|
1,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let packets = to_packets(&[tx]);
|
let packets = to_packets(&[tx]);
|
||||||
let packets = packets
|
let packets = packets
|
||||||
|
@ -1151,8 +1147,8 @@ mod tests {
|
||||||
let pubkey2 = Pubkey::new_rand();
|
let pubkey2 = Pubkey::new_rand();
|
||||||
|
|
||||||
let transactions = vec![
|
let transactions = vec![
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&keypair2, &pubkey2, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&keypair2, &pubkey2, 1, genesis_block.hash()),
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut results = vec![Ok(()), Ok(())];
|
let mut results = vec![Ok(()), Ok(())];
|
||||||
|
@ -1211,21 +1207,18 @@ mod tests {
|
||||||
&pubkey,
|
&pubkey,
|
||||||
1,
|
1,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
)),
|
)),
|
||||||
Some(system_transaction::transfer(
|
Some(system_transaction::transfer(
|
||||||
&mint_keypair,
|
&mint_keypair,
|
||||||
&pubkey,
|
&pubkey,
|
||||||
1,
|
1,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
)),
|
)),
|
||||||
Some(system_transaction::transfer(
|
Some(system_transaction::transfer(
|
||||||
&mint_keypair,
|
&mint_keypair,
|
||||||
&pubkey,
|
&pubkey,
|
||||||
1,
|
1,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
)),
|
)),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
@ -1234,7 +1227,6 @@ mod tests {
|
||||||
&pubkey,
|
&pubkey,
|
||||||
1,
|
1,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
)),
|
)),
|
||||||
None,
|
None,
|
||||||
Some(system_transaction::transfer(
|
Some(system_transaction::transfer(
|
||||||
|
@ -1242,7 +1234,6 @@ mod tests {
|
||||||
&pubkey,
|
&pubkey,
|
||||||
1,
|
1,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
)),
|
)),
|
||||||
None,
|
None,
|
||||||
Some(system_transaction::transfer(
|
Some(system_transaction::transfer(
|
||||||
|
@ -1250,19 +1241,18 @@ mod tests {
|
||||||
&pubkey,
|
&pubkey,
|
||||||
1,
|
1,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
)),
|
)),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
];
|
];
|
||||||
|
|
||||||
let filtered_transactions = vec![
|
let filtered_transactions = vec![
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
];
|
];
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1288,12 +1278,12 @@ mod tests {
|
||||||
let pubkey = Pubkey::new_rand();
|
let pubkey = Pubkey::new_rand();
|
||||||
|
|
||||||
let transactions = vec![
|
let transactions = vec![
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
];
|
];
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1406,7 +1396,6 @@ mod tests {
|
||||||
&pubkey,
|
&pubkey,
|
||||||
1,
|
1,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
)];
|
)];
|
||||||
|
|
||||||
let working_bank = WorkingBank {
|
let working_bank = WorkingBank {
|
||||||
|
@ -1462,7 +1451,6 @@ mod tests {
|
||||||
&pubkey,
|
&pubkey,
|
||||||
2,
|
2,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
)];
|
)];
|
||||||
|
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
|
@ -1490,8 +1478,8 @@ mod tests {
|
||||||
let pubkey1 = Pubkey::new_rand();
|
let pubkey1 = Pubkey::new_rand();
|
||||||
|
|
||||||
let transactions = vec![
|
let transactions = vec![
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey1, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey1, 1, genesis_block.hash()),
|
||||||
];
|
];
|
||||||
|
|
||||||
let working_bank = WorkingBank {
|
let working_bank = WorkingBank {
|
||||||
|
|
|
@ -183,10 +183,8 @@ mod test {
|
||||||
|
|
||||||
let keypair0 = Keypair::new();
|
let keypair0 = Keypair::new();
|
||||||
let keypair1 = Keypair::new();
|
let keypair1 = Keypair::new();
|
||||||
let tx0 =
|
let tx0 = system_transaction::transfer(&keypair0, &keypair1.pubkey(), 1, Hash::default());
|
||||||
system_transaction::transfer(&keypair0, &keypair1.pubkey(), 1, Hash::default(), 0);
|
let tx1 = system_transaction::transfer(&keypair1, &keypair0.pubkey(), 2, Hash::default());
|
||||||
let tx1 =
|
|
||||||
system_transaction::transfer(&keypair1, &keypair0.pubkey(), 2, Hash::default(), 0);
|
|
||||||
let serialized_tx0 = serialize(&tx0).unwrap();
|
let serialized_tx0 = serialize(&tx0).unwrap();
|
||||||
let serialized_tx1 = serialize(&tx1).unwrap();
|
let serialized_tx1 = serialize(&tx1).unwrap();
|
||||||
let entry = Entry::new(&Hash::default(), 1, vec![tx0, tx1]);
|
let entry = Entry::new(&Hash::default(), 1, vec![tx0, tx1]);
|
||||||
|
|
|
@ -146,7 +146,6 @@ mod test {
|
||||||
&keypair.pubkey(),
|
&keypair.pubkey(),
|
||||||
1,
|
1,
|
||||||
Hash::default(),
|
Hash::default(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let entry = Entry::new(&mut blockhash, 1, vec![tx]);
|
let entry = Entry::new(&mut blockhash, 1, vec![tx]);
|
||||||
blockhash = entry.hash;
|
blockhash = entry.hash;
|
||||||
|
|
|
@ -576,7 +576,6 @@ mod tests {
|
||||||
&keypair.pubkey(),
|
&keypair.pubkey(),
|
||||||
1,
|
1,
|
||||||
slot_entries.last().unwrap().hash,
|
slot_entries.last().unwrap().hash,
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// First, ensure the TX is rejected because of the unregistered last ID
|
// First, ensure the TX is rejected because of the unregistered last ID
|
||||||
|
@ -611,7 +610,6 @@ mod tests {
|
||||||
&keypair.pubkey(),
|
&keypair.pubkey(),
|
||||||
1,
|
1,
|
||||||
blockhash,
|
blockhash,
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let entry = Entry::new(&last_entry_hash, 1, vec![tx]);
|
let entry = Entry::new(&last_entry_hash, 1, vec![tx]);
|
||||||
last_entry_hash = entry.hash;
|
last_entry_hash = entry.hash;
|
||||||
|
@ -625,7 +623,6 @@ mod tests {
|
||||||
&keypair2.pubkey(),
|
&keypair2.pubkey(),
|
||||||
42,
|
42,
|
||||||
blockhash,
|
blockhash,
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let entry = Entry::new(&last_entry_hash, 1, vec![tx]);
|
let entry = Entry::new(&last_entry_hash, 1, vec![tx]);
|
||||||
last_entry_hash = entry.hash;
|
last_entry_hash = entry.hash;
|
||||||
|
@ -712,7 +709,6 @@ mod tests {
|
||||||
&keypair1.pubkey(),
|
&keypair1.pubkey(),
|
||||||
2,
|
2,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
|
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
|
||||||
let tx = system_transaction::create_user_account(
|
let tx = system_transaction::create_user_account(
|
||||||
|
@ -720,7 +716,6 @@ mod tests {
|
||||||
&keypair2.pubkey(),
|
&keypair2.pubkey(),
|
||||||
2,
|
2,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let entry_2 = next_entry(&entry_1.hash, 1, vec![tx]);
|
let entry_2 = next_entry(&entry_1.hash, 1, vec![tx]);
|
||||||
assert_eq!(process_entries(&bank, &[entry_1, entry_2]), Ok(()));
|
assert_eq!(process_entries(&bank, &[entry_1, entry_2]), Ok(()));
|
||||||
|
@ -750,7 +745,6 @@ mod tests {
|
||||||
&mint_keypair.pubkey(),
|
&mint_keypair.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
)],
|
)],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -763,14 +757,12 @@ mod tests {
|
||||||
&keypair3.pubkey(),
|
&keypair3.pubkey(),
|
||||||
2,
|
2,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
), // should be fine
|
), // should be fine
|
||||||
system_transaction::create_user_account(
|
system_transaction::create_user_account(
|
||||||
&keypair1,
|
&keypair1,
|
||||||
&mint_keypair.pubkey(),
|
&mint_keypair.pubkey(),
|
||||||
2,
|
2,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
), // will collide
|
), // will collide
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -809,14 +801,12 @@ mod tests {
|
||||||
&mint_keypair.pubkey(),
|
&mint_keypair.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
),
|
),
|
||||||
system_transaction::transfer(
|
system_transaction::transfer(
|
||||||
&keypair4,
|
&keypair4,
|
||||||
&keypair4.pubkey(),
|
&keypair4.pubkey(),
|
||||||
1,
|
1,
|
||||||
Hash::default(), // Should cause a transaction failure with BlockhashNotFound
|
Hash::default(), // Should cause a transaction failure with BlockhashNotFound
|
||||||
0,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -830,14 +820,12 @@ mod tests {
|
||||||
&keypair3.pubkey(),
|
&keypair3.pubkey(),
|
||||||
2,
|
2,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
), // should be fine
|
), // should be fine
|
||||||
system_transaction::create_user_account(
|
system_transaction::create_user_account(
|
||||||
&keypair1,
|
&keypair1,
|
||||||
&mint_keypair.pubkey(),
|
&mint_keypair.pubkey(),
|
||||||
2,
|
2,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
), // will collide
|
), // will collide
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -882,7 +870,6 @@ mod tests {
|
||||||
&keypair1.pubkey(),
|
&keypair1.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
||||||
let tx = system_transaction::create_user_account(
|
let tx = system_transaction::create_user_account(
|
||||||
|
@ -890,7 +877,6 @@ mod tests {
|
||||||
&keypair2.pubkey(),
|
&keypair2.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
||||||
|
|
||||||
|
@ -901,7 +887,6 @@ mod tests {
|
||||||
&keypair3.pubkey(),
|
&keypair3.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
|
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
|
||||||
let tx = system_transaction::create_user_account(
|
let tx = system_transaction::create_user_account(
|
||||||
|
@ -909,7 +894,6 @@ mod tests {
|
||||||
&keypair4.pubkey(),
|
&keypair4.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let entry_2 = next_entry(&entry_1.hash, 1, vec![tx]);
|
let entry_2 = next_entry(&entry_1.hash, 1, vec![tx]);
|
||||||
assert_eq!(process_entries(&bank, &[entry_1, entry_2]), Ok(()));
|
assert_eq!(process_entries(&bank, &[entry_1, entry_2]), Ok(()));
|
||||||
|
@ -933,7 +917,6 @@ mod tests {
|
||||||
&keypair1.pubkey(),
|
&keypair1.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
||||||
let tx = system_transaction::create_user_account(
|
let tx = system_transaction::create_user_account(
|
||||||
|
@ -941,7 +924,6 @@ mod tests {
|
||||||
&keypair2.pubkey(),
|
&keypair2.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
||||||
|
|
||||||
|
@ -952,7 +934,7 @@ mod tests {
|
||||||
|
|
||||||
// ensure bank can process 2 entries that do not have a common account and tick is registered
|
// ensure bank can process 2 entries that do not have a common account and tick is registered
|
||||||
let tx =
|
let tx =
|
||||||
system_transaction::create_user_account(&keypair2, &keypair3.pubkey(), 1, blockhash, 0);
|
system_transaction::create_user_account(&keypair2, &keypair3.pubkey(), 1, blockhash);
|
||||||
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
|
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
|
||||||
let tick = next_entry(&entry_1.hash, 1, vec![]);
|
let tick = next_entry(&entry_1.hash, 1, vec![]);
|
||||||
let tx = system_transaction::create_user_account(
|
let tx = system_transaction::create_user_account(
|
||||||
|
@ -960,7 +942,6 @@ mod tests {
|
||||||
&keypair4.pubkey(),
|
&keypair4.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let entry_2 = next_entry(&tick.hash, 1, vec![tx]);
|
let entry_2 = next_entry(&tick.hash, 1, vec![tx]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -976,7 +957,6 @@ mod tests {
|
||||||
&keypair3.pubkey(),
|
&keypair3.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let entry_3 = next_entry(&entry_2.hash, 1, vec![tx]);
|
let entry_3 = next_entry(&entry_2.hash, 1, vec![tx]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1007,13 +987,8 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Make sure other errors don't update the signature cache
|
// Make sure other errors don't update the signature cache
|
||||||
let tx = system_transaction::create_user_account(
|
let tx =
|
||||||
&mint_keypair,
|
system_transaction::create_user_account(&mint_keypair, &pubkey, 1000, Hash::default());
|
||||||
&pubkey,
|
|
||||||
1000,
|
|
||||||
Hash::default(),
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
let signature = tx.signatures[0];
|
let signature = tx.signatures[0];
|
||||||
|
|
||||||
// Should fail with blockhash not found
|
// Should fail with blockhash not found
|
||||||
|
@ -1040,14 +1015,12 @@ mod tests {
|
||||||
&keypair1.pubkey(),
|
&keypair1.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let fail_tx = system_transaction::create_user_account(
|
let fail_tx = system_transaction::create_user_account(
|
||||||
&mint_keypair,
|
&mint_keypair,
|
||||||
&keypair2.pubkey(),
|
&keypair2.pubkey(),
|
||||||
2,
|
2,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let entry_1_to_mint = next_entry(
|
let entry_1_to_mint = next_entry(
|
||||||
|
@ -1099,7 +1072,6 @@ mod tests {
|
||||||
&keypairs[i + NUM_TRANSFERS].pubkey(),
|
&keypairs[i + NUM_TRANSFERS].pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
)],
|
)],
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -1117,7 +1089,6 @@ mod tests {
|
||||||
&keypairs[i].pubkey(),
|
&keypairs[i].pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
)],
|
)],
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -122,7 +122,6 @@ mod tests {
|
||||||
&keypair.pubkey(),
|
&keypair.pubkey(),
|
||||||
1,
|
1,
|
||||||
one,
|
one,
|
||||||
0,
|
|
||||||
)],
|
)],
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -41,13 +41,8 @@ pub fn spend_and_verify_all_nodes(
|
||||||
.expect("balance in source");
|
.expect("balance in source");
|
||||||
assert!(bal > 0);
|
assert!(bal > 0);
|
||||||
let (blockhash, _fee_calculator) = client.get_recent_blockhash().unwrap();
|
let (blockhash, _fee_calculator) = client.get_recent_blockhash().unwrap();
|
||||||
let mut transaction = system_transaction::transfer(
|
let mut transaction =
|
||||||
&funding_keypair,
|
system_transaction::transfer(&funding_keypair, &random_keypair.pubkey(), 1, blockhash);
|
||||||
&random_keypair.pubkey(),
|
|
||||||
1,
|
|
||||||
blockhash,
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
let confs = VOTE_THRESHOLD_DEPTH + 1;
|
let confs = VOTE_THRESHOLD_DEPTH + 1;
|
||||||
let sig = client
|
let sig = client
|
||||||
.retry_transfer_until_confirmed(&funding_keypair, &mut transaction, 5, confs)
|
.retry_transfer_until_confirmed(&funding_keypair, &mut transaction, 5, confs)
|
||||||
|
@ -68,13 +63,8 @@ pub fn send_many_transactions(node: &ContactInfo, funding_keypair: &Keypair, num
|
||||||
.expect("balance in source");
|
.expect("balance in source");
|
||||||
assert!(bal > 0);
|
assert!(bal > 0);
|
||||||
let (blockhash, _fee_calculator) = client.get_recent_blockhash().unwrap();
|
let (blockhash, _fee_calculator) = client.get_recent_blockhash().unwrap();
|
||||||
let mut transaction = system_transaction::transfer(
|
let mut transaction =
|
||||||
&funding_keypair,
|
system_transaction::transfer(&funding_keypair, &random_keypair.pubkey(), 1, blockhash);
|
||||||
&random_keypair.pubkey(),
|
|
||||||
1,
|
|
||||||
blockhash,
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
client
|
client
|
||||||
.retry_transfer(&funding_keypair, &mut transaction, 5)
|
.retry_transfer(&funding_keypair, &mut transaction, 5)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -190,7 +180,6 @@ pub fn kill_entry_and_spend_and_verify_rest(
|
||||||
&random_keypair.pubkey(),
|
&random_keypair.pubkey(),
|
||||||
1,
|
1,
|
||||||
blockhash,
|
blockhash,
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let confs = VOTE_THRESHOLD_DEPTH + 1;
|
let confs = VOTE_THRESHOLD_DEPTH + 1;
|
||||||
|
|
|
@ -482,8 +482,8 @@ mod tests {
|
||||||
|
|
||||||
// First, verify entries
|
// First, verify entries
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
let tx0 = system_transaction::create_user_account(&keypair, &keypair.pubkey(), 0, zero, 0);
|
let tx0 = system_transaction::create_user_account(&keypair, &keypair.pubkey(), 0, zero);
|
||||||
let tx1 = system_transaction::create_user_account(&keypair, &keypair.pubkey(), 1, zero, 0);
|
let tx1 = system_transaction::create_user_account(&keypair, &keypair.pubkey(), 1, zero);
|
||||||
let mut e0 = Entry::new(&zero, 0, vec![tx0.clone(), tx1.clone()]);
|
let mut e0 = Entry::new(&zero, 0, vec![tx0.clone(), tx1.clone()]);
|
||||||
assert!(e0.verify(&zero));
|
assert!(e0.verify(&zero));
|
||||||
|
|
||||||
|
@ -533,7 +533,7 @@ mod tests {
|
||||||
fn test_next_entry_panic() {
|
fn test_next_entry_panic() {
|
||||||
let zero = Hash::default();
|
let zero = Hash::default();
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
let tx = system_transaction::create_user_account(&keypair, &keypair.pubkey(), 0, zero, 0);
|
let tx = system_transaction::create_user_account(&keypair, &keypair.pubkey(), 0, zero);
|
||||||
next_entry(&zero, 0, vec![tx]);
|
next_entry(&zero, 0, vec![tx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ mod tests {
|
||||||
fn test_serialized_to_blob_size() {
|
fn test_serialized_to_blob_size() {
|
||||||
let zero = Hash::default();
|
let zero = Hash::default();
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
let tx = system_transaction::create_user_account(&keypair, &keypair.pubkey(), 0, zero, 0);
|
let tx = system_transaction::create_user_account(&keypair, &keypair.pubkey(), 0, zero);
|
||||||
let entry = next_entry(&zero, 1, vec![tx.clone()]);
|
let entry = next_entry(&zero, 1, vec![tx.clone()]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Entry::serialized_to_blob_size(&[tx]),
|
Entry::serialized_to_blob_size(&[tx]),
|
||||||
|
|
|
@ -361,7 +361,6 @@ impl LocalCluster {
|
||||||
dest_pubkey,
|
dest_pubkey,
|
||||||
lamports,
|
lamports,
|
||||||
blockhash,
|
blockhash,
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
info!(
|
info!(
|
||||||
"executing transfer of {} from {} to {}",
|
"executing transfer of {} from {} to {}",
|
||||||
|
|
|
@ -676,7 +676,7 @@ mod tests {
|
||||||
fn test_to_packets() {
|
fn test_to_packets() {
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
let hash = Hash::new(&[1; 32]);
|
let hash = Hash::new(&[1; 32]);
|
||||||
let tx = system_transaction::create_user_account(&keypair, &keypair.pubkey(), 1, hash, 0);
|
let tx = system_transaction::create_user_account(&keypair, &keypair.pubkey(), 1, hash);
|
||||||
let rv = to_packets(&vec![tx.clone(); 1]);
|
let rv = to_packets(&vec![tx.clone(); 1]);
|
||||||
assert_eq!(rv.len(), 1);
|
assert_eq!(rv.len(), 1);
|
||||||
assert_eq!(rv[0].packets.len(), 1);
|
assert_eq!(rv[0].packets.len(), 1);
|
||||||
|
|
|
@ -422,7 +422,6 @@ impl Replicator {
|
||||||
1,
|
1,
|
||||||
1024 * 4, // TODO the account space needs to be well defined somewhere
|
1024 * 4, // TODO the account space needs to be well defined somewhere
|
||||||
&solana_storage_api::id(),
|
&solana_storage_api::id(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let signature = client.async_send_transaction(tx)?;
|
let signature = client.async_send_transaction(tx)?;
|
||||||
client
|
client
|
||||||
|
|
|
@ -499,10 +499,10 @@ mod tests {
|
||||||
let exit = Arc::new(AtomicBool::new(false));
|
let exit = Arc::new(AtomicBool::new(false));
|
||||||
|
|
||||||
let blockhash = bank.confirmed_last_blockhash();
|
let blockhash = bank.confirmed_last_blockhash();
|
||||||
let tx = system_transaction::transfer(&alice, pubkey, 20, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, pubkey, 20, blockhash);
|
||||||
bank.process_transaction(&tx).expect("process transaction");
|
bank.process_transaction(&tx).expect("process transaction");
|
||||||
|
|
||||||
let tx = system_transaction::transfer(&alice, &alice.pubkey(), 20, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &alice.pubkey(), 20, blockhash);
|
||||||
let _ = bank.process_transaction(&tx);
|
let _ = bank.process_transaction(&tx);
|
||||||
|
|
||||||
let request_processor = Arc::new(RwLock::new(JsonRpcRequestProcessor::new(
|
let request_processor = Arc::new(RwLock::new(JsonRpcRequestProcessor::new(
|
||||||
|
@ -542,7 +542,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let blockhash = bank.confirmed_last_blockhash();
|
let blockhash = bank.confirmed_last_blockhash();
|
||||||
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
|
||||||
bank.process_transaction(&tx).expect("process transaction");
|
bank.process_transaction(&tx).expect("process transaction");
|
||||||
})
|
})
|
||||||
.join()
|
.join()
|
||||||
|
@ -650,7 +650,7 @@ mod tests {
|
||||||
fn test_rpc_confirm_tx() {
|
fn test_rpc_confirm_tx() {
|
||||||
let bob_pubkey = Pubkey::new_rand();
|
let bob_pubkey = Pubkey::new_rand();
|
||||||
let (io, meta, blockhash, alice, _leader_id) = start_rpc_handler_with_tx(&bob_pubkey);
|
let (io, meta, blockhash, alice, _leader_id) = start_rpc_handler_with_tx(&bob_pubkey);
|
||||||
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
|
||||||
|
|
||||||
let req = format!(
|
let req = format!(
|
||||||
r#"{{"jsonrpc":"2.0","id":1,"method":"confirmTransaction","params":["{}"]}}"#,
|
r#"{{"jsonrpc":"2.0","id":1,"method":"confirmTransaction","params":["{}"]}}"#,
|
||||||
|
@ -669,7 +669,7 @@ mod tests {
|
||||||
fn test_rpc_get_signature_status() {
|
fn test_rpc_get_signature_status() {
|
||||||
let bob_pubkey = Pubkey::new_rand();
|
let bob_pubkey = Pubkey::new_rand();
|
||||||
let (io, meta, blockhash, alice, _leader_id) = start_rpc_handler_with_tx(&bob_pubkey);
|
let (io, meta, blockhash, alice, _leader_id) = start_rpc_handler_with_tx(&bob_pubkey);
|
||||||
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
|
||||||
|
|
||||||
let req = format!(
|
let req = format!(
|
||||||
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
|
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
|
||||||
|
@ -689,7 +689,7 @@ mod tests {
|
||||||
assert_eq!(expected, result);
|
assert_eq!(expected, result);
|
||||||
|
|
||||||
// Test getSignatureStatus request on unprocessed tx
|
// Test getSignatureStatus request on unprocessed tx
|
||||||
let tx = system_transaction::transfer(&alice, &bob_pubkey, 10, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &bob_pubkey, 10, blockhash);
|
||||||
let req = format!(
|
let req = format!(
|
||||||
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
|
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
|
||||||
tx.signatures[0]
|
tx.signatures[0]
|
||||||
|
@ -708,7 +708,7 @@ mod tests {
|
||||||
assert_eq!(expected, result);
|
assert_eq!(expected, result);
|
||||||
|
|
||||||
// Test getSignatureStatus request on a TransactionError
|
// Test getSignatureStatus request on a TransactionError
|
||||||
let tx = system_transaction::transfer(&alice, &alice.pubkey(), 20, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &alice.pubkey(), 20, blockhash);
|
||||||
let req = format!(
|
let req = format!(
|
||||||
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
|
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
|
||||||
tx.signatures[0]
|
tx.signatures[0]
|
||||||
|
@ -825,8 +825,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rpc_verify_signature() {
|
fn test_rpc_verify_signature() {
|
||||||
let tx =
|
let tx = system_transaction::transfer(&Keypair::new(), &Pubkey::new_rand(), 20, hash(&[0]));
|
||||||
system_transaction::transfer(&Keypair::new(), &Pubkey::new_rand(), 20, hash(&[0]), 0);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
verify_signature(&tx.signatures[0].to_string()).unwrap(),
|
verify_signature(&tx.signatures[0].to_string()).unwrap(),
|
||||||
tx.signatures[0]
|
tx.signatures[0]
|
||||||
|
|
|
@ -298,7 +298,7 @@ mod tests {
|
||||||
let rpc = RpcSolPubSubImpl::default();
|
let rpc = RpcSolPubSubImpl::default();
|
||||||
|
|
||||||
// Test signature subscriptions
|
// Test signature subscriptions
|
||||||
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
|
||||||
|
|
||||||
let session = create_session();
|
let session = create_session();
|
||||||
let (subscriber, _id_receiver, mut receiver) =
|
let (subscriber, _id_receiver, mut receiver) =
|
||||||
|
@ -333,7 +333,7 @@ mod tests {
|
||||||
let rpc = RpcSolPubSubImpl::default();
|
let rpc = RpcSolPubSubImpl::default();
|
||||||
io.extend_with(rpc.to_delegate());
|
io.extend_with(rpc.to_delegate());
|
||||||
|
|
||||||
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
|
||||||
let req = format!(
|
let req = format!(
|
||||||
r#"{{"jsonrpc":"2.0","id":1,"method":"signatureSubscribe","params":["{}"]}}"#,
|
r#"{{"jsonrpc":"2.0","id":1,"method":"signatureSubscribe","params":["{}"]}}"#,
|
||||||
tx.signatures[0].to_string()
|
tx.signatures[0].to_string()
|
||||||
|
@ -395,7 +395,6 @@ mod tests {
|
||||||
&contract_funds.pubkey(),
|
&contract_funds.pubkey(),
|
||||||
51,
|
51,
|
||||||
blockhash,
|
blockhash,
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
process_transaction_and_notify(&bank_forks, &tx, &rpc.subscriptions).unwrap();
|
process_transaction_and_notify(&bank_forks, &tx, &rpc.subscriptions).unwrap();
|
||||||
|
|
||||||
|
@ -439,8 +438,7 @@ mod tests {
|
||||||
assert_eq!(serde_json::to_string(&expected).unwrap(), response);
|
assert_eq!(serde_json::to_string(&expected).unwrap(), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
let tx =
|
let tx = system_transaction::create_user_account(&alice, &witness.pubkey(), 1, blockhash);
|
||||||
system_transaction::create_user_account(&alice, &witness.pubkey(), 1, blockhash, 0);
|
|
||||||
process_transaction_and_notify(&bank_forks, &tx, &rpc.subscriptions).unwrap();
|
process_transaction_and_notify(&bank_forks, &tx, &rpc.subscriptions).unwrap();
|
||||||
sleep(Duration::from_millis(200));
|
sleep(Duration::from_millis(200));
|
||||||
let ix = budget_instruction::apply_signature(
|
let ix = budget_instruction::apply_signature(
|
||||||
|
@ -514,7 +512,7 @@ mod tests {
|
||||||
let (subscriber, _id_receiver, mut receiver) = Subscriber::new_test("accountNotification");
|
let (subscriber, _id_receiver, mut receiver) = Subscriber::new_test("accountNotification");
|
||||||
rpc.account_subscribe(session, subscriber, bob.pubkey().to_string(), Some(2));
|
rpc.account_subscribe(session, subscriber, bob.pubkey().to_string(), Some(2));
|
||||||
|
|
||||||
let tx = system_transaction::transfer(&alice, &bob.pubkey(), 100, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &bob.pubkey(), 100, blockhash);
|
||||||
bank_forks
|
bank_forks
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -539,7 +537,7 @@ mod tests {
|
||||||
let (subscriber, _id_receiver, mut receiver) = Subscriber::new_test("accountNotification");
|
let (subscriber, _id_receiver, mut receiver) = Subscriber::new_test("accountNotification");
|
||||||
rpc.account_subscribe(session, subscriber, bob.pubkey().to_string(), Some(2));
|
rpc.account_subscribe(session, subscriber, bob.pubkey().to_string(), Some(2));
|
||||||
|
|
||||||
let tx = system_transaction::transfer(&alice, &bob.pubkey(), 100, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &bob.pubkey(), 100, blockhash);
|
||||||
bank_forks
|
bank_forks
|
||||||
.write()
|
.write()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
@ -320,7 +320,6 @@ mod tests {
|
||||||
1,
|
1,
|
||||||
16,
|
16,
|
||||||
&solana_budget_api::id(),
|
&solana_budget_api::id(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
bank_forks
|
bank_forks
|
||||||
.write()
|
.write()
|
||||||
|
@ -372,7 +371,6 @@ mod tests {
|
||||||
1,
|
1,
|
||||||
16,
|
16,
|
||||||
&solana_budget_api::id(),
|
&solana_budget_api::id(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
bank_forks
|
bank_forks
|
||||||
.write()
|
.write()
|
||||||
|
@ -416,7 +414,7 @@ mod tests {
|
||||||
let blockhash = bank.last_blockhash();
|
let blockhash = bank.last_blockhash();
|
||||||
let bank_forks = Arc::new(RwLock::new(BankForks::new(0, bank)));
|
let bank_forks = Arc::new(RwLock::new(BankForks::new(0, bank)));
|
||||||
let alice = Keypair::new();
|
let alice = Keypair::new();
|
||||||
let tx = system_transaction::transfer(&mint_keypair, &alice.pubkey(), 20, blockhash, 0);
|
let tx = system_transaction::transfer(&mint_keypair, &alice.pubkey(), 20, blockhash);
|
||||||
let signature = tx.signatures[0];
|
let signature = tx.signatures[0];
|
||||||
bank_forks
|
bank_forks
|
||||||
.write()
|
.write()
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub fn test_tx() -> Transaction {
|
||||||
let keypair1 = Keypair::new();
|
let keypair1 = Keypair::new();
|
||||||
let pubkey1 = keypair1.pubkey();
|
let pubkey1 = keypair1.pubkey();
|
||||||
let zero = Hash::default();
|
let zero = Hash::default();
|
||||||
system_transaction::create_user_account(&keypair1, &pubkey1, 42, zero, 0)
|
system_transaction::create_user_account(&keypair1, &pubkey1, 42, zero)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn test_multisig_tx() -> Transaction {
|
pub fn test_multisig_tx() -> Transaction {
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn test_rpc_send_tx() {
|
||||||
let blockhash: Hash = json["result"][0].as_str().unwrap().parse().unwrap();
|
let blockhash: Hash = json["result"][0].as_str().unwrap().parse().unwrap();
|
||||||
|
|
||||||
info!("blockhash: {:?}", blockhash);
|
info!("blockhash: {:?}", blockhash);
|
||||||
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
|
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash);
|
||||||
let serial_tx = serialize(&tx).unwrap();
|
let serial_tx = serialize(&tx).unwrap();
|
||||||
|
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
|
|
|
@ -154,7 +154,6 @@ fn test_replay() {
|
||||||
&bob_keypair.pubkey(),
|
&bob_keypair.pubkey(),
|
||||||
transfer_amount,
|
transfer_amount,
|
||||||
blockhash,
|
blockhash,
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let entry_tick1 = next_entry_mut(&mut cur_hash, i + 1, vec![]);
|
let entry_tick1 = next_entry_mut(&mut cur_hash, i + 1, vec![]);
|
||||||
let entry1 = next_entry_mut(&mut cur_hash, i + num_transfers, vec![tx0]);
|
let entry1 = next_entry_mut(&mut cur_hash, i + num_transfers, vec![tx0]);
|
||||||
|
|
|
@ -18,6 +18,6 @@ pub fn request_airdrop_transaction(
|
||||||
let key = Keypair::new();
|
let key = Keypair::new();
|
||||||
let to = Pubkey::new_rand();
|
let to = Pubkey::new_rand();
|
||||||
let blockhash = Hash::default();
|
let blockhash = Hash::default();
|
||||||
let tx = system_transaction::create_user_account(&key, &to, lamports, blockhash, 0);
|
let tx = system_transaction::create_user_account(&key, &to, lamports, blockhash);
|
||||||
Ok(tx)
|
Ok(tx)
|
||||||
}
|
}
|
||||||
|
|
|
@ -762,7 +762,7 @@ impl Bank {
|
||||||
/// `n` lamports where `blockhash` is the last Entry ID observed by the client.
|
/// `n` lamports where `blockhash` is the last Entry ID observed by the client.
|
||||||
pub fn transfer(&self, n: u64, keypair: &Keypair, to: &Pubkey) -> Result<Signature> {
|
pub fn transfer(&self, n: u64, keypair: &Keypair, to: &Pubkey) -> Result<Signature> {
|
||||||
let blockhash = self.last_blockhash();
|
let blockhash = self.last_blockhash();
|
||||||
let tx = system_transaction::create_user_account(keypair, to, n, blockhash, 0);
|
let tx = system_transaction::create_user_account(keypair, to, n, blockhash);
|
||||||
let signature = tx.signatures[0];
|
let signature = tx.signatures[0];
|
||||||
self.process_transaction(&tx).map(|_| signature)
|
self.process_transaction(&tx).map(|_| signature)
|
||||||
}
|
}
|
||||||
|
@ -1032,8 +1032,8 @@ mod tests {
|
||||||
let bank = Bank::new(&genesis_block);
|
let bank = Bank::new(&genesis_block);
|
||||||
assert_eq!(bank.last_blockhash(), genesis_block.hash());
|
assert_eq!(bank.last_blockhash(), genesis_block.hash());
|
||||||
|
|
||||||
let t1 = system_transaction::transfer(&mint_keypair, &key1, 1, genesis_block.hash(), 0);
|
let t1 = system_transaction::transfer(&mint_keypair, &key1, 1, genesis_block.hash());
|
||||||
let t2 = system_transaction::transfer(&mint_keypair, &key2, 1, genesis_block.hash(), 0);
|
let t2 = system_transaction::transfer(&mint_keypair, &key2, 1, genesis_block.hash());
|
||||||
let res = bank.process_transactions(&vec![t1.clone(), t2.clone()]);
|
let res = bank.process_transactions(&vec![t1.clone(), t2.clone()]);
|
||||||
assert_eq!(res.len(), 2);
|
assert_eq!(res.len(), 2);
|
||||||
assert_eq!(res[0], Ok(()));
|
assert_eq!(res[0], Ok(()));
|
||||||
|
@ -1106,7 +1106,6 @@ mod tests {
|
||||||
&dest.pubkey(),
|
&dest.pubkey(),
|
||||||
2,
|
2,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let signature = tx.signatures[0];
|
let signature = tx.signatures[0];
|
||||||
assert!(!bank.has_signature(&signature));
|
assert!(!bank.has_signature(&signature));
|
||||||
|
@ -1222,7 +1221,7 @@ mod tests {
|
||||||
let key2 = Keypair::new();
|
let key2 = Keypair::new();
|
||||||
|
|
||||||
let tx =
|
let tx =
|
||||||
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 2, genesis_block.hash(), 0);
|
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 2, genesis_block.hash());
|
||||||
let initial_balance = bank.get_balance(&leader);
|
let initial_balance = bank.get_balance(&leader);
|
||||||
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
||||||
assert_eq!(bank.get_balance(&leader), initial_balance + 3);
|
assert_eq!(bank.get_balance(&leader), initial_balance + 3);
|
||||||
|
@ -1230,7 +1229,7 @@ mod tests {
|
||||||
assert_eq!(bank.get_balance(&mint_keypair.pubkey()), 100 - 5);
|
assert_eq!(bank.get_balance(&mint_keypair.pubkey()), 100 - 5);
|
||||||
|
|
||||||
bank.fee_calculator.lamports_per_signature = 1;
|
bank.fee_calculator.lamports_per_signature = 1;
|
||||||
let tx = system_transaction::transfer(&key1, &key2.pubkey(), 1, genesis_block.hash(), 0);
|
let tx = system_transaction::transfer(&key1, &key2.pubkey(), 1, genesis_block.hash());
|
||||||
|
|
||||||
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
||||||
assert_eq!(bank.get_balance(&leader), initial_balance + 4);
|
assert_eq!(bank.get_balance(&leader), initial_balance + 4);
|
||||||
|
@ -1240,7 +1239,7 @@ mod tests {
|
||||||
|
|
||||||
// verify that an InstructionError collects fees, too
|
// verify that an InstructionError collects fees, too
|
||||||
let mut tx =
|
let mut tx =
|
||||||
system_transaction::transfer(&mint_keypair, &key2.pubkey(), 1, genesis_block.hash(), 0);
|
system_transaction::transfer(&mint_keypair, &key2.pubkey(), 1, genesis_block.hash());
|
||||||
// send a bogus instruction to system_program, cause an instruction error
|
// send a bogus instruction to system_program, cause an instruction error
|
||||||
tx.message.instructions[0].data[0] = 40;
|
tx.message.instructions[0].data[0] = 40;
|
||||||
|
|
||||||
|
@ -1260,9 +1259,9 @@ mod tests {
|
||||||
|
|
||||||
let key = Keypair::new();
|
let key = Keypair::new();
|
||||||
let tx1 =
|
let tx1 =
|
||||||
system_transaction::transfer(&mint_keypair, &key.pubkey(), 2, genesis_block.hash(), 0);
|
system_transaction::transfer(&mint_keypair, &key.pubkey(), 2, genesis_block.hash());
|
||||||
let tx2 =
|
let tx2 =
|
||||||
system_transaction::transfer(&mint_keypair, &key.pubkey(), 5, genesis_block.hash(), 0);
|
system_transaction::transfer(&mint_keypair, &key.pubkey(), 5, genesis_block.hash());
|
||||||
|
|
||||||
let results = vec![
|
let results = vec![
|
||||||
Ok(()),
|
Ok(()),
|
||||||
|
@ -1290,14 +1289,12 @@ mod tests {
|
||||||
&keypair.pubkey(),
|
&keypair.pubkey(),
|
||||||
2,
|
2,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let tx1 = system_transaction::create_user_account(
|
let tx1 = system_transaction::create_user_account(
|
||||||
&keypair,
|
&keypair,
|
||||||
&mint_keypair.pubkey(),
|
&mint_keypair.pubkey(),
|
||||||
1,
|
1,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let txs = vec![tx0, tx1];
|
let txs = vec![tx0, tx1];
|
||||||
let results = bank.process_transactions(&txs);
|
let results = bank.process_transactions(&txs);
|
||||||
|
@ -1319,7 +1316,6 @@ mod tests {
|
||||||
&alice.pubkey(),
|
&alice.pubkey(),
|
||||||
1,
|
1,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
let pay_alice = vec![tx1];
|
let pay_alice = vec![tx1];
|
||||||
|
|
||||||
|
@ -1354,13 +1350,8 @@ mod tests {
|
||||||
let keypair = Keypair::new();
|
let keypair = Keypair::new();
|
||||||
let bank = Bank::new(&genesis_block);
|
let bank = Bank::new(&genesis_block);
|
||||||
|
|
||||||
let tx = system_transaction::transfer(
|
let tx =
|
||||||
&mint_keypair,
|
system_transaction::transfer(&mint_keypair, &keypair.pubkey(), 1, genesis_block.hash());
|
||||||
&keypair.pubkey(),
|
|
||||||
1,
|
|
||||||
genesis_block.hash(),
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut tx_invalid_program_index = tx.clone();
|
let mut tx_invalid_program_index = tx.clone();
|
||||||
tx_invalid_program_index.message.instructions[0].program_ids_index = 42;
|
tx_invalid_program_index.message.instructions[0].program_ids_index = 42;
|
||||||
|
@ -1385,7 +1376,7 @@ mod tests {
|
||||||
|
|
||||||
bank.transfer(1, &mint_keypair, &key1.pubkey()).unwrap();
|
bank.transfer(1, &mint_keypair, &key1.pubkey()).unwrap();
|
||||||
assert_eq!(bank.get_balance(&key1.pubkey()), 1);
|
assert_eq!(bank.get_balance(&key1.pubkey()), 1);
|
||||||
let tx = system_transaction::transfer(&key1, &key1.pubkey(), 1, genesis_block.hash(), 0);
|
let tx = system_transaction::transfer(&key1, &key1.pubkey(), 1, genesis_block.hash());
|
||||||
let res = bank.process_transactions(&vec![tx.clone()]);
|
let res = bank.process_transactions(&vec![tx.clone()]);
|
||||||
assert_eq!(res.len(), 1);
|
assert_eq!(res.len(), 1);
|
||||||
assert_eq!(bank.get_balance(&key1.pubkey()), 1);
|
assert_eq!(bank.get_balance(&key1.pubkey()), 1);
|
||||||
|
@ -1420,7 +1411,7 @@ mod tests {
|
||||||
let parent = Arc::new(Bank::new(&genesis_block));
|
let parent = Arc::new(Bank::new(&genesis_block));
|
||||||
|
|
||||||
let tx =
|
let tx =
|
||||||
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash(), 0);
|
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash());
|
||||||
assert_eq!(parent.process_transaction(&tx), Ok(()));
|
assert_eq!(parent.process_transaction(&tx), Ok(()));
|
||||||
let bank = new_from_parent(&parent);
|
let bank = new_from_parent(&parent);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -1438,10 +1429,10 @@ mod tests {
|
||||||
let parent = Arc::new(Bank::new(&genesis_block));
|
let parent = Arc::new(Bank::new(&genesis_block));
|
||||||
|
|
||||||
let tx =
|
let tx =
|
||||||
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash(), 0);
|
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash());
|
||||||
assert_eq!(parent.process_transaction(&tx), Ok(()));
|
assert_eq!(parent.process_transaction(&tx), Ok(()));
|
||||||
let bank = new_from_parent(&parent);
|
let bank = new_from_parent(&parent);
|
||||||
let tx = system_transaction::transfer(&key1, &key2.pubkey(), 1, genesis_block.hash(), 0);
|
let tx = system_transaction::transfer(&key1, &key2.pubkey(), 1, genesis_block.hash());
|
||||||
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
assert_eq!(bank.process_transaction(&tx), Ok(()));
|
||||||
assert_eq!(parent.get_signature_status(&tx.signatures[0]), None);
|
assert_eq!(parent.get_signature_status(&tx.signatures[0]), None);
|
||||||
}
|
}
|
||||||
|
@ -1499,7 +1490,7 @@ mod tests {
|
||||||
let parent = Arc::new(Bank::new(&genesis_block));
|
let parent = Arc::new(Bank::new(&genesis_block));
|
||||||
|
|
||||||
let tx_transfer_mint_to_1 =
|
let tx_transfer_mint_to_1 =
|
||||||
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash(), 0);
|
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash());
|
||||||
trace!("parent process tx ");
|
trace!("parent process tx ");
|
||||||
assert_eq!(parent.process_transaction(&tx_transfer_mint_to_1), Ok(()));
|
assert_eq!(parent.process_transaction(&tx_transfer_mint_to_1), Ok(()));
|
||||||
trace!("done parent process tx ");
|
trace!("done parent process tx ");
|
||||||
|
@ -1519,7 +1510,7 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(bank.transaction_count(), parent.transaction_count());
|
assert_eq!(bank.transaction_count(), parent.transaction_count());
|
||||||
let tx_transfer_1_to_2 =
|
let tx_transfer_1_to_2 =
|
||||||
system_transaction::transfer(&key1, &key2.pubkey(), 1, genesis_block.hash(), 0);
|
system_transaction::transfer(&key1, &key2.pubkey(), 1, genesis_block.hash());
|
||||||
assert_eq!(bank.process_transaction(&tx_transfer_1_to_2), Ok(()));
|
assert_eq!(bank.process_transaction(&tx_transfer_1_to_2), Ok(()));
|
||||||
assert_eq!(bank.transaction_count(), 2);
|
assert_eq!(bank.transaction_count(), 2);
|
||||||
assert_eq!(parent.transaction_count(), 1);
|
assert_eq!(parent.transaction_count(), 1);
|
||||||
|
@ -1727,7 +1718,7 @@ mod tests {
|
||||||
let bank = Arc::new(Bank::new(&genesis_block));
|
let bank = Arc::new(Bank::new(&genesis_block));
|
||||||
let key1 = Keypair::new();
|
let key1 = Keypair::new();
|
||||||
let tx_transfer_mint_to_1 =
|
let tx_transfer_mint_to_1 =
|
||||||
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash(), 0);
|
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash());
|
||||||
assert_eq!(bank.process_transaction(&tx_transfer_mint_to_1), Ok(()));
|
assert_eq!(bank.process_transaction(&tx_transfer_mint_to_1), Ok(()));
|
||||||
assert_eq!(bank.is_delta.load(Ordering::Relaxed), true);
|
assert_eq!(bank.is_delta.load(Ordering::Relaxed), true);
|
||||||
}
|
}
|
||||||
|
@ -1741,7 +1732,7 @@ mod tests {
|
||||||
|
|
||||||
// Set is_delta to true
|
// Set is_delta to true
|
||||||
let tx_transfer_mint_to_1 =
|
let tx_transfer_mint_to_1 =
|
||||||
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash(), 0);
|
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash());
|
||||||
assert_eq!(bank.process_transaction(&tx_transfer_mint_to_1), Ok(()));
|
assert_eq!(bank.process_transaction(&tx_transfer_mint_to_1), Ok(()));
|
||||||
assert_eq!(bank.is_votable(), false);
|
assert_eq!(bank.is_votable(), false);
|
||||||
|
|
||||||
|
@ -1770,7 +1761,6 @@ mod tests {
|
||||||
&Keypair::new().pubkey(),
|
&Keypair::new().pubkey(),
|
||||||
1,
|
1,
|
||||||
genesis_block.hash(),
|
genesis_block.hash(),
|
||||||
0
|
|
||||||
)),
|
)),
|
||||||
Ok(())
|
Ok(())
|
||||||
);
|
);
|
||||||
|
@ -1868,7 +1858,6 @@ mod tests {
|
||||||
&keypair2.pubkey(),
|
&keypair2.pubkey(),
|
||||||
1,
|
1,
|
||||||
bank.last_blockhash(),
|
bank.last_blockhash(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Should fail with TransactionError::AccountNotFound, which means
|
// Should fail with TransactionError::AccountNotFound, which means
|
||||||
|
|
|
@ -117,8 +117,8 @@ mod tests {
|
||||||
let pubkey2 = Pubkey::new_rand();
|
let pubkey2 = Pubkey::new_rand();
|
||||||
|
|
||||||
let txs = vec![
|
let txs = vec![
|
||||||
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash()),
|
||||||
system_transaction::transfer(&keypair2, &pubkey2, 1, genesis_block.hash(), 0),
|
system_transaction::transfer(&keypair2, &pubkey2, 1, genesis_block.hash()),
|
||||||
];
|
];
|
||||||
|
|
||||||
(bank, txs)
|
(bank, txs)
|
||||||
|
|
|
@ -15,7 +15,6 @@ pub fn create_account(
|
||||||
lamports: u64,
|
lamports: u64,
|
||||||
space: u64,
|
space: u64,
|
||||||
program_id: &Pubkey,
|
program_id: &Pubkey,
|
||||||
_fee: u64,
|
|
||||||
) -> Transaction {
|
) -> Transaction {
|
||||||
let from_pubkey = from_keypair.pubkey();
|
let from_pubkey = from_keypair.pubkey();
|
||||||
let create_instruction =
|
let create_instruction =
|
||||||
|
@ -30,27 +29,13 @@ pub fn create_user_account(
|
||||||
to: &Pubkey,
|
to: &Pubkey,
|
||||||
lamports: u64,
|
lamports: u64,
|
||||||
recent_blockhash: Hash,
|
recent_blockhash: Hash,
|
||||||
fee: u64,
|
|
||||||
) -> Transaction {
|
) -> Transaction {
|
||||||
let program_id = system_program::id();
|
let program_id = system_program::id();
|
||||||
create_account(
|
create_account(from_keypair, to, recent_blockhash, lamports, 0, &program_id)
|
||||||
from_keypair,
|
|
||||||
to,
|
|
||||||
recent_blockhash,
|
|
||||||
lamports,
|
|
||||||
0,
|
|
||||||
&program_id,
|
|
||||||
fee,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create and sign new system_instruction::Assign transaction
|
/// Create and sign new system_instruction::Assign transaction
|
||||||
pub fn assign(
|
pub fn assign(from_keypair: &Keypair, recent_blockhash: Hash, program_id: &Pubkey) -> Transaction {
|
||||||
from_keypair: &Keypair,
|
|
||||||
recent_blockhash: Hash,
|
|
||||||
program_id: &Pubkey,
|
|
||||||
_fee: u64,
|
|
||||||
) -> Transaction {
|
|
||||||
let from_pubkey = from_keypair.pubkey();
|
let from_pubkey = from_keypair.pubkey();
|
||||||
let assign_instruction = system_instruction::assign(&from_pubkey, program_id);
|
let assign_instruction = system_instruction::assign(&from_pubkey, program_id);
|
||||||
let instructions = vec![assign_instruction];
|
let instructions = vec![assign_instruction];
|
||||||
|
@ -63,7 +48,6 @@ pub fn transfer(
|
||||||
to: &Pubkey,
|
to: &Pubkey,
|
||||||
lamports: u64,
|
lamports: u64,
|
||||||
recent_blockhash: Hash,
|
recent_blockhash: Hash,
|
||||||
_fee: u64,
|
|
||||||
) -> Transaction {
|
) -> Transaction {
|
||||||
let from_pubkey = from_keypair.pubkey();
|
let from_pubkey = from_keypair.pubkey();
|
||||||
let transfer_instruction = system_instruction::transfer(&from_pubkey, to, lamports);
|
let transfer_instruction = system_instruction::transfer(&from_pubkey, to, lamports);
|
||||||
|
|
|
@ -543,7 +543,6 @@ fn process_deploy(
|
||||||
1,
|
1,
|
||||||
program_data.len() as u64,
|
program_data.len() as u64,
|
||||||
&bpf_loader::id(),
|
&bpf_loader::id(),
|
||||||
0,
|
|
||||||
);
|
);
|
||||||
trace!("Creating program account");
|
trace!("Creating program account");
|
||||||
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&config.keypair]);
|
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&config.keypair]);
|
||||||
|
@ -598,7 +597,7 @@ fn process_pay(
|
||||||
let (blockhash, _fee_calculator) = rpc_client.get_recent_blockhash()?;
|
let (blockhash, _fee_calculator) = rpc_client.get_recent_blockhash()?;
|
||||||
|
|
||||||
if timestamp == None && *witnesses == None {
|
if timestamp == None && *witnesses == None {
|
||||||
let mut tx = system_transaction::transfer(&config.keypair, to, lamports, blockhash, 0);
|
let mut tx = system_transaction::transfer(&config.keypair, to, lamports, blockhash);
|
||||||
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&config.keypair]);
|
let result = rpc_client.send_and_confirm_transaction(&mut tx, &[&config.keypair]);
|
||||||
let signature_str = log_instruction_custom_error::<SystemError>(result)?;
|
let signature_str = log_instruction_custom_error::<SystemError>(result)?;
|
||||||
Ok(signature_str.to_string())
|
Ok(signature_str.to_string())
|
||||||
|
|
Loading…
Reference in New Issue