failed admin test

This commit is contained in:
Hardhat Chad
2024-02-16 20:04:14 +00:00
parent 879c39d00d
commit abba4122fb
3 changed files with 8 additions and 2 deletions

View File

@@ -23,7 +23,7 @@ pub fn process_update_admin<'a, 'info>(
// Validate admin signer
let mut treasury_data = treasury_info.data.borrow_mut();
let mut treasury = Treasury::try_from_bytes_mut(&mut treasury_data)?;
if !treasury.admin.eq(&signer.key) {
if treasury.admin.ne(&signer.key) {
return Err(ProgramError::MissingRequiredSignature);
}

View File

@@ -25,7 +25,7 @@ pub fn process_update_difficulty<'a, 'info>(
// Validate admin signer
let mut treasury_data = treasury_info.data.borrow_mut();
let mut treasury = Treasury::try_from_bytes_mut(&mut treasury_data)?;
if !treasury.admin.eq(&signer.key) {
if treasury.admin.ne(&signer.key) {
return Err(ProgramError::MissingRequiredSignature);
}

View File

@@ -40,6 +40,12 @@ async fn test_update_admin() {
treasury_.total_claimed_rewards,
treasury.total_claimed_rewards
);
// Submit another update admin ix
let ix = ore::instruction::update_admin(payer.pubkey(), payer.pubkey());
let tx = Transaction::new_signed_with_payer(&[ix], Some(&payer.pubkey()), &[&payer], blockhash);
let res = banks.process_transaction(tx).await;
assert!(res.is_err());
}
async fn setup_program_test_env() -> (BanksClient, Keypair, Hash) {