Sui indexer is an off-fullnode service to serve data from Sui protocol, including both data directly generated from chain and derivative data.
- install local Postgres server
- install Diesel CLI, you can follow the Diesel Getting Started guide up to the Write Rust section
- [optional but handy] Postgres client like Postico, for local check, query execution etc.
- DB setup, under
sui/crates/sui-indexer
run:
# an example DATABASE_URL is "postgres://postgres:postgres@localhost/gegao"
diesel setup --database-url="<DATABASE_URL>"
diesel migration run --database-url="<DATABASE_URL>"
- Checkout devnet
git fetch upstream devnet && git reset --hard upstream/devnet
- Start indexer binary, under
sui/crates/sui-indexer
run:
# Change the RPC_CLIENT_URL to http://0.0.0.0:9000 to run indexer against local validator & fullnode
cargo run --bin sui-indexer -- --db-url "<DATABASE_URL>" --rpc-client-url "https://fullnode.devnet.sui.io:443"
diesel database reset --database-url="<DATABASE_URL>"
Integration tests in the integration_tests.rs
will be run by GitHub action as part of the CI checks
to run the test locally, start a Postgresql DB and run the test using following command:
POSTGRES_PORT=5432 cargo test --package sui-indexer --test integration_tests --features pg_integration
Note: all existing data will be wiped during the test.