This commit is contained in:
Raven Scott
2025-12-17 20:05:50 -05:00
commit 742e27d3f7
276 changed files with 89838 additions and 0 deletions
+107
View File
@@ -0,0 +1,107 @@
# Test Scripts for Plugin SDK Replication
This directory contains test scripts for researching and developing HyperDB and Hyperdrive replication over the global topic.
## Scripts
### test-sdk-integration.js
Tests basic SDK integration including plugin domain reading from config.json and global topic access.
### test-sdk-methods.js
Tests SDK methods to ensure they work correctly with the new plugin context system.
### test-replication-managers.js
Tests the replication managers to ensure they use the global topic correctly.
### test-sdk-hyperdb-replication.js ⭐ **Real-World Example**
Comprehensive test demonstrating HyperDB usage through the SDK:
- Setting up HyperDB from config.json
- Using SDK methods (insert, get, find, flush)
- Replication setup with global topic
- Real-world plugin structure
### test-sdk-hyperdrive-replication.js ⭐ **Real-World Example**
Comprehensive test demonstrating Hyperdrive usage through the SDK:
- Creating Hyperdrive instances via SDK
- Storing and retrieving files
- File operations (list, read, delete, symlink)
- Replication setup with global topic
- Real-world plugin structure
### test-p2p-hyperdb-simple.js ⭐ **Peer-to-Peer Test**
Simplified peer-to-peer HyperDB replication test:
- Two peers in same process
- Peer1 inserts data, Peer2 receives it
- Peer2 inserts data, Peer1 receives it
- Verifies bidirectional replication works
- Uses global topic for replication
### test-p2p-hyperdrive-simple.js ⭐ **Peer-to-Peer Test**
Simplified peer-to-peer Hyperdrive replication test:
- Two peers in same process
- Peer1 writes files, Peer2 receives them
- Peer2 writes files, Peer1 receives them
- Verifies bidirectional file replication works
- Uses global topic for replication
### test-p2p-hyperdb-replication.js (Advanced)
Full peer-to-peer test with separate processes. Requires network connectivity for DHT discovery.
### test-p2p-hyperdrive-replication.js (Advanced)
Full peer-to-peer test with separate processes. Requires network connectivity for DHT discovery.
### test-hyperdb-replication.js (Legacy)
Low-level HyperDB replication test. Use `test-sdk-hyperdb-replication.js` for SDK-based testing.
### test-hyperdrive-replication.js (Legacy)
Low-level Hyperdrive replication test. Use `test-sdk-hyperdrive-replication.js` for SDK-based testing.
## Usage
### Recommended: Real-World SDK Tests
Run the comprehensive SDK tests that demonstrate actual plugin usage:
```bash
# Test HyperDB with SDK
node test-scripts/test-sdk-hyperdb-replication.js
# Test Hyperdrive with SDK
node test-scripts/test-sdk-hyperdrive-replication.js
# Test peer-to-peer HyperDB replication (simplified)
node test-scripts/test-p2p-hyperdb-simple.js
# Test peer-to-peer Hyperdrive replication (simplified)
node test-scripts/test-p2p-hyperdrive-simple.js
```
### Basic Tests
```bash
# Test SDK integration
node test-scripts/test-sdk-integration.js
# Test SDK methods
node test-scripts/test-sdk-methods.js
# Test replication managers
node test-scripts/test-replication-managers.js
```
### Legacy Tests (Low-Level)
```bash
node test-scripts/test-hyperdb-replication.js
node test-scripts/test-hyperdrive-replication.js
```
## Requirements
- Node.js with required dependencies (hyperdb, hyperdrive, hyperswarm, corestore)
- Access to the P2NS codebase
- Two or more peers for replication testing
## Notes
These scripts are for research and development purposes. They help validate the replication architecture before integrating into the main SDK.