diff --git a/program/rust/src/lib.rs b/program/rust/src/lib.rs index 0e84109f5..560202684 100644 --- a/program/rust/src/lib.rs +++ b/program/rust/src/lib.rs @@ -2,11 +2,20 @@ //to reflect the current status of oracle.h mod c_oracle_header; +//do not link with C during unit tests (which are built in native architecture, unlike libpyth.o) +#[cfg(target_arch = "bpf")] #[link(name = "cpyth")] extern "C" { fn c_entrypoint(input: *mut u8) -> u64; } +//make the C entrypoint a no-op when running cargo test +#[cfg(not(target_arch = "bpf"))] +pub extern "C" fn c_entrypoint(input: *mut u8) -> u64{ + 0//SUCCESS value +} + + #[no_mangle] pub extern "C" fn entrypoint(input: *mut u8) -> u64 { let c_ret_val = unsafe{c_entrypoint(input)}; diff --git a/scripts/build-bpf.sh b/scripts/build-bpf.sh index e7a552352..95818a2ad 100755 --- a/scripts/build-bpf.sh +++ b/scripts/build-bpf.sh @@ -43,7 +43,10 @@ cd "${RUST_DIR}" cargo install bindgen bindgen ./src/bindings.h -o ./src/c_oracle_header.rs cargo clean +cargo test +cargo clean cargo build-bpf + sha256sum ./target/**/*.so rm ./target/**/*-keypair.json rm -r $PYTH_DIR/target || true @@ -52,3 +55,5 @@ mv ./target $PYTH_DIR/target + +