Skip to content

Commit

Permalink
experimenting with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
heeckhau committed Feb 2, 2024
1 parent 5e4b43b commit 7cdd9a8
Show file tree
Hide file tree
Showing 6 changed files with 6,224 additions and 16 deletions.
12 changes: 8 additions & 4 deletions static/index.template.ejs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="manifest" href="/manifest.json">
<title>tlsn-js development</title>
</head>

<body>
<script>
global = globalThis //<- this should be enough
</script>
<div id="root"></div>
<script>
global = globalThis //<- this should be enough
</script>
<div id="root"></div>
<div id="verify_simple"></div>
</body>

</html>
19 changes: 12 additions & 7 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ after(function () {
describe('tlsn-js test suite', function () {
it('should prove and verify', async function () {
const assert = require('assert');
const content = await check();
const result = JSON.parse(content);
assert(result);
async function check(): Promise<string> {
const content = await page.$eval('#root', (n: any) => n.innerText);

for (var div of ["root", "simple_verify"]) {

const content = await check(div);
const result = JSON.parse(content);
assert(result);
}

async function check(div: string): Promise<string> {
const content = await page.$eval(`#${div}`, (n: any) => n.innerText);
if (content) return content;
await new Promise((r) => setTimeout(r, 1000));
return check();
return check(div);
}
});
});
});
7 changes: 7 additions & 0 deletions utils/simple_proof_expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"serverName": "example.com",
"time": 1700642161,
"sent": "GET / HTTP/1.1\r\nhost: example.com\r\naccept: */*\r\naccept-encoding: identity\r\nconnection: close\r\nuser-agent: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\r\n\r\n",
"recv": "HTTP/1.1 200 OK\r\nAge: 22659\r\nCache-Control: max-age=604800\r\nContent-Type: text/html; charset=UTF-8\r\nDate: Wed, 22 Nov 2023 08:36:02 GMT\r\nEtag: \"3147526947+ident\"\r\nExpires: Wed, 29 Nov 2023 08:36:02 GMT\r\nLast-Modified: Thu, 17 Oct 2019 07:18:26 GMT\r\nServer: ECS (dce/26AB)\r\nVary: Accept-Encoding\r\nX-Cache: HIT\r\nContent-Length: 1256\r\nConnection: close\r\n\r\n<!doctype html>\n<html>\n<head>\n <title>XXXXXXXXXXXXXX</title>\n\n <meta charset=\"utf-8\" />\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n <style type=\"text/css\">\n body {\n background-color: #f0f0f2;\n margin: 0;\n padding: 0;\n font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n \n }\n div {\n width: 600px;\n margin: 5em auto;\n padding: 2em;\n background-color: #fdfdff;\n border-radius: 0.5em;\n box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\n }\n a:link, a:visited {\n color: #38488f;\n text-decoration: none;\n }\n @media (max-width: 700px) {\n div {\n margin: 0 auto;\n width: auto;\n }\n }\n </style> \n</head>\n\n<body>\n<div>\n <h1>XXXXXXXXXXXXXX</h1>\n <p>This domain is for use in illustrative examples in documents. You may use this\n domain in literature without prior coordination or asking for permission.</p>\n <p><a href=\"https://www.iana.org/domains/example\">More information...</a></p>\n</div>\n</body>\n</html>\n",
"notaryUrl": "http://localhost"
}
Loading

0 comments on commit 7cdd9a8

Please sign in to comment.