DarkSwap includes comprehensive tests for all components of the application. This ensures that the code is reliable and functions as expected.
To run all tests, use the following command:
./run-tests.shThis will run both unit tests and end-to-end tests.
Unit tests are written using Jest and test individual components of the application. To run only the unit tests:
npm testEnd-to-end tests are written using Playwright and test the application as a whole. To run only the end-to-end tests:
npm run test:e2eThe tests cover all major components of the application:
- Bitcoin transaction functionality
- Runes protocol integration
- Alkanes protocol integration
- P2P orderbook synchronization
- WebRTC functionality
- WebRTC wallet integration
If you encounter issues with the tests, you can run them in debug mode:
# Debug unit tests
npx jest --config=jest.config.js --debug
# Debug end-to-end tests
npx playwright test tests/e2e/trading.test.js --debugDarkSwap is a decentralized peer-to-peer trading platform for Bitcoin, runes, and alkanes. It enables trustless trading without requiring a central server or authority.
- P2P Networking: Decentralized peer-to-peer network for order discovery and matching
- WebRTC Support: Browser compatibility for web-based trading
- Circuit Relay: NAT traversal for peers behind firewalls
- Orderbook Management: Decentralized orderbook for trading pairs
- PSBT-Based Trading: Secure trade execution using PSBTs
- Runes and Alkanes Support: Trading of Bitcoin-based assets
- Web Interface: User-friendly web interface for trading
DarkSwap consists of the following components:
- DarkSwap Support: Shared code and protobuf definitions
- DarkSwap P2P: Core P2P networking library with WebRTC support
- DarkSwap SDK: Core library for building decentralized trading applications
- DarkSwap Web-Sys: WebAssembly bindings for browser integration
- DarkSwap Lib: TypeScript library for web applications
- DarkSwap Relay: Circuit relay server for NAT traversal
- DarkSwap Daemon: Background service for hosting an orderbook
- DarkSwap CLI: Command-line interface for interacting with the SDK
- DarkSwap Web: Web interface for trading
- Rust 1.70.0 or later
- Node.js 18.0.0 or later
- Yarn 1.22.0 or later
- Clone the repository:
git clone https://github.com/darkswap/darkswap.git
cd darkswap- Build all components:
./build.sh --all- Build specific components:
./build.sh --sdk --daemon --webcd darkswap-cli
cargo run -- --helpcd darkswap-daemon
cargo runcd web
yarn devdarkswap-cli create-order --base-asset BTC --quote-asset "RUNE:test_rune" --side buy --amount 1.0 --price 50000darkswap-cli take-order --order-id <order_id> --amount 0.5darkswap-cli list-orders --base-asset BTC --quote-asset "RUNE:test_rune"darkswap-cli market --base-asset BTC --quote-asset "RUNE:test_rune"darkswap/
├── darkswap-support/ # Shared code and protobuf definitions
├── darkswap-p2p/ # Core P2P networking library
├── darkswap-sdk/ # Core SDK
├── darkswap-web-sys/ # WebAssembly bindings
├── darkswap-lib/ # TypeScript library
├── darkswap-relay/ # Circuit relay server
├── darkswap-daemon/ # Background service
├── darkswap-cli/ # Command-line interface
├── web/ # Web interface
├── reference/ # Reference documentation
└── memory-bank/ # Project documentation
┌───────────────────────────────────────────────────────────────────────────┐
│ darkswap-support │
│ (Protobuf & Shared Code) │
└───────────────────────────────────────────────────────────────────────────┘
▲ ▲
│ │
│ │
┌────────────────┴─────────────────┐ ┌─────────────┴─────────────────┐
│ │ │ │
│ darkswap-p2p │ │ darkswap-web-sys │
│ (Rust P2P Networking) │ │ (WASM Bindings) │
└────────────────┬─────────────────┘ └─────────────┬─────────────────┘
▲ ▲
│ │
│ │
┌────────────────┴─────────────────┐ ┌─────────────┴─────────────────┐
│ │ │ │
│ darkswap-sdk │ │ darkswap-lib │
│ (Rust Trading SDK) │ │ (TypeScript Library) │
└────────────────┬─────────────────┘ └─────────────┬─────────────────┘
▲ ▲
│ │
│ │
┌────────────────┴─────────┐ ┌───────────┐ ┌─────────┴─────────────────┐
│ │ │ │ │ │
│ darkswap-relay │ │darkswap- │ │ darkswap-app │
│ (Circuit Relay) │ │ daemon │ │ (Web Interface) │
└──────────────────────────┘ └───────────┘ └───────────────────────────┘
cd darkswap-sdk
cargo testcd darkswap-sdk
cargo doc --openThe project is currently in Phase 1 of development, focusing on the core P2P infrastructure. Recent achievements include:
- Fixed WebSocket event handling in handlers.rs
- Verified OrderId import from orderbook module in api.rs
- Implemented core SDK with P2P networking, orderbook management, and trade execution
- Added WebRTC transport for browser compatibility
- Implemented PSBT-based trade execution for secure atomic swaps
- Added Bitcoin wallet integration
Next steps include:
- Completing the runes and alkanes support
- Implementing the WebAssembly bindings
- Developing the TypeScript library
- Setting up the relay server
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Subfrost for the circuit relay implementation
- PintSwap for the P2P orderbook and trading functionality
- rust-libp2p for the P2P networking library
- bitcoin for the Bitcoin library