You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`tlsn-js` can be used in many different modes, depending on your use case.
29
+
`tlsn-js` can be used in several modes depending on your use case.
31
30
32
-
The `./demo` folder contains three demos of `tlsn-js`:
31
+
The `./demo` folder contains three demos:
33
32
34
-
*`react-ts-webpack`: create an attestation with a Notary and render the result.
35
-
*`interactive-demo`: prove data interactively to a Verifier.
36
-
*`web-to-web-p2p`: prove data between two peers, in the browser.
33
+
-`react-ts-webpack`: Create an attestation with a Notary and render the result.
34
+
-`interactive-demo`: Prove data interactively to a Verifier.
35
+
-`web-to-web-p2p`: Prove data between two browser peers.
37
36
38
-
## Running a local websocket proxy
37
+
## Running a Local WebSocket Proxy
39
38
40
-
In the demos, we attest data from `https://raw.githubusercontent.com`. Because the browser does not allow for TCP connections, you need to set up a websocket proxy:
39
+
In the demos, we attest data from `https://raw.githubusercontent.com`. Since browsers do not support raw TCP connections, a WebSocket proxy is required:
To work on `tlsn-wasm` and `tlsn-js` at the same time, replace the "tlsn-wasm" dependency in `package.json` with:
65
+
To work on both `tlsn-wasm` and `tlsn-js` locally, update `package.json`:
66
+
67
+
```json
68
+
"tlsn-wasm": "./tlsn-wasm/pkg"
65
69
```
66
-
"tlsn-wasm": "./tlsn-wasm/pkg"
70
+
71
+
Then build `tlsn-wasm`:
72
+
73
+
```sh
74
+
npm run build:wasm
67
75
```
68
-
and run `npm run build:wasm` to build `tlsn-wasm` locally.
69
76
70
-
Next, run:
77
+
Next:
78
+
71
79
```sh
72
80
npm install
73
81
npm run test
74
82
```
75
83
76
-
Note: if you want to switch back to a build with the version from npm, make sure to reset/remove`package-lock.json`, or it will keep using the local link.
84
+
> ℹ️ To switch back to the npm-published version of `tlsn-wasm`, delete or reset `package-lock.json` to remove the localpath reference.
77
85
78
86
## Build for NPM
79
87
@@ -82,9 +90,51 @@ npm install
82
90
npm run build
83
91
```
84
92
85
-
## Adding a new test
86
-
1. Create a new `new-test.spec.ts` file in the `test/` directory.
87
-
2. Add your spec file to the entry object in `webpack.web.dev.config.js`.
88
-
3. Add a new `div` block to `test/test.ejs` like this: `<div>Testing "new-test":<div id="new-test"></div></div>`. The `div` id must be the same as the filename.
93
+
## Testing
94
+
95
+
Testing is slightly complex due to the need for browser-based workers.
96
+
97
+
- Tests live in the `test/` directory.
98
+
- The `tests/` directory contains a Playwright test runner that opens a Chromium browser and runs the actual test page.
99
+
100
+
Some tests require a running Notary. You can start one via Docker:
101
+
102
+
```sh
103
+
npm run notary
104
+
```
105
+
106
+
### Adding a New `tlsn-js` Test
107
+
108
+
1. Create a `new-test.spec.ts` file in the `test/` directory.
109
+
2. Add your spec file to the `entry` object in`webpack.web.dev.config.js`.
110
+
3. Update `test/test.ejs` with a block like:
111
+
112
+
```html
113
+
<div>
114
+
Testing "new-test":
115
+
<div id="new-test" data-testid="new-test"></div>
116
+
</div>
117
+
```
118
+
119
+
The `div` ID must match the filename.
120
+
121
+
4. Add an `expect()` call foritin`tests/test.spec.ts`.
0 commit comments