Skip to content

Commit faa4833

Browse files
committed
Fix www/ and www-test/ code formatting
By running `make format`
1 parent b15c2d1 commit faa4833

File tree

7 files changed

+137
-106
lines changed

7 files changed

+137
-106
lines changed

mithril-client-wasm/www-test/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Mithril client wasm: www-test
22

3-
* A set of tests for the Mithril client WASM library, which is a client for interacting with a Mithril network. The tests cover functionalities provided by the MithrilClient class.
3+
- A set of tests for the Mithril client WASM library, which is a client for interacting with a Mithril network. The tests cover functionalities provided by the MithrilClient class.
44

55
## Download source code
66

@@ -12,7 +12,7 @@ git clone https://github.com/input-output-hk/mithril
1212
cd mithril-client-wasm/
1313
```
1414

15-
* Before running the tests, make sure to install the required dependencies. Use the following command:
15+
- Before running the tests, make sure to install the required dependencies. Use the following command:
1616

1717
```bash
1818
make www-test-install
@@ -26,4 +26,4 @@ make www-test-serve
2626

2727
## Test Results Display
2828

29-
The results of each test are displayed in the DOM dynamically. Open [http://localhost:8080](http://localhost:8080) with your browser. (port 8080 is the default port)
29+
The results of each test are displayed in the DOM dynamically. Open [http://localhost:8080](http://localhost:8080) with your browser. (port 8080 is the default port)
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// A dependency graph that contains any wasm must all be imported
22
// asynchronously. This `bootstrap.js` file does the single async import, so
33
// that no one else needs to worry about it again.
4-
import("./index.js")
5-
.catch(e => console.error("Error importing `index.js`:", e));
4+
import("./index.js").catch((e) => console.error("Error importing `index.js`:", e));

mithril-client-wasm/www-test/index.js

Lines changed: 38 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import initMithrilClient, {
2-
MithrilClient
3-
} from "@mithril-dev/mithril-client-wasm";
1+
import initMithrilClient, { MithrilClient } from "@mithril-dev/mithril-client-wasm";
42

53
async function run_test(test_name, test_number, fun) {
64
try {
@@ -26,9 +24,7 @@ function handle_error(test_name, test_number, error) {
2624
display_test_result_in_dom(test_name, test_number, "FAILED", error);
2725
console.error(`Error at step ${test_number} (${test_name}):`, error);
2826
add_finished_div();
29-
throw new Error(
30-
`Stopping script due to error at step ${test_number}: ${error}`
31-
);
27+
throw new Error(`Stopping script due to error at step ${test_number}: ${error}`);
3228
}
3329

3430
function add_finished_div() {
@@ -43,10 +39,9 @@ const genesis_verification_key = process.env.GENESIS_VERIFICATION_KEY;
4339
let client;
4440
let test_number = 1;
4541

46-
const aggregator_capabilities =
47-
await fetch(aggregator_endpoint)
48-
.then(res => res.status === 200 ? res.json() : [])
49-
.then(res => res.capabilities?.signed_entity_types ?? []);
42+
const aggregator_capabilities = await fetch(aggregator_endpoint)
43+
.then((res) => (res.status === 200 ? res.json() : []))
44+
.then((res) => res.capabilities?.signed_entity_types ?? []);
5045
console.log("aggregator_endpoint: ", aggregator_endpoint);
5146
console.log("aggregator_capabilities: ", aggregator_capabilities);
5247

@@ -78,61 +73,46 @@ let mithril_stake_distribution;
7873
test_number++;
7974
await run_test("get_mithril_stake_distribution", test_number, async () => {
8075
mithril_stake_distribution = await client.get_mithril_stake_distribution(
81-
mithril_stake_distributions[0].hash
76+
mithril_stake_distributions[0].hash,
8277
);
8378
console.log("mithril_stake_distribution", mithril_stake_distribution);
8479
});
8580

8681
let certificate;
8782
test_number++;
8883
await run_test("get_mithril_certificate", test_number, async () => {
89-
certificate = await client.get_mithril_certificate(
90-
mithril_stake_distribution.certificate_hash
91-
);
84+
certificate = await client.get_mithril_certificate(mithril_stake_distribution.certificate_hash);
9285
console.log("certificate", certificate);
9386
});
9487

9588
let last_certificate_from_chain;
9689
test_number++;
9790
await run_test("verify_certificate_chain", test_number, async () => {
98-
last_certificate_from_chain = await client.verify_certificate_chain(
99-
certificate.hash
100-
);
91+
last_certificate_from_chain = await client.verify_certificate_chain(certificate.hash);
10192
console.log("last_certificate_from_chain", last_certificate_from_chain);
10293
});
10394

10495
let mithril_stake_distribution_message;
10596
test_number++;
106-
await run_test(
107-
"compute_mithril_stake_distribution_message",
108-
test_number,
109-
async () => {
110-
mithril_stake_distribution_message =
111-
await client.compute_mithril_stake_distribution_message(
112-
mithril_stake_distribution
113-
);
114-
console.log(
115-
"mithril_stake_distribution_message",
116-
mithril_stake_distribution_message
117-
);
118-
}
119-
);
97+
await run_test("compute_mithril_stake_distribution_message", test_number, async () => {
98+
mithril_stake_distribution_message = await client.compute_mithril_stake_distribution_message(
99+
mithril_stake_distribution,
100+
);
101+
console.log("mithril_stake_distribution_message", mithril_stake_distribution_message);
102+
});
120103

121104
test_number++;
122105
await run_test("verify_message_match_certificate", test_number, async () => {
123-
const valid_stake_distribution_message =
124-
await client.verify_message_match_certificate(
125-
mithril_stake_distribution_message,
126-
last_certificate_from_chain
127-
);
128-
console.log(
129-
"valid_stake_distribution_message",
130-
valid_stake_distribution_message
106+
const valid_stake_distribution_message = await client.verify_message_match_certificate(
107+
mithril_stake_distribution_message,
108+
last_certificate_from_chain,
131109
);
110+
console.log("valid_stake_distribution_message", valid_stake_distribution_message);
132111
});
133112

134113
if (aggregator_capabilities.includes("CardanoTransactions")) {
135-
const transactions_hashes_to_certify = process.env.TRANSACTIONS_HASHES_TO_CERTIFY?.split(",") ?? [];
114+
const transactions_hashes_to_certify =
115+
process.env.TRANSACTIONS_HASHES_TO_CERTIFY?.split(",") ?? [];
136116

137117
let ctx_sets;
138118
test_number++;
@@ -153,19 +133,21 @@ if (aggregator_capabilities.includes("CardanoTransactions")) {
153133
let ctx_proof;
154134
test_number++;
155135
await run_test("get_cardano_transaction_proof", test_number, async () => {
156-
ctx_proof = await client.unstable.get_cardano_transaction_proofs(transactions_hashes_to_certify);
136+
ctx_proof = await client.unstable.get_cardano_transaction_proofs(
137+
transactions_hashes_to_certify,
138+
);
157139
console.log(
158-
"got proof for transactions: ", ctx_proof.transactions_hashes,
159-
"\nnon_certified_transactions: ", ctx_proof.non_certified_transactions
140+
"got proof for transactions: ",
141+
ctx_proof.transactions_hashes,
142+
"\nnon_certified_transactions: ",
143+
ctx_proof.non_certified_transactions,
160144
);
161145
});
162146

163147
let proof_certificate;
164148
test_number++;
165149
await run_test("proof_verify_certificate_chain", test_number, async () => {
166-
proof_certificate = await client.verify_certificate_chain(
167-
ctx_proof.certificate_hash
168-
);
150+
proof_certificate = await client.verify_certificate_chain(ctx_proof.certificate_hash);
169151
console.log("proof_certificate", proof_certificate);
170152
});
171153

@@ -176,25 +158,21 @@ if (aggregator_capabilities.includes("CardanoTransactions")) {
176158
test_number,
177159
async () => {
178160
ctx_proof_message =
179-
await client.unstable.verify_cardano_transaction_proof_then_compute_message(ctx_proof, proof_certificate);
180-
console.log(
181-
"verify_cardano_transaction_proof_then_compute_message",
182-
ctx_proof_message
183-
);
184-
}
161+
await client.unstable.verify_cardano_transaction_proof_then_compute_message(
162+
ctx_proof,
163+
proof_certificate,
164+
);
165+
console.log("verify_cardano_transaction_proof_then_compute_message", ctx_proof_message);
166+
},
185167
);
186168

187169
test_number++;
188170
await run_test("proof_verify_message_match_certificate", test_number, async () => {
189-
const valid_stake_distribution_message =
190-
await client.verify_message_match_certificate(
191-
ctx_proof_message,
192-
proof_certificate
193-
);
194-
console.log(
195-
"valid_stake_distribution_message",
196-
valid_stake_distribution_message
171+
const valid_stake_distribution_message = await client.verify_message_match_certificate(
172+
ctx_proof_message,
173+
proof_certificate,
197174
);
175+
console.log("valid_stake_distribution_message", valid_stake_distribution_message);
198176
});
199177
}
200178
}
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const CopyWebpackPlugin = require("copy-webpack-plugin")
2-
const path = require("path")
3-
const Dotenv = require("dotenv-webpack")
1+
const CopyWebpackPlugin = require("copy-webpack-plugin");
2+
const path = require("path");
3+
const Dotenv = require("dotenv-webpack");
44

55
module.exports = {
66
entry: "./bootstrap.js",
@@ -9,10 +9,13 @@ module.exports = {
99
filename: "bootstrap.js",
1010
},
1111
mode: "development",
12-
plugins: [new CopyWebpackPlugin({
13-
patterns: ["index.html"]
14-
}), new Dotenv()],
12+
plugins: [
13+
new CopyWebpackPlugin({
14+
patterns: ["index.html"],
15+
}),
16+
new Dotenv(),
17+
],
1518
experiments: {
1619
asyncWebAssembly: true,
1720
},
18-
}
21+
};

mithril-client-wasm/www/bootstrap.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// A dependency graph that contains any wasm must all be imported
22
// asynchronously. This `bootstrap.js` file does the single async import, so
33
// that no one else needs to worry about it again.
4-
import("./index.js")
5-
.catch(e => console.error("Error importing `index.js`:", e));
4+
import("./index.js").catch((e) => console.error("Error importing `index.js`:", e));

0 commit comments

Comments
 (0)