Fix zero-len slice translations (#12642)
This commit is contained in:
@ -115,6 +115,18 @@ extern uint64_t entrypoint(const uint8_t *input) {
|
||||
sol_invoke(&instruction, accounts, SOL_ARRAY_SIZE(accounts)));
|
||||
}
|
||||
|
||||
sol_log("Test no instruction data");
|
||||
{
|
||||
SolAccountMeta arguments[] = {{accounts[ARGUMENT_INDEX].key, true, true}};
|
||||
uint8_t data[] = {};
|
||||
const SolInstruction instruction = {accounts[INVOKED_PROGRAM_INDEX].key,
|
||||
arguments, SOL_ARRAY_SIZE(arguments),
|
||||
data, SOL_ARRAY_SIZE(data)};
|
||||
|
||||
sol_assert(SUCCESS ==
|
||||
sol_invoke(&instruction, accounts, SOL_ARRAY_SIZE(accounts)));
|
||||
}
|
||||
|
||||
sol_log("Test return error");
|
||||
{
|
||||
SolAccountMeta arguments[] = {{accounts[ARGUMENT_INDEX].key, true, true}};
|
||||
|
@ -12,6 +12,10 @@ extern uint64_t entrypoint(const uint8_t *input) {
|
||||
return ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (params.data_len == 0) {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
switch (params.data[0]) {
|
||||
case TEST_VERIFY_TRANSLATIONS: {
|
||||
sol_log("verify data translations");
|
||||
|
@ -117,6 +117,16 @@ fn process_instruction(
|
||||
invoke(&instruction, accounts)?;
|
||||
}
|
||||
|
||||
info!("Test no instruction data");
|
||||
{
|
||||
let instruction = create_instruction(
|
||||
*accounts[INVOKED_PROGRAM_INDEX].key,
|
||||
&[(accounts[ARGUMENT_INDEX].key, true, true)],
|
||||
vec![],
|
||||
);
|
||||
invoke(&instruction, accounts)?;
|
||||
}
|
||||
|
||||
info!("Test return error");
|
||||
{
|
||||
let instruction = create_instruction(
|
||||
|
@ -21,6 +21,10 @@ fn process_instruction(
|
||||
) -> ProgramResult {
|
||||
info!("Invoked program");
|
||||
|
||||
if instruction_data.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
match instruction_data[0] {
|
||||
TEST_VERIFY_TRANSLATIONS => {
|
||||
info!("verify data translations");
|
||||
|
@ -536,6 +536,7 @@ fn test_program_bpf_invoke() {
|
||||
invoked_program_id.clone(),
|
||||
invoked_program_id.clone(),
|
||||
invoked_program_id.clone(),
|
||||
invoked_program_id.clone(),
|
||||
]
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user