Impl get_/set_return_data syscalls for ProgramTest (#22647)

* Remove &mut self from set_return_data

* Impl get_/set_return_data for program-test SyscallStubs

* Add return_data program-test
This commit is contained in:
Tyera Eulberg
2022-01-21 17:05:48 -07:00
committed by GitHub
parent 4d00995d2d
commit fc8130955a
3 changed files with 106 additions and 2 deletions

View File

@ -87,7 +87,7 @@ pub trait SyscallStubs: Sync + Send {
fn sol_get_return_data(&self) -> Option<(Pubkey, Vec<u8>)> {
None
}
fn sol_set_return_data(&mut self, _data: &[u8]) {}
fn sol_set_return_data(&self, _data: &[u8]) {}
fn sol_log_data(&self, fields: &[&[u8]]) {
println!("data: {}", fields.iter().map(base64::encode).join(" "));
}
@ -170,7 +170,7 @@ pub(crate) fn sol_get_return_data() -> Option<(Pubkey, Vec<u8>)> {
}
pub(crate) fn sol_set_return_data(data: &[u8]) {
SYSCALL_STUBS.write().unwrap().sol_set_return_data(data)
SYSCALL_STUBS.read().unwrap().sol_set_return_data(data)
}
pub(crate) fn sol_log_data(data: &[&[u8]]) {