Add support for BPF program custom errors (#5743)
* Add support for BPF program custom errors * Rename SOL_SUCCESS -> SUCCESS
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
#include <solana_sdk.h>
|
||||
|
||||
/**
|
||||
* Custom error for when struct doesn't add to 12
|
||||
*/
|
||||
#define INCORRECT_SUM 1
|
||||
|
||||
struct test_struct { uint64_t x; uint64_t y; uint64_t z;};
|
||||
|
||||
static struct test_struct __attribute__ ((noinline)) test_function(void) {
|
||||
@@ -10,12 +15,11 @@ static struct test_struct __attribute__ ((noinline)) test_function(void) {
|
||||
return s;
|
||||
}
|
||||
|
||||
extern bool entrypoint(const uint8_t* input) {
|
||||
extern uint32_t entrypoint(const uint8_t* input) {
|
||||
struct test_struct s = test_function();
|
||||
sol_log("foobar");
|
||||
if (s.x + s.y + s.z == 12 ) {
|
||||
return true;
|
||||
return SUCCESS;
|
||||
}
|
||||
return false;
|
||||
return INCORRECT_SUM;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user