Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spl-pod = "0.7.1"
thiserror = "2.0"

[lib]
crate-type = ["cdylib", "lib"]
crate-type = ["lib"]

[lints]
workspace = true
Expand Down
28 changes: 28 additions & 0 deletions interface/src/onchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ pub fn invoke_execute<'a>(
)?;
}

// Demote all signers
cpi_instruction
.accounts
.iter_mut()
.for_each(|a| a.is_signer = false);

invoke(&cpi_instruction, &cpi_account_infos)
}

Expand Down Expand Up @@ -508,4 +514,26 @@ mod tests {
assert_eq!(a.is_writable, b.is_writable);
}
}

#[test]
fn test_signer_demotion_sanity() {
// This test doesn't actually run any functions in this file, but checks
// that demotion works as expected.
let mut instruction = instruction::execute(
&Pubkey::new_unique(),
&Pubkey::new_unique(),
&Pubkey::new_unique(),
&Pubkey::new_unique(),
&Pubkey::new_unique(),
100,
);
instruction
.accounts
.push(AccountMeta::new(Pubkey::new_unique(), true));
instruction
.accounts
.iter_mut()
.for_each(|a| a.is_signer = false);
assert!(instruction.accounts.iter().all(|a| !a.is_signer));
}
}