socialdept / atp-testnet
Stand up a local AT Protocol testnet for integration testing in PHP
Requires
- php: ^8.3
- guzzlehttp/guzzle: ^7.0|^8.0
- socialdept/atp-cbor: ^0.2
- symfony/process: ^7.0|^8.0
- textalk/websocket: ^1.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.89
- phpunit/phpunit: ^11.0|^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
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.
