Allow BPF structure passing and returning (#2100)

* Add BPF struct passing and returning tests
This commit is contained in:
jackcmay
2018-12-11 09:03:37 -08:00
committed by GitHub
parent 166945a461
commit e3dfd7b1ab
5 changed files with 68 additions and 21 deletions

View File

@ -0,0 +1,17 @@
#include <solana_sdk.h>
struct foo {const uint8_t *input;};
void foo(const uint8_t *input, struct foo foo) ;
extern bool entrypoint(const uint8_t *input) {
struct foo f;
f.input = input;
foo(input, f);
return true;
}
void foo(const uint8_t *input, struct foo foo) {
sol_log_64(0, 0, 0, (uint64_t)input, (uint64_t)foo.input);
sol_assert(input == foo.input);
}

View File

@ -0,0 +1,18 @@
#include <solana_sdk.h>
struct foo {const uint8_t *input;};
struct foo bar(const uint8_t *input);
extern bool entrypoint(const uint8_t *input) {
struct foo foo = bar(input);
sol_log_64(0, 0, 0, (uint64_t)input, (uint64_t)foo.input);
sol_assert(input == foo.input);
return true;
}
struct foo bar(const uint8_t *input) {
struct foo foo;
foo.input = input;
return foo;
}