Add support for BPF program custom errors (#5743)

* Add support for BPF program custom errors

* Rename SOL_SUCCESS -> SUCCESS
This commit is contained in:
Justin Starry
2019-09-06 16:05:01 -07:00
committed by GitHub
parent d3052d094c
commit 81c36699c4
26 changed files with 108 additions and 67 deletions

View File

@@ -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;
}