Search by

socialdept / atp-testnet

socialdept

Stand up a local AT Protocol testnet for integration testing in PHP

Package info

github.com/socialdept/atp-testnet

pkg:composer/socialdept/atp-testnet

Statistics

Installs: 192

Dependents: 0

Suggesters: 0

Stars: 6

Open Issues: 0

v0.2.4 2026-10-18 03:56 UTC

This package is auto-updated.

Last update: 2026-11-07 08:20:28 UTC


README

Testnet Header

Stand up a local AT Protocol testnet for integration testing in PHP.


This package runs a complete AT Protocol network on your machine with Docker Compose, so integration tests can talk to a real PLC directory, a real PDS and a real relay with a firehose instead of mocks. It creates accounts, signs PLC operations, resets state between tests and can spawn extra PDS containers that a test owns outright. To learn all about it, head over to the documentation.

Here are a few short examples of what you can do.

Boot the network and create an account:

use SocialDept\AtpTestnet\Testnet;

$testnet = Testnet::start();

$alice = $testnet->createAccount('alice');
echo $alice->did;    // did:plc:...
echo $alice->handle; // alice.test

Write a record and read the DID document back from the PLC directory:

$testnet->pds()->createRecord(
    'app.bsky.feed.post',
    ['$type' => 'app.bsky.feed.post', 'text' => 'Hello from testnet!', 'createdAt' => gmdate('c')],
    $alice->accessJwt,
);

$doc = $testnet->plc()->getDocument($alice->did);

Have the relay crawl the PDS and listen to the firehose:

$testnet->requestRelayCrawl();
$frames = $testnet->relay()->consumeFirehose(timeoutMs: 3000);

Use it from a test, with a clean slate before each one:

use SocialDept\AtpTestnet\Concerns\UsesTestnet;

uses(UsesTestnet::class);

beforeEach(function () {
    $this->testnet->resetAll();
});

Documentation

You'll find the documentation on https://socialde.pt/docs/atp-testnet.

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving it? Feel free to create an issue on GitHub.

Testing

vendor/bin/phpunit

The suite boots a real testnet, so Docker has to be running. CI runs vendor/bin/phpunit --exclude-group integration, which skips the tests that spawn extra PDS containers.

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see LICENSE for more information.