Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions libs/gl-sdk-napi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,42 @@ quickStart();
| `label` | `string` | Label assigned to the invoice |
| `amountMsat` | `number` | Amount received in millisatoshis |

## Development
## Testing

### Running Tests
The test setup starts and stops all required infrastructure automatically.

### Running the Tests

```bash
# Run all tests
npm test

# Run with verbose infrastructure logs
VERBOSE=1 npm test

# Run a specific test file
npm test -- --verbose tests/node.spec.ts
```

### Local npm Publishing
### How It Works

The global setup script `./tests/jest.globalSetup.ts` automatically:
- Starts `test_setup.py`, spinning up bitcoind, the Greenlight scheduler, and an LSPS2-compatible LSP node
- Waits for all services to be ready
- Injects the required environment variables (`GL_SCHEDULER_GRPC_URI`, `GL_CA_CRT`, `GL_NOBODY_CRT`, `GL_NOBODY_KEY`, `LSP_RPC_SOCKET`, `LSP_NODE_ID`, `LSP_PROMISE_SECRET`, `GL_FUND_SERVER`)
- Shuts everything down after all tests complete

### Test Helpers

`test.helper.ts` provides utilities for interacting with the running infrastructure:

| Function | Description |
|----------|-------------|
| `fundNode(node, amountSats?)` | Funds a test node with on-chain Bitcoin, waiting until the node detects the confirmed UTXO |
| `lspInfo()` | Returns the LSP node's RPC socket, node ID, and promise secret |


## Local npm Publishing
This workflow only builds for local platform. For multi-platform builds, use the GitHub Actions workflow which cross-compiles for all supported targets.

```bash
Expand Down
5 changes: 4 additions & 1 deletion libs/gl-sdk-napi/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'node',
maxWorkers: 1,
testTimeout: 30000,
testTimeout: 120_000,
runner: 'jest-runner',
resetModules: true,
restoreMocks: true,
Expand All @@ -17,4 +17,7 @@ module.exports = {
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
testMatch: ["<rootDir>/tests/**/*.spec.ts"],
globalSetup: '<rootDir>/tests/jest.globalSetup.ts',
globalTeardown: '<rootDir>/tests/jest.globalTeardown.ts',
};
Loading
Loading