-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lightspark-sdk] Add integration tests, upgrade Turbo (#6804) (#281)
* [lightspark-sdk] Add integration tests, upgrade Turbo (#6804) GitOrigin-RevId: bbdfdc8250cf133b91c849d230864a47d345064d * Update lock file --------- Co-authored-by: Corey Martin <[email protected]>
- Loading branch information
1 parent
b895794
commit 3332061
Showing
5 changed files
with
98 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": [ | ||
|
@@ -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]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
packages/lightspark-sdk/src/tests/integration/client.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters