Pubky Testnet
A local test network for developing Pubky Core or applications depending on it.
All resources are ephemeral, including the database, and all servers are cleaned up when the testnet is dropped.
Quickstart
Option 1: Embedded PostgreSQL (No External DB Required)
For testing without a separate Postgres installation, enable the embedded-postgres feature:
[]
= { = "0.7", = ["embedded-postgres"] }
#
#
#
use EphemeralTestnet;
#
async
The first run will download PostgreSQL binaries (~50-100MB), which are cached for subsequent runs.
Option 2: External PostgreSQL
If you prefer to use an external Postgres instance:
# Example local Postgres with password auth
Then run the testnet binary:
TEST_PUBKY_CONNECTION_STRING='postgres://postgres:postgres@localhost:5432/postgres?pubky-test=true'
Usage
Writing Tests
use EphemeralTestnet;
// Macro ensures ephemeral Postgres databases are cleaned up
async
Custom Postgres Connection
By default (without embedded-postgres), testnet will use postgres://localhost:5432/postgres?pubky-test=true.
The ?pubky-test=true parameter indicates that the homeserver should create an ephemeral database.
To use a custom connection string:
Option A: Set the TEST_PUBKY_CONNECTION_STRING environment variable.
Option B: Pass the connection string programmatically:
use ;
async
Custom Configuration
use ;
async
Binary (Static Testnet)
If you need to run the testnet in a separate process (e.g., to test Pubky Core in browsers), run the binary which creates these components with hardcoded configurations: