You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+95-13Lines changed: 95 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -10,20 +10,27 @@ Note that only permissioned publishers can publish data to the network. Please r
10
10
11
11
Prerequisites: Rust 1.68 or higher. A Unix system is recommended.
12
12
13
-
```bash
14
-
# Install OpenSSL
15
-
apt install libssl-dev
13
+
```shell
14
+
# Install OpenSSL (Debian-based systems)
15
+
$ apt install libssl-dev
16
+
17
+
# Install Rust
18
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
19
+
$ rustup default 1.68 # Optional
16
20
17
21
# Build the project. This will produce a binary at target/release/agent
18
-
cargo build --release
22
+
$ cargo build --release
19
23
```
20
24
21
25
## Configure
22
-
Configuration is managed through a configuration file. An example configuration file with sensible defaults can be found at [config/config.toml](config/config.toml).
26
+
The agent takes a single `--config` CLI option, pointing at
27
+
`config/config.toml` by default. An example configuration is provided
28
+
there, containing a minimal set of mandatory options and documentation
29
+
comments for optional settings. **The config file must exist.**
23
30
24
-
The logging level can be configured at runtime through the `RUST_LOG` environment variable, using [env_logger](https://docs.rs/env_logger/latest/env_logger/)'s scheme. For example, to log at `debug` instead of the default `info` level, set `RUST_LOG=debug`.
25
-
26
-
## Run
31
+
The logging level can be configured at runtime
32
+
through the `RUST_LOG` environment variable using the standard
33
+
`error|warn|info|debug|trace` levels.
27
34
28
35
### Key Store
29
36
If you already have a key store set up, you can skip this step. If you haven't, you will need to create one before publishing data. A key store contains the cryptographic keys needed to publish data. Once you have a key store set up, please ensure that the configuration file mentioned above contains the correct path to your key store.
@@ -44,11 +51,86 @@ PYTH_KEY_ENV=devnet # Can be devnet, testnet or mainnet
`cargo run --release -- --config <your_config.toml>` will build and run the agent in a single step.
56
+
57
+
## Publishing API
58
+
A running agent will expose a WebSocket serving the JRPC publishing API documented [here](https://docs.pyth.network/publish-data/pyth-client-websocket-api). See `config/config.toml` for related settings.
59
+
60
+
# Development
61
+
## Unit Testing
62
+
A collection of Rust unit tests is provided, ran with `cargo test`.
63
+
64
+
## Integration Testing
65
+
In `integration-tests`, we provide end-to-end tests for the Pyth
66
+
`agent` binary against a running `solana-test-validator` with Pyth
67
+
oracle deployed to it. Optionally, accumulator message buffer program
68
+
can be deployed and used to validate accumulator CPI correctness
69
+
end-to-end (see configuration options below). Prebuilt binaries are
70
+
provided manually in `integration-tests/program-binaries` - see below
71
+
for more context.
72
+
73
+
### Running Integration Tests
74
+
The tests are implemented as a Python package containing a `pytest`
75
+
test suite, managed with [Poetry](https://python-poetry.org/) under
76
+
Python >3.10. Use following commands to install and run them:
77
+
48
78
```bash
49
-
# Run the agent binary, which will start a JRPC websocket API server.
You can now publish data to the Pyth Network using the JRPC websocket API documented [here](https://docs.pyth.network/publish-data/pyth-client-websocket-api).
84
+
### Optional Integration Test Configuration
85
+
*`USE_ACCUMULATOR`, off by default - when this env is set, the test
86
+
framework also deploys the accumulator program
87
+
(`message_buffer.so`), initializes it and configures the agent to
88
+
make accumulator-enabled calls into the oracle
89
+
*`SOLANA_TEST_VALIDATOR`, systemwide `solana-test-validator` by
90
+
default - when this env is set, the specified binary is used as the
91
+
test validator. This is especially useful with `USE_ACCUMULATOR`,
92
+
enabling life-like accumulator output from the `pythnet` validator.
93
+
94
+
### Testing Setup Overview
95
+
For each test's setup in `integration-tests/tests/test_integration.py`, we:
96
+
* Start `solana-test-validator` with prebuilt Solana programs deployed
97
+
* Generate and fund test Solana keypairs
98
+
* Initialize the oracle program - allocate test price feeds, assign
99
+
publishing permissions. This is done using the dedicated [`program-admin`](https://github.com/pyth-network/program-admin) Python package.
100
+
* (Optionally) Initialize accumulator message buffer program
101
+
initialize test authority, preallocate message buffers, assign
102
+
allowed program permissions to the oracle - this is done using a
103
+
generated client package in
104
+
`integration-tests/message_buffer_client_codegen`, created using
0 commit comments