File tree Expand file tree Collapse file tree 4 files changed +35
-1
lines changed Expand file tree Collapse file tree 4 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 11OUT_DIR := ./target
22SOLANA := ../../../solana
33include $(SOLANA ) /sdk/bpf/c/bpf.mk
4+
45cpyth :
6+ # Bundle C code compiled to bpf for use by rust
57 bash -c "ar rcs target/libcpyth.a target/**/*.o"
8+ cpythtest :
9+ # Compile C code to system architecture for use by rust's cargo test
10+ $(CC) -c ./src/oracle/for_cargo_test/cpyth_test.c -o ./target/cpyth_test.o
11+ # Bundle C code compiled to system architecture for use by rust's cargo test
12+ ar rcs target/libcpythtest.a ./target/cpyth_test.o
Original file line number Diff line number Diff line change 1+ /// The goal of this file is to provide the upd_aggregate function to local rust tests
2+
3+ /// We need to allocate some heap space for upd_aggregate
4+ /// When compiling for the solana runtime, the heap space is preallocated and PC_HEAP_START is provided by <solana.h>
5+ char heap_start [8192 ];
6+ #define PC_HEAP_START (heap_start)
7+ #define static_assert _Static_assert
8+
9+ typedef signed char int8_t ;
10+ typedef unsigned char uint8_t ;
11+ typedef signed short int16_t ;
12+ typedef unsigned short uint16_t ;
13+ typedef signed int int32_t ;
14+ typedef unsigned int uint32_t ;
15+ typedef signed long int int64_t ;
16+ typedef unsigned long int uint64_t ;
17+
18+ #include "../upd_aggregate.h"
19+
20+ extern bool c_upd_aggregate ( pc_price_t * ptr , uint64_t slot , int64_t timestamp ){
21+ return upd_aggregate (ptr , slot , timestamp );
22+ }
Original file line number Diff line number Diff line change @@ -171,3 +171,7 @@ extern uint64_t c_entrypoint(const uint8_t *input)
171171 }
172172 return dispatch ( prm , ka );
173173}
174+
175+ extern bool c_upd_aggregate ( pc_price_t * ptr , uint64_t slot , int64_t timestamp ){
176+ return upd_aggregate (ptr , slot , timestamp );
177+ }
Original file line number Diff line number Diff line change @@ -30,13 +30,14 @@ export V="${V:-1}"
3030make clean
3131make " ${@: 2} "
3232make cpyth
33+ make cpythtest
3334rm ./target/* -keypair.json
3435
3536
3637# build Rust and link it with C
3738cd " ${PYTH_DIR} "
3839cargo clean
39- cargo test
40+ cargo test-bpf
4041cargo clean
4142cargo build-bpf
4243
You can’t perform that action at this time.
0 commit comments