Skip to content

Commit 054b019

Browse files
author
Damien LACHAUME / PALO-IT
committed
Add Cardano transactions functionnalities in www-test/
1 parent 1bd233b commit 054b019

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

.github/workflows/test-client.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ on:
3131
required: false
3232
type: string
3333
default: https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/pre-release-preview/genesis.vkey
34+
transactions_hashes_to_certify:
35+
description: Comma separated list of transactions hashes to test certification on.
36+
required: false
37+
type: string
3438
enable_debug:
3539
description: Enable debug output ("-vvv") for the mithril-client calls
3640
required: true
@@ -193,6 +197,7 @@ jobs:
193197
run: |
194198
echo "AGGREGATOR_ENDPOINT=${{ inputs.aggregator_endpoint }}" > ./www-test/.env
195199
echo "GENESIS_VERIFICATION_KEY=$(curl -s ${{ inputs.genesis_verification_key }})" >> ./www-test/.env
200+
echo "TRANSACTIONS_HASHES_TO_CERTIFY=$(curl -s ${{ inputs.transactions_hashes_to_certify }})" >> ./www-test/.env
196201
197202
- name: Start the server
198203
working-directory: mithril-client-wasm

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

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ const genesis_verification_key = process.env.GENESIS_VERIFICATION_KEY;
4343
let client;
4444
let test_number = 1;
4545

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 ?? []);
50+
console.log("aggregator_endpoint: ", aggregator_endpoint);
51+
console.log("aggregator_capabilities: ", aggregator_capabilities);
52+
4653
await run_test("constructor", test_number, async () => {
4754
client = new MithrilClient(aggregator_endpoint, genesis_verification_key);
4855
});
@@ -124,4 +131,72 @@ await run_test("verify_message_match_certificate", test_number, async () => {
124131
);
125132
});
126133

134+
if (aggregator_capabilities.includes("CardanoTransactions")) {
135+
const transactions_hashes_to_certify = process.env.TRANSACTIONS_HASHES_TO_CERTIFY?.split(',') ?? [];
136+
137+
let ctx_sets;
138+
test_number++;
139+
await run_test("list_cardano_transactions_sets", test_number, async () => {
140+
ctx_sets = await client.unstable.list_cardano_transaction_sets();
141+
console.log("cardano_transactions_sets", ctx_sets);
142+
});
143+
144+
test_number++;
145+
await run_test("get_cardano_transaction_set", test_number, async () => {
146+
const ctx_set = await client.unstable.get_cardano_transaction_set(ctx_sets[0].hash);
147+
console.log("cardano_transaction_set", ctx_set);
148+
});
149+
150+
if (transactions_hashes_to_certify.length > 0) {
151+
console.log("Testing transactions certification with txs:", transactions_hashes_to_certify);
152+
153+
let ctx_proof;
154+
test_number++;
155+
await run_test("get_cardano_transaction_proof", test_number, async () => {
156+
ctx_proof = await client.unstable.get_cardano_transaction_proofs(transactions_hashes_to_certify);
157+
console.log(
158+
"got proof for txs: ", ctx_proof.transactions_hashes,
159+
"\nnon_certified_transactions: ", ctx_proof.non_certified_transactions
160+
);
161+
});
162+
163+
let proof_certificate;
164+
test_number++;
165+
await run_test("proof verify_certificate_chain", test_number, async () => {
166+
proof_certificate = await client.verify_certificate_chain(
167+
ctx_proof.certificate_hash
168+
);
169+
console.log("proof_certificate", proof_certificate);
170+
});
171+
172+
let ctx_proof_message;
173+
test_number++;
174+
await run_test(
175+
"compute_cardano_transaction_proof_message",
176+
test_number,
177+
async () => {
178+
ctx_proof_message =
179+
await client.unstable.compute_cardano_transaction_proof_message(ctx_proof, proof_certificate);
180+
console.log(
181+
"compute_cardano_transaction_proof_message",
182+
ctx_proof_message
183+
);
184+
}
185+
);
186+
187+
test_number++;
188+
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
197+
);
198+
});
199+
}
200+
}
201+
127202
add_finished_div();

0 commit comments

Comments
 (0)