Skip to content

Commit

Permalink
[lightspark-sdk] Add integration tests, upgrade Turbo (#6804) (#281)
Browse files Browse the repository at this point in the history
* [lightspark-sdk] Add integration tests, upgrade Turbo (#6804)

GitOrigin-RevId: bbdfdc8250cf133b91c849d230864a47d345064d

* Update lock file

---------

Co-authored-by: Corey Martin <[email protected]>
  • Loading branch information
github-actions[bot] and coreymartin authored Oct 12, 2023
1 parent b895794 commit 3332061
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 32 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"start:check": "turbo run build && turbo run build:watch start types:watch lint:watch --parallel --concurrency 200",
"start": "turbo run build && turbo run build:watch start --concurrency 200",
"test": "turbo run test",
"test:integration": "turbo run test:integration",
"types": "turbo run types"
},
"workspaces": [
Expand All @@ -41,7 +42,7 @@
"@changesets/cli": "^2.26.1",
"@manypkg/cli": "^0.21.0",
"ts-prune": "^0.10.3",
"turbo": "v1.10.1",
"turbo": "1.10.15",
"unimported": "^1.29.2"
},
"packageManager": "[email protected]"
Expand Down
4 changes: 3 additions & 1 deletion packages/lightspark-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
"lint:watch": "esw ./src -w --ext .ts,.tsx,.js --color",
"lint": "eslint .",
"postversion": "yarn build",
"test": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
"test-cmd": "node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --bail",
"test": "yarn test-cmd src/tests/*.test.ts",
"test:integration": "yarn test-cmd src/tests/integration/*.test.ts",
"types:watch": "tsc-absolute --watch",
"types": "tsc"
},
Expand Down
60 changes: 60 additions & 0 deletions packages/lightspark-sdk/src/tests/integration/client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import LightsparkClient from "../../client.js";
import { getCredentialsFromEnvOrThrow } from "../../env.js";
import {
AccountTokenAuthProvider,
BitcoinNetwork,
PaymentRequestStatus,
} from "../../index.js";

describe("lightspark-sdk client", () => {
const { apiTokenClientId, apiTokenClientSecret, baseUrl } =
getCredentialsFromEnvOrThrow();
const accountAuthProvider = new AccountTokenAuthProvider(
apiTokenClientId,
apiTokenClientSecret,
);
let regtestNodeId: string | undefined;

function getRegtestNodeId() {
expect(regtestNodeId).toBeDefined();
if (!regtestNodeId) {
throw new Error("regtestNodeId is not set");
}
return regtestNodeId as string;
}

it("should get env vars and construct the client successfully", async () => {
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);
expect(lightsparkClient).toBeDefined();
});

it("should successfully get the current account regtest node", async () => {
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);

const account = await lightsparkClient.getCurrentAccount();
const nodesConnection = await account?.getNodes(lightsparkClient, 1, [
BitcoinNetwork.REGTEST,
]);

const regtestNode = nodesConnection?.entities[0];
expect(regtestNode).toBeDefined();
regtestNodeId = regtestNode?.id;
});

it("should successfully create an uma invoice", async () => {
const nodeId = getRegtestNodeId();
const lightsparkClient = new LightsparkClient(accountAuthProvider, baseUrl);

const metadata = JSON.stringify([
["text/plain", "Pay to vasp2.com user $bob"],
["text/identifier", "[email protected]"],
]);

const umaInvoice = await lightsparkClient.createUmaInvoice(
nodeId,
1000,
metadata,
);
expect(umaInvoice?.status).toEqual(PaymentRequestStatus.OPEN);
});
});
3 changes: 3 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
"test": {
"dependsOn": ["^build"]
},
"test:integration": {
"dependsOn": ["^build"]
},
"types": {},
"types:watch": {
"cache": false,
Expand Down
60 changes: 30 additions & 30 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13555,7 +13555,7 @@ __metadata:
"@changesets/cli": ^2.26.1
"@manypkg/cli": ^0.21.0
ts-prune: ^0.10.3
turbo: v1.10.1
turbo: 1.10.15
unimported: ^1.29.2
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -20016,58 +20016,58 @@ __metadata:
languageName: node
linkType: hard

"turbo-darwin-64@npm:1.10.1":
version: 1.10.1
resolution: "turbo-darwin-64@npm:1.10.1"
"turbo-darwin-64@npm:1.10.15":
version: 1.10.15
resolution: "turbo-darwin-64@npm:1.10.15"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"turbo-darwin-arm64@npm:1.10.1":
version: 1.10.1
resolution: "turbo-darwin-arm64@npm:1.10.1"
"turbo-darwin-arm64@npm:1.10.15":
version: 1.10.15
resolution: "turbo-darwin-arm64@npm:1.10.15"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"turbo-linux-64@npm:1.10.1":
version: 1.10.1
resolution: "turbo-linux-64@npm:1.10.1"
"turbo-linux-64@npm:1.10.15":
version: 1.10.15
resolution: "turbo-linux-64@npm:1.10.15"
conditions: os=linux & cpu=x64
languageName: node
linkType: hard

"turbo-linux-arm64@npm:1.10.1":
version: 1.10.1
resolution: "turbo-linux-arm64@npm:1.10.1"
"turbo-linux-arm64@npm:1.10.15":
version: 1.10.15
resolution: "turbo-linux-arm64@npm:1.10.15"
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard

"turbo-windows-64@npm:1.10.1":
version: 1.10.1
resolution: "turbo-windows-64@npm:1.10.1"
"turbo-windows-64@npm:1.10.15":
version: 1.10.15
resolution: "turbo-windows-64@npm:1.10.15"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard

"turbo-windows-arm64@npm:1.10.1":
version: 1.10.1
resolution: "turbo-windows-arm64@npm:1.10.1"
"turbo-windows-arm64@npm:1.10.15":
version: 1.10.15
resolution: "turbo-windows-arm64@npm:1.10.15"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard

"turbo@npm:v1.10.1":
version: 1.10.1
resolution: "turbo@npm:1.10.1"
dependencies:
turbo-darwin-64: 1.10.1
turbo-darwin-arm64: 1.10.1
turbo-linux-64: 1.10.1
turbo-linux-arm64: 1.10.1
turbo-windows-64: 1.10.1
turbo-windows-arm64: 1.10.1
"turbo@npm:1.10.15":
version: 1.10.15
resolution: "turbo@npm:1.10.15"
dependencies:
turbo-darwin-64: 1.10.15
turbo-darwin-arm64: 1.10.15
turbo-linux-64: 1.10.15
turbo-linux-arm64: 1.10.15
turbo-windows-64: 1.10.15
turbo-windows-arm64: 1.10.15
dependenciesMeta:
turbo-darwin-64:
optional: true
Expand All @@ -20083,7 +20083,7 @@ __metadata:
optional: true
bin:
turbo: bin/turbo
checksum: 3551c57be67e833583de549d74d5ec991e0f1e38047e25600b8acc085a1a8a4007992259a015eb9f2c0abd68156545800bd34e7b5ad337d1998b32461952d3fb
checksum: b494c8bf79355874919e76ee0e4a0a53616e0ae5c7126eb1add50e67d4cd1e445ed9aecf99cb6d81c592b7a43ba91cd7dbf30df70410a44cecedba8b5126095d
languageName: node
linkType: hard

Expand Down

0 comments on commit 3332061

Please sign in to comment.