Skip to content

Commit 76e14c7

Browse files
committed
refactor: adapt the WASM client www tests with new unstable implementation
1 parent b779826 commit 76e14c7

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

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

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ console.log("aggregator_endpoint: ", aggregator_endpoint);
4646
console.log("aggregator_capabilities: ", aggregator_capabilities);
4747

4848
await run_test("constructor", test_number, async () => {
49-
client = new MithrilClient(aggregator_endpoint, genesis_verification_key);
49+
client = new MithrilClient(aggregator_endpoint, genesis_verification_key, {
50+
// The following option activates the unstable features of the client.
51+
// Unstable features will trigger an error if this option is not set.
52+
unstable: true,
53+
});
5054
});
5155

5256
let snapshots;
@@ -117,13 +121,13 @@ if (aggregator_capabilities.includes("CardanoTransactions")) {
117121
let ctx_sets;
118122
test_number++;
119123
await run_test("list_cardano_transactions_snapshots", test_number, async () => {
120-
ctx_sets = await client.unstable.list_cardano_transactions_snapshots();
124+
ctx_sets = await client.list_cardano_transactions_snapshots();
121125
console.log("cardano_transactions_sets", ctx_sets);
122126
});
123127

124128
test_number++;
125129
await run_test("get_cardano_transactions_snapshot", test_number, async () => {
126-
const ctx_set = await client.unstable.get_cardano_transactions_snapshot(ctx_sets[0].hash);
130+
const ctx_set = await client.get_cardano_transactions_snapshot(ctx_sets[0].hash);
127131
console.log("cardano_transaction_set", ctx_set);
128132
});
129133

@@ -133,9 +137,7 @@ if (aggregator_capabilities.includes("CardanoTransactions")) {
133137
let ctx_proof;
134138
test_number++;
135139
await run_test("get_cardano_transaction_proof", test_number, async () => {
136-
ctx_proof = await client.unstable.get_cardano_transaction_proofs(
137-
transactions_hashes_to_certify,
138-
);
140+
ctx_proof = await client.get_cardano_transaction_proofs(transactions_hashes_to_certify);
139141
console.log(
140142
"got proof for transactions: ",
141143
ctx_proof.transactions_hashes,
@@ -157,11 +159,10 @@ if (aggregator_capabilities.includes("CardanoTransactions")) {
157159
"verify_cardano_transaction_proof_then_compute_message",
158160
test_number,
159161
async () => {
160-
ctx_proof_message =
161-
await client.unstable.verify_cardano_transaction_proof_then_compute_message(
162-
ctx_proof,
163-
proof_certificate,
164-
);
162+
ctx_proof_message = await client.verify_cardano_transaction_proof_then_compute_message(
163+
ctx_proof,
164+
proof_certificate,
165+
);
165166
console.log("verify_cardano_transaction_proof_then_compute_message", ctx_proof_message);
166167
},
167168
);
@@ -181,14 +182,14 @@ if (aggregator_capabilities.includes("CardanoStakeDistribution")) {
181182
let cardano_stake_distributions;
182183
test_number++;
183184
await run_test("list_cardano_stake_distributions", test_number, async () => {
184-
cardano_stake_distributions = await client.unstable.list_cardano_stake_distributions();
185+
cardano_stake_distributions = await client.list_cardano_stake_distributions();
185186
console.log("cardano_stake_distributions", cardano_stake_distributions);
186187
});
187188

188189
let cardano_stake_distribution;
189190
test_number++;
190191
await run_test("get_cardano_stake_distribution", test_number, async () => {
191-
cardano_stake_distribution = await client.unstable.get_cardano_stake_distribution(
192+
cardano_stake_distribution = await client.get_cardano_stake_distribution(
192193
cardano_stake_distributions[0].hash,
193194
);
194195
console.log("cardano_stake_distribution", cardano_stake_distribution);
@@ -198,8 +199,7 @@ if (aggregator_capabilities.includes("CardanoStakeDistribution")) {
198199
await run_test("get_cardano_stake_distribution_by_epoch", test_number, async () => {
199200
let epoch = BigInt(cardano_stake_distributions[0].epoch);
200201

201-
cardano_stake_distribution =
202-
await client.unstable.get_cardano_stake_distribution_by_epoch(epoch);
202+
cardano_stake_distribution = await client.get_cardano_stake_distribution_by_epoch(epoch);
203203
console.log("cardano_stake_distribution by epoch", cardano_stake_distribution);
204204
});
205205

@@ -220,11 +220,10 @@ if (aggregator_capabilities.includes("CardanoStakeDistribution")) {
220220
let cardano_stake_distribution_message;
221221
test_number++;
222222
await run_test("compute_cardano_stake_distribution_message", test_number, async () => {
223-
cardano_stake_distribution_message =
224-
await client.unstable.compute_cardano_stake_distribution_message(
225-
certificate,
226-
cardano_stake_distribution,
227-
);
223+
cardano_stake_distribution_message = await client.compute_cardano_stake_distribution_message(
224+
certificate,
225+
cardano_stake_distribution,
226+
);
228227
console.log("cardano_stake_distribution_message", cardano_stake_distribution_message);
229228
});
230229

0 commit comments

Comments
 (0)