Skip to content

Commit d9f187d

Browse files
authored
Merge pull request #13 from pyth-network/abehjati/move-contract-test-to-a-local-crate
move contract test to a local crate
2 parents ccff4a3 + 7fc9820 commit d9f187d

File tree

15 files changed

+67
-35
lines changed

15 files changed

+67
-35
lines changed

.github/workflows/pyth-sdk-solana.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ jobs:
1717
working-directory: ./pyth-sdk-solana
1818
steps:
1919
- uses: actions/checkout@v2
20+
- name: Install dependencies
21+
run: sudo apt-get install libudev-dev
22+
- name: Build
23+
run: cargo build --verbose
24+
- name: Run tests
25+
run: cargo test --verbose
26+
test-contract:
27+
runs-on: ubuntu-latest
28+
defaults:
29+
run:
30+
working-directory: ./pyth-sdk-solana/test-contract
31+
steps:
32+
- uses: actions/checkout@v2
2033
- name: Install dependencies
2134
run: sudo apt-get install libudev-dev
2235
- name: Install Solana Binaries

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
members = [
44
"pyth-sdk",
55
"pyth-sdk-solana",
6+
"pyth-sdk-solana/test-contract",
67
]

pyth-sdk-solana/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ description = "pyth price oracle data structures and example usage"
1010
keywords = [ "pyth", "solana", "oracle" ]
1111
readme = "README.md"
1212

13-
[features]
14-
test-bpf = []
15-
no-entrypoint = []
16-
1713
[dependencies]
1814
solana-program = "1.8.1"
1915
borsh = "0.9"
@@ -26,7 +22,6 @@ serde = { version = "1.0.136", features = ["derive"] }
2622
pyth-sdk = { path = "../pyth-sdk" }
2723

2824
[dev-dependencies]
29-
solana-program-test = "1.8.1"
3025
solana-client = "1.8.1"
3126
solana-sdk = "1.8.1"
3227

pyth-sdk-solana/README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ Add a dependency to your Cargo.toml:
2121
pyth-sdk-solana="<version>"
2222
```
2323

24-
If you want to use this library in your on-chain program you should use `no-entrypoint` feature to prevent conflict between your program and this library's program.
25-
26-
```toml
27-
[dependencies]
28-
pyth-sdk-solana = {version = "<version>", features = ["no-entrypoint"]}
29-
```
30-
3124
See [pyth-sdk-solana on crates.io](https://crates.io/crates/pyth-sdk-solana/) to get the latest version of the library.
3225

3326
## Usage
@@ -188,7 +181,3 @@ product_account .. 6MEwdxe4g1NeAF9u6KDG14anJpFsVEa2cvr5H6iriFZ8
188181
This library can be built for either your native platform or in BPF (used by Solana programs).
189182
Use `cargo build` / `cargo test` to build and test natively.
190183
Use `cargo build-bpf` / `cargo test-bpf` to build in BPF for Solana; these commands require you to have installed the [Solana CLI tools](https://docs.solana.com/cli/install-solana-cli-tools).
191-
192-
The BPF tests will also run an instruction count program that logs the resource consumption
193-
of various library functions.
194-
This program can also be run on its own using `cargo test-bpf --test instruction_count`.

pyth-sdk-solana/src/lib.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ pub use self::error::PythError;
77
mod error;
88
pub mod state;
99

10-
pub mod entrypoint;
11-
pub mod instruction;
12-
pub mod processor;
13-
14-
// This is used only in local testing.
15-
solana_program::declare_id!("PythC11111111111111111111111111111111111111");
16-
1710
use state::load_price_account;
1811

1912
pub use pyth_sdk::{
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "test-contract"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
[features]
7+
test-bpf = []
8+
no-entrypoint = []
9+
10+
[dependencies]
11+
pyth-sdk-solana = { path = "../" }
12+
solana-program = "1.8.1"
13+
bytemuck = "1.7.2"
14+
borsh = "0.9"
15+
borsh-derive = "0.9.0"
16+
17+
[dev-dependencies]
18+
solana-program-test = "1.8.1"
19+
solana-client = "1.8.1"
20+
solana-sdk = "1.8.1"
21+
22+
[lib]
23+
crate-type = ["cdylib", "lib"]
24+
25+
[package.metadata.docs.rs]
26+
targets = ["x86_64-unknown-linux-gnu"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Pyth SDK Solana Test Contract
2+
This contract is used to test pyth-sdk-solana onchain.
3+
4+
## Development
5+
Use `cargo build-bpf` / `cargo test-bpf` to build in BPF for Solana; these commands require you to have installed the [Solana CLI tools](https://docs.solana.com/cli/install-solana-cli-tools).
6+
7+
The BPF tests will also run an instruction count program that logs the resource consumption
8+
of various library functions.
9+
This program can also be run on its own using `cargo test-bpf --test instruction_count`.
File renamed without changes.

pyth-sdk-solana/src/instruction.rs renamed to pyth-sdk-solana/test-contract/src/instruction.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
33
use bytemuck::bytes_of;
44

5-
use crate::state::PriceAccount;
6-
use crate::PriceStatus;
7-
8-
use crate::{
9-
id,
5+
use pyth_sdk_solana::state::PriceAccount;
6+
use pyth_sdk_solana::{
107
PriceConf,
8+
PriceStatus,
119
};
10+
11+
use crate::id;
1212
use borsh::{
1313
BorshDeserialize,
1414
BorshSerialize,

0 commit comments

Comments
 (0)