Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlwn123 committed Oct 3, 2024
1 parent 5994498 commit fc8dc29
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 46 deletions.
8 changes: 7 additions & 1 deletion docs/core/dev/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ This framework should be suitable for all the additional libraries we have plann

## Nix

The Fedimint Web SDK depends on several external pieces of infrastructure. In order to run high-fidelity tests, we utilize a tool from the [fedimint](https://github.com/fedimint/fedimint) repo called [Devimint](https://github.com/fedimint/fedimint/tree/master/devimint). Devimint includes several pieces of infrastructure for running a local testing environment for fedimint applications including a bitcoind node (regtest), multiple guardian servers (fedimintd), multiple lightning gateways (lnd, cln), and a faucet for minting tokens.
The Fedimint Web SDK depends on several external pieces of infrastructure. In order to run high-fidelity tests, we utilize a tool from the [fedimint](https://github.com/fedimint/fedimint) repo called [Devimint](https://github.com/fedimint/fedimint/tree/master/devimint). Devimint includes several pieces of infrastructure for running a local testing environment for fedimint applications including a bitcoind node (regtest), multiple guardian servers (fedimintd), multiple lightning gateways (lnd, cln, ldk), and a faucet for minting tokens.

::: warning Note

Nix is NOT required to build or use the Fedimint Web SDK. It is ONLY required to run the tests.

:::

## Nix Installation & Setup

Expand Down
17 changes: 1 addition & 16 deletions packages/core-web/docs/TESTING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
# Testing

We use [vitest](https://vitest.dev/) for testing library code.

Configuring this properly was tricky. Since the library heavily relies on browser APIs like web workers & wasm, it doesn't really make sense to mock the browser APIs for unit tests. To trust our tests in this library, we really need them to run in a realistic browser environment.

Vitest browser mode + playwright (provider) seems to satisfy all our needs. It spins up a real browser to run tests and can run headlessly for CI. I had to add one hack to make it work with the web-worker, but otherwise it seems to work well out of the box.

This framework should be suitable for all the additional libraries we have planned (e.g. react).

## Usage

```bash
# in the root of the repo
pnpm run test
```
Check out the [testing docs](https://web.fedimint.org/core/dev/testing) for more information.
29 changes: 0 additions & 29 deletions packages/core-web/src/test/TestFedimintWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,6 @@ export class TestFedimintWallet extends FedimintWallet {
const res = await this.testing.payFaucetInvoice(invoice.invoice)
await this.lightning.waitForReceive(invoice.operation_id)
console.error('FUNDED', res)
// try {
// const invoice = await this.lightning.createInvoiceWithGateway(
// amount,
// '',
// gateways[0].info,
// )
// console.error('gateway 0', gateways[0].info.api)
// const res = await this.testing.payFaucetInvoice(invoice.invoice)
// await this.lightning.waitForReceive(invoice.operation_id)
// console.error('First success', res)
// } catch (e) {
// console.error('Fail for first', e)
// }
// try {
// const invoice = await this.lightning.createInvoiceWithGateway(
// amount,
// '',
// gateways[1].info,
// )
// console.error('gateway 1', gateways[1].info.api)
// const res = await this.testing.payFaucetInvoice(invoice.invoice)
// await this.lightning.waitForReceive(invoice.operation_id)
// console.error('Second success', res)
// } catch (e) {
// console.error('Fail for second', e)
// }
// console.error('INVOICE', invoice)
// console.error('RES', res)
// await this.lightning.waitForReceive(invoice.operation_id)
}

// Method to expose the WorkerClient
Expand Down

0 comments on commit fc8dc29

Please sign in to comment.