Add Close instrruction and tooling to upgradeable loader (#15887)

This commit is contained in:
Jack May
2021-03-17 21:39:29 -07:00
committed by GitHub
parent 12399157f5
commit 7f500d610c
9 changed files with 980 additions and 64 deletions

View File

@@ -131,6 +131,17 @@ pub fn parse_bpf_upgradeable_loader(
}),
})
}
UpgradeableLoaderInstruction::Close => {
check_num_bpf_upgradeable_loader_accounts(&instruction.accounts, 3)?;
Ok(ParsedInstructionEnum {
instruction_type: "close".to_string(),
info: json!({
"account": account_keys[instruction.accounts[0] as usize].to_string(),
"recipient": account_keys[instruction.accounts[1] as usize].to_string(),
"authority": account_keys[instruction.accounts[2] as usize].to_string()
}),
})
}
}
}
@@ -352,5 +363,20 @@ mod test {
}
);
assert!(parse_bpf_upgradeable_loader(&message.instructions[0], &keys[0..1]).is_err());
let instruction = solana_sdk::bpf_loader_upgradeable::close(&keys[0], &keys[1], &keys[2]);
let message = Message::new(&[instruction], None);
assert_eq!(
parse_bpf_upgradeable_loader(&message.instructions[0], &keys[..3]).unwrap(),
ParsedInstructionEnum {
instruction_type: "close".to_string(),
info: json!({
"account": keys[1].to_string(),
"recipient": keys[2].to_string(),
"authority": keys[0].to_string(),
}),
}
);
assert!(parse_bpf_upgradeable_loader(&message.instructions[0], &keys[0..1]).is_err());
}
}