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 1
1
OUT_DIR := ./target
2
2
SOLANA := ../../../solana
3
3
include $(SOLANA ) /sdk/bpf/c/bpf.mk
4
+
4
5
cpyth :
6
+ # Bundle C code compiled to bpf for use by rust
5
7
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)
171
171
}
172
172
return dispatch ( prm , ka );
173
173
}
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}"
30
30
make clean
31
31
make " ${@: 2} "
32
32
make cpyth
33
+ make cpythtest
33
34
rm ./target/* -keypair.json
34
35
35
36
36
37
# build Rust and link it with C
37
38
cd " ${PYTH_DIR} "
38
39
cargo clean
39
- cargo test
40
+ cargo test-bpf
40
41
cargo clean
41
42
cargo build-bpf
42
43
You can’t perform that action at this time.
0 commit comments