Attoshi E2E Tests#
Real end-to-end tests for the Attoshi token system. These tests use actual AT Protocol accounts to verify the full flow:
- Follow → Issuance - Following the entity DID triggers token issuance
- Cashtag → Transfer -
$attoshi <amount>in a reply transfers tokens to the parent author - Balance/UTXO queries - Verify balances and UTXOs
- State reset - Clean slate for next test run
Prerequisites#
You need 2 existing Bluesky accounts for testing. Create them at bsky.app if you don't have them.
Setup#
Option 1: Interactive Setup#
bun tests/e2e/setup-accounts.ts
This will prompt you for credentials and output the environment variables to set.
Option 2: Manual Setup#
-
Create app passwords for your test accounts at bsky.app/settings/app-passwords
-
Get session tokens by calling
createSession:
curl -X POST "https://bsky.social/xrpc/com.atproto.server.createSession" \
-H "Content-Type: application/json" \
-d '{"identifier": "your-handle.bsky.social", "password": "your-app-password"}'
- Set environment variables:
export AUTH_TOKEN="your-attoshi-admin-token"
export TEST_ACCOUNT_1_DID="did:plc:xxxxx"
export TEST_ACCOUNT_1_JWT="eyJ..."
export TEST_ACCOUNT_1_PDS="https://bsky.social"
export TEST_ACCOUNT_2_DID="did:plc:yyyyy"
export TEST_ACCOUNT_2_JWT="eyJ..."
export TEST_ACCOUNT_2_PDS="https://bsky.social"
Running Tests#
# Run E2E tests
bun test tests/e2e/real-flow.test.ts
# Or via npm script
bun test:e2e
What the Tests Do#
- Reset state to clean slate (0 issuances)
- Account 1 follows the entity → receives issuance tokens
- Account 2 follows the entity → receives issuance tokens
- Account 2 creates a post
- Account 1 replies with
$attoshi 10→ transfers 10 tokens to Account 2 - Verify balances changed correctly
- Query UTXOs and transactions
- Cleanup - delete follow records, reset state to 0
Notes#
- JWTs expire after ~2 hours. Re-run setup if tests fail with auth errors.
- The tests wait for the firehose to process events (3-6 seconds per action).
- State is reset at the start and end of tests for clean slate testing.