Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

system-program: Remove zero lamport check on transfers #17726

Merged
merged 9 commits into from
Jun 5, 2021
Prev Previous commit
Update test to allow splitting into account with lamports
  • Loading branch information
joncinque committed Jun 4, 2021
commit bdd6da6f00d87edf28edfddeb258a94efb546af7
18 changes: 6 additions & 12 deletions runtime/tests/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use solana_sdk::{
message::Message,
pubkey::Pubkey,
signature::{Keypair, Signer},
system_instruction::SystemError,
sysvar::{self, stake_history::StakeHistory},
transaction::TransactionError,
};
use solana_stake_program::{
stake_instruction::{self},
Expand Down Expand Up @@ -171,7 +169,7 @@ fn test_stake_create_and_split_single_signature() {

#[test]
fn test_stake_create_and_split_to_existing_system_account() {
// Ensure stake-split does not allow the user to promote an existing system account into
// Ensure stake-split allows the user to promote an existing system account into
// a stake account.

solana_logger::setup();
Expand Down Expand Up @@ -229,7 +227,7 @@ fn test_stake_create_and_split_to_existing_system_account() {
existing_lamports
);

// Verify the split fails because the account is already in use
// Verify the split succeeds with lamports in the destination account
let message = Message::new(
&stake_instruction::split_with_seed(
&stake_address, // original
Expand All @@ -241,16 +239,12 @@ fn test_stake_create_and_split_to_existing_system_account() {
),
Some(&staker_keypair.pubkey()),
);
assert_eq!(
bank_client
.send_and_confirm_message(&[&staker_keypair], message)
.unwrap_err()
.unwrap(),
TransactionError::InstructionError(0, SystemError::AccountAlreadyInUse.into())
);
bank_client
.send_and_confirm_message(&[&staker_keypair], message)
.expect("failed to split into account with lamports");
assert_eq!(
bank_client.get_balance(&split_stake_address).unwrap(),
existing_lamports
existing_lamports + lamports / 2
);
}

Expand Down