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

Commit f4b4842

Browse files
committed
shrink scope of this PR to bandaid
1 parent ad7d9c9 commit f4b4842

File tree

2 files changed

+2
-54
lines changed

2 files changed

+2
-54
lines changed

runtime/src/system_instruction_processor.rs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ fn assign_account_to_program(
134134
keyed_account: &mut KeyedAccount,
135135
program_id: &Pubkey,
136136
) -> Result<(), InstructionError> {
137-
// no work to do, just return
138-
if keyed_account.account.owner == *program_id {
139-
return Ok(());
140-
}
141-
142137
if keyed_account.signer_key().is_none() {
143138
debug!("Assign: account must sign");
144139
return Err(InstructionError::MissingRequiredSignature);
@@ -718,14 +713,6 @@ mod tests {
718713
),
719714
Err(InstructionError::MissingRequiredSignature)
720715
);
721-
// no change, no signature needed
722-
assert_eq!(
723-
assign_account_to_program(
724-
&mut KeyedAccount::new(&from, false, &mut from_account),
725-
&system_program::id(),
726-
),
727-
Ok(())
728-
);
729716

730717
assert_eq!(
731718
process_instruction(
@@ -842,45 +829,6 @@ mod tests {
842829
)
843830
}
844831

845-
#[test]
846-
fn test_create_account_no_transfer() {
847-
solana_logger::setup();
848-
let (genesis_config, alice_keypair) = create_genesis_config(100);
849-
let alice_pubkey = alice_keypair.pubkey();
850-
let bob_keypair = Keypair::new();
851-
let bob_pubkey = bob_keypair.pubkey();
852-
853-
// Fund to account to bypass AccountNotFound error
854-
let bank = Bank::new(&genesis_config);
855-
let bank_client = BankClient::new(bank);
856-
bank_client
857-
.transfer(50, &alice_keypair, &bob_pubkey)
858-
.unwrap();
859-
let program_id = Pubkey::new_rand();
860-
861-
// test system_instruction: that alice's signature is not asked for
862-
let instruction =
863-
system_instruction::create_account(&alice_pubkey, &bob_pubkey, 0, 1, &program_id);
864-
865-
assert!(!instruction.accounts[0].is_signer);
866-
867-
// test system_instruction_processor: that alice's signature is needed
868-
assert!(bank_client
869-
.send_instruction(&bob_keypair, instruction)
870-
.is_ok());
871-
872-
assert_eq!(bank_client.get_balance(&alice_pubkey).unwrap(), 50);
873-
assert_eq!(
874-
bank_client.get_account(&bob_pubkey).unwrap().unwrap(),
875-
Account {
876-
data: vec![0; 1],
877-
owner: program_id,
878-
lamports: 50,
879-
..Account::default()
880-
}
881-
);
882-
}
883-
884832
#[test]
885833
fn test_system_unsigned_transaction() {
886834
let (genesis_config, alice_keypair) = create_genesis_config(100);

sdk/src/system_instruction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub fn create_account(
147147
program_id: &Pubkey,
148148
) -> Instruction {
149149
let account_metas = vec![
150-
AccountMeta::new(*from_pubkey, lamports != 0), // no signature required if no transfer
150+
AccountMeta::new(*from_pubkey, true),
151151
AccountMeta::new(*to_pubkey, true),
152152
];
153153
Instruction::new(
@@ -173,7 +173,7 @@ pub fn create_account_with_seed(
173173
program_id: &Pubkey,
174174
) -> Instruction {
175175
let account_metas = vec![
176-
AccountMeta::new(*from_pubkey, lamports != 0),
176+
AccountMeta::new(*from_pubkey, true),
177177
AccountMeta::new(*to_pubkey, false),
178178
]
179179
.with_signer(base);

0 commit comments

Comments
 (0)