Skip to content

Commit 01d43ea

Browse files
committed
test: modify code according to the changement of apis
1 parent b827d67 commit 01d43ea

File tree

1 file changed

+165
-99
lines changed

1 file changed

+165
-99
lines changed

scripts/run_with_eigen_service.js

Lines changed: 165 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -17,74 +17,99 @@ const digest = ethers.utils.keccak256(ethers.utils.toUtf8Bytes("Hello Eigen"));
1717

1818
async function keygen(m, delay) {
1919
user_id = 1;
20-
keygen_url = `${eigen_service}/user/${user_id}/tss/keygen`;
21-
res = await axios.post(keygen_url, {
22-
headers: {
23-
"Content-Type": "application/x-www-form-urlencoded",
24-
},
25-
});
26-
console.log(res);
20+
key_name = "Just test";
21+
keygen_url = `${eigen_service}/tss/keygen`;
22+
res = await axios.post(
23+
keygen_url,
24+
querystring.stringify({ user_id: user_id, name: key_name }),
25+
{
26+
headers: {
27+
"Content-Type": "application/x-www-form-urlencoded",
28+
},
29+
}
30+
);
31+
console.log(res.data);
2732
await delay_ms(1000);
2833

2934
let context = await m.gg18_keygen_client_new_context(addr, t, n, delay);
3035

3136
console.log("keygen new context: ");
3237

3338
round = 1;
34-
res = await axios.post(keygen_url, querystring.stringify({ round: round }), {
35-
headers: {
36-
"Content-Type": "application/x-www-form-urlencoded",
37-
},
38-
});
39-
console.log(res);
39+
res = await axios.post(
40+
keygen_url,
41+
querystring.stringify({ user_id: user_id, round: round }),
42+
{
43+
headers: {
44+
"Content-Type": "application/x-www-form-urlencoded",
45+
},
46+
}
47+
);
48+
console.log(res.data);
4049
await delay_ms(1000);
4150

4251
context = await m.gg18_keygen_client_round1(context, delay);
4352
console.log("keygen round1:");
4453

4554
round = 2;
46-
res = await axios.post(keygen_url, querystring.stringify({ round: round }), {
47-
headers: {
48-
"Content-Type": "application/x-www-form-urlencoded",
49-
},
50-
});
51-
console.log(res);
55+
res = await axios.post(
56+
keygen_url,
57+
querystring.stringify({ user_id: user_id, round: round }),
58+
{
59+
headers: {
60+
"Content-Type": "application/x-www-form-urlencoded",
61+
},
62+
}
63+
);
64+
console.log(res.data);
5265
await delay_ms(1000);
5366

5467
context = await m.gg18_keygen_client_round2(context, delay);
5568
console.log("keygen round2: ");
5669

5770
round = 3;
58-
res = await axios.post(keygen_url, querystring.stringify({ round: round }), {
59-
headers: {
60-
"Content-Type": "application/x-www-form-urlencoded",
61-
},
62-
});
63-
console.log(res);
71+
res = await axios.post(
72+
keygen_url,
73+
querystring.stringify({ user_id: user_id, round: round }),
74+
{
75+
headers: {
76+
"Content-Type": "application/x-www-form-urlencoded",
77+
},
78+
}
79+
);
80+
console.log(res.data);
6481
await delay_ms(1000);
6582

6683
context = await m.gg18_keygen_client_round3(context, delay);
6784
console.log("keygen round3: ");
6885

6986
round = 4;
70-
res = await axios.post(keygen_url, querystring.stringify({ round: round }), {
71-
headers: {
72-
"Content-Type": "application/x-www-form-urlencoded",
73-
},
74-
});
75-
console.log(res);
87+
res = await axios.post(
88+
keygen_url,
89+
querystring.stringify({ user_id: user_id, round: round }),
90+
{
91+
headers: {
92+
"Content-Type": "application/x-www-form-urlencoded",
93+
},
94+
}
95+
);
96+
console.log(res.data);
7697
await delay_ms(1000);
7798

7899
context = await m.gg18_keygen_client_round4(context, delay);
79100
console.log("keygen round4: ");
80101

81102
round = 5;
82-
res = await axios.post(keygen_url, querystring.stringify({ round: round }), {
83-
headers: {
84-
"Content-Type": "application/x-www-form-urlencoded",
85-
},
86-
});
87-
console.log(res);
103+
res = await axios.post(
104+
keygen_url,
105+
querystring.stringify({ user_id: user_id, round: round }),
106+
{
107+
headers: {
108+
"Content-Type": "application/x-www-form-urlencoded",
109+
},
110+
}
111+
);
112+
console.log(res.data);
88113
await delay_ms(1000);
89114

90115
keygen_json = await m.gg18_keygen_client_round5(context, delay);
@@ -99,20 +124,21 @@ async function keygen(m, delay) {
99124
async function sign(m, key_store, delay, public_key_address) {
100125
console.log("public_key_address = ", public_key_address);
101126
user_id = 1;
102-
sign_url = `${eigen_service}/user/${user_id}/tss/sign`;
127+
sign_url = `${eigen_service}/tss/sign`;
103128
res = await axios.post(
104129
sign_url,
105130
querystring.stringify({
106131
digest: digest.slice(2),
107132
user_address: public_key_address,
133+
user_id: user_id,
108134
}),
109135
{
110136
headers: {
111137
"Content-Type": "application/x-www-form-urlencoded",
112138
},
113139
}
114140
);
115-
console.log(res);
141+
console.log(res.data);
116142
await delay_ms(1000);
117143

118144
let context = await m.gg18_sign_client_new_context(
@@ -125,120 +151,160 @@ async function sign(m, key_store, delay, public_key_address) {
125151
console.log("sign new context: ", context);
126152

127153
round = 0;
128-
res = await axios.post(sign_url, querystring.stringify({ round: round }), {
129-
headers: {
130-
"Content-Type": "application/x-www-form-urlencoded",
131-
},
132-
});
133-
console.log(res);
154+
res = await axios.post(
155+
sign_url,
156+
querystring.stringify({ user_id: user_id, round: round }),
157+
{
158+
headers: {
159+
"Content-Type": "application/x-www-form-urlencoded",
160+
},
161+
}
162+
);
163+
console.log(res.data);
134164
await delay_ms(1000);
135165

136166
context = await m.gg18_sign_client_round0(context, delay);
137167
console.log("sign round0: ");
138168

139169
round = 1;
140-
res = await axios.post(sign_url, querystring.stringify({ round: round }), {
141-
headers: {
142-
"Content-Type": "application/x-www-form-urlencoded",
143-
},
144-
});
145-
console.log(res);
170+
res = await axios.post(
171+
sign_url,
172+
querystring.stringify({ user_id: user_id, round: round }),
173+
{
174+
headers: {
175+
"Content-Type": "application/x-www-form-urlencoded",
176+
},
177+
}
178+
);
179+
console.log(res.data);
146180
await delay_ms(1000);
147181

148182
context = await m.gg18_sign_client_round1(context, delay);
149183
console.log("sign round1: ");
150184

151185
round = 2;
152-
res = await axios.post(sign_url, querystring.stringify({ round: round }), {
153-
headers: {
154-
"Content-Type": "application/x-www-form-urlencoded",
155-
},
156-
});
157-
console.log(res);
186+
res = await axios.post(
187+
sign_url,
188+
querystring.stringify({ user_id: user_id, round: round }),
189+
{
190+
headers: {
191+
"Content-Type": "application/x-www-form-urlencoded",
192+
},
193+
}
194+
);
195+
console.log(res.data);
158196
await delay_ms(1000);
159197

160198
context = await m.gg18_sign_client_round2(context, delay);
161199
console.log("sign round2: ");
162200

163201
round = 3;
164-
res = await axios.post(sign_url, querystring.stringify({ round: round }), {
165-
headers: {
166-
"Content-Type": "application/x-www-form-urlencoded",
167-
},
168-
});
169-
console.log(res);
202+
res = await axios.post(
203+
sign_url,
204+
querystring.stringify({ user_id: user_id, round: round }),
205+
{
206+
headers: {
207+
"Content-Type": "application/x-www-form-urlencoded",
208+
},
209+
}
210+
);
211+
console.log(res.data);
170212
await delay_ms(1000);
171213

172214
context = await m.gg18_sign_client_round3(context, delay);
173215
console.log("sign round3: ");
174216

175217
round = 4;
176-
res = await axios.post(sign_url, querystring.stringify({ round: round }), {
177-
headers: {
178-
"Content-Type": "application/x-www-form-urlencoded",
179-
},
180-
});
181-
console.log(res);
218+
res = await axios.post(
219+
sign_url,
220+
querystring.stringify({ user_id: user_id, round: round }),
221+
{
222+
headers: {
223+
"Content-Type": "application/x-www-form-urlencoded",
224+
},
225+
}
226+
);
227+
console.log(res.data);
182228
await delay_ms(1000);
183229

184230
context = await m.gg18_sign_client_round4(context, delay);
185231
console.log("sign round4: ");
186232

187233
round = 5;
188-
res = await axios.post(sign_url, querystring.stringify({ round: round }), {
189-
headers: {
190-
"Content-Type": "application/x-www-form-urlencoded",
191-
},
192-
});
193-
console.log(res);
234+
res = await axios.post(
235+
sign_url,
236+
querystring.stringify({ user_id: user_id, round: round }),
237+
{
238+
headers: {
239+
"Content-Type": "application/x-www-form-urlencoded",
240+
},
241+
}
242+
);
243+
console.log(res.data);
194244
await delay_ms(1000);
195245

196246
context = await m.gg18_sign_client_round5(context, delay);
197247
console.log("sign round5: ");
198248

199249
round = 6;
200-
res = await axios.post(sign_url, querystring.stringify({ round: round }), {
201-
headers: {
202-
"Content-Type": "application/x-www-form-urlencoded",
203-
},
204-
});
205-
console.log(res);
250+
res = await axios.post(
251+
sign_url,
252+
querystring.stringify({ user_id: user_id, round: round }),
253+
{
254+
headers: {
255+
"Content-Type": "application/x-www-form-urlencoded",
256+
},
257+
}
258+
);
259+
console.log(res.data);
206260
await delay_ms(1000);
207261

208262
context = await m.gg18_sign_client_round6(context, delay);
209263
console.log("sign round6: ");
210264

211265
round = 7;
212-
res = await axios.post(sign_url, querystring.stringify({ round: round }), {
213-
headers: {
214-
"Content-Type": "application/x-www-form-urlencoded",
215-
},
216-
});
217-
console.log(res);
266+
res = await axios.post(
267+
sign_url,
268+
querystring.stringify({ user_id: user_id, round: round }),
269+
{
270+
headers: {
271+
"Content-Type": "application/x-www-form-urlencoded",
272+
},
273+
}
274+
);
275+
console.log(res.data);
218276
await delay_ms(1000);
219277

220278
context = await m.gg18_sign_client_round7(context, delay);
221279
console.log("sign round7: ");
222280

223281
round = 8;
224-
res = await axios.post(sign_url, querystring.stringify({ round: round }), {
225-
headers: {
226-
"Content-Type": "application/x-www-form-urlencoded",
227-
},
228-
});
229-
console.log(res);
282+
res = await axios.post(
283+
sign_url,
284+
querystring.stringify({ user_id: user_id, round: round }),
285+
{
286+
headers: {
287+
"Content-Type": "application/x-www-form-urlencoded",
288+
},
289+
}
290+
);
291+
console.log(res.data);
230292
await delay_ms(1000);
231293

232294
context = await m.gg18_sign_client_round8(context, delay);
233295
console.log("sign round8: ");
234296

235297
round = 9;
236-
res = await axios.post(sign_url, querystring.stringify({ round: round }), {
237-
headers: {
238-
"Content-Type": "application/x-www-form-urlencoded",
239-
},
240-
});
241-
console.log(res);
298+
res = await axios.post(
299+
sign_url,
300+
querystring.stringify({ user_id: user_id, round: round }),
301+
{
302+
headers: {
303+
"Content-Type": "application/x-www-form-urlencoded",
304+
},
305+
}
306+
);
307+
console.log(res.data);
242308
await delay_ms(1000);
243309

244310
sign_json = await m.gg18_sign_client_round9(context, delay);

0 commit comments

Comments
 (0)