1
- import initMithrilClient , {
2
- MithrilClient
3
- } from "@mithril-dev/mithril-client-wasm" ;
1
+ import initMithrilClient , { MithrilClient } from "@mithril-dev/mithril-client-wasm" ;
4
2
5
3
async function run_test ( test_name , test_number , fun ) {
6
4
try {
@@ -26,9 +24,7 @@ function handle_error(test_name, test_number, error) {
26
24
display_test_result_in_dom ( test_name , test_number , "FAILED" , error ) ;
27
25
console . error ( `Error at step ${ test_number } (${ test_name } ):` , error ) ;
28
26
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 } ` ) ;
32
28
}
33
29
34
30
function add_finished_div ( ) {
@@ -43,10 +39,9 @@ const genesis_verification_key = process.env.GENESIS_VERIFICATION_KEY;
43
39
let client ;
44
40
let test_number = 1 ;
45
41
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 ?? [ ] ) ;
50
45
console . log ( "aggregator_endpoint: " , aggregator_endpoint ) ;
51
46
console . log ( "aggregator_capabilities: " , aggregator_capabilities ) ;
52
47
@@ -78,61 +73,46 @@ let mithril_stake_distribution;
78
73
test_number ++ ;
79
74
await run_test ( "get_mithril_stake_distribution" , test_number , async ( ) => {
80
75
mithril_stake_distribution = await client . get_mithril_stake_distribution (
81
- mithril_stake_distributions [ 0 ] . hash
76
+ mithril_stake_distributions [ 0 ] . hash ,
82
77
) ;
83
78
console . log ( "mithril_stake_distribution" , mithril_stake_distribution ) ;
84
79
} ) ;
85
80
86
81
let certificate ;
87
82
test_number ++ ;
88
83
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 ) ;
92
85
console . log ( "certificate" , certificate ) ;
93
86
} ) ;
94
87
95
88
let last_certificate_from_chain ;
96
89
test_number ++ ;
97
90
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 ) ;
101
92
console . log ( "last_certificate_from_chain" , last_certificate_from_chain ) ;
102
93
} ) ;
103
94
104
95
let mithril_stake_distribution_message ;
105
96
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
+ } ) ;
120
103
121
104
test_number ++ ;
122
105
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 ,
131
109
) ;
110
+ console . log ( "valid_stake_distribution_message" , valid_stake_distribution_message ) ;
132
111
} ) ;
133
112
134
113
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 ( "," ) ?? [ ] ;
136
116
137
117
let ctx_sets ;
138
118
test_number ++ ;
@@ -153,19 +133,21 @@ if (aggregator_capabilities.includes("CardanoTransactions")) {
153
133
let ctx_proof ;
154
134
test_number ++ ;
155
135
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
+ ) ;
157
139
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 ,
160
144
) ;
161
145
} ) ;
162
146
163
147
let proof_certificate ;
164
148
test_number ++ ;
165
149
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 ) ;
169
151
console . log ( "proof_certificate" , proof_certificate ) ;
170
152
} ) ;
171
153
@@ -176,25 +158,21 @@ if (aggregator_capabilities.includes("CardanoTransactions")) {
176
158
test_number ,
177
159
async ( ) => {
178
160
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
+ } ,
185
167
) ;
186
168
187
169
test_number ++ ;
188
170
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 ,
197
174
) ;
175
+ console . log ( "valid_stake_distribution_message" , valid_stake_distribution_message ) ;
198
176
} ) ;
199
177
}
200
178
}
0 commit comments