Skip to content

Commit b04daad

Browse files
committed
fix: failing unit tests
1 parent fe4c47b commit b04daad

File tree

4 files changed

+61
-48
lines changed

4 files changed

+61
-48
lines changed

packages/lit-node-client-nodejs/src/lib/helpers/get-max-prices-for-nodes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PRODUCT_IDS } from '@lit-protocol/constants';
1+
import { PRODUCT_IDS } from '@lit-protocol/types';
22

33
import { getMaxPricesForNodeProduct } from './get-max-prices-for-node-product';
44

packages/lit-node-client-nodejs/src/lib/helpers/parse-pkp-sign-response.test.ts

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ describe('parsePkpSignResponse', () => {
1212
const responseData: PKPSignEndpointResponse[] = [
1313
{
1414
success: false,
15-
signedData: new Uint8Array([
15+
signedData: [
1616
125, 135, 197, 234, 117, 247, 55, 139, 183, 1, 228, 4, 197, 6, 57, 22,
1717
26, 243, 239, 246, 98, 147, 233, 243, 117, 181, 241, 126, 181, 4, 118,
1818
244,
19-
]),
19+
],
2020
signatureShare: {
2121
EcdsaSignedMessageShare: {
2222
digest: 'fail',
@@ -33,11 +33,11 @@ describe('parsePkpSignResponse', () => {
3333
},
3434
{
3535
success: true,
36-
signedData: new Uint8Array([
36+
signedData: [
3737
125, 135, 197, 234, 117, 247, 55, 139, 183, 1, 228, 4, 197, 6, 57, 22,
3838
26, 243, 239, 246, 98, 147, 233, 243, 117, 181, 241, 126, 181, 4, 118,
3939
244,
40-
]),
40+
],
4141
signatureShare: {
4242
EcdsaSignedMessageShare: {
4343
digest:
@@ -55,17 +55,17 @@ describe('parsePkpSignResponse', () => {
5555
'"0381ff5b9f673837eacd4dca7e9377084250dccfc13ebf13913e662182027d1482"',
5656
public_key:
5757
'"04156D7E068BF5ED014057B8B6365BF89053D567D38EC24030C699B94065F2D39B4D45F463464F1A138D7149D1C0EF41ACF9B8826050B9E3DCC847DE2127BDB726"',
58-
sig_type: 'K256',
58+
sig_type: 'EcdsaK256Sha256',
5959
},
6060
},
6161
},
6262
{
6363
success: true,
64-
signedData: new Uint8Array([
64+
signedData: [
6565
125, 135, 197, 234, 117, 247, 55, 139, 183, 1, 228, 4, 197, 6, 57, 22,
6666
26, 243, 239, 246, 98, 147, 233, 243, 117, 181, 241, 126, 181, 4, 118,
6767
244,
68-
]),
68+
],
6969
signatureShare: {
7070
EcdsaSignedMessageShare: {
7171
digest:
@@ -83,7 +83,7 @@ describe('parsePkpSignResponse', () => {
8383
'"0381ff5b9f673837eacd4dca7e9377084250dccfc13ebf13913e662182027d1482"',
8484
public_key:
8585
'"04156D7E068BF5ED014057B8B6365BF89053D567D38EC24030C699B94065F2D39B4D45F463464F1A138D7149D1C0EF41ACF9B8826050B9E3DCC847DE2127BDB726"',
86-
sig_type: 'K256',
86+
sig_type: 'EcdsaK256Sha256',
8787
},
8888
},
8989
},
@@ -93,6 +93,7 @@ describe('parsePkpSignResponse', () => {
9393
{
9494
digest: 'fail',
9595
shareId: '',
96+
peerId: '',
9697
signatureShare: '',
9798
bigR: '',
9899
compressedPublicKey: '',
@@ -102,35 +103,39 @@ describe('parsePkpSignResponse', () => {
102103
},
103104
{
104105
digest:
105-
'7D87C5EA75F7378BB701E404C50639161AF3EFF66293E9F375B5F17EB50476F4',
106+
'0x7D87C5EA75F7378BB701E404C50639161AF3EFF66293E9F375B5F17EB50476F4',
106107
shareId:
107-
'1A0369823607C6EF403D86BA41534DDB1420730C696060EAD7931DE5DB603937',
108+
'0x1A0369823607C6EF403D86BA41534DDB1420730C696060EAD7931DE5DB603937',
109+
peerId:
110+
'0x800ca9780644bb7e1908efa6bd1a0686f1095158c3ba6f1649ef9d2d67bfaf34',
108111
signatureShare:
109-
'3ED0A844FAE40DF6210A6B2EACB9426E52E8339E243E697E33CF14E0CDE2B827',
110-
bigR: '0332188F0918B7DEBB0CC846B00B0AAD9300308260C2DAD25A85FDECA671C36B1B',
112+
'0x3ED0A844FAE40DF6210A6B2EACB9426E52E8339E243E697E33CF14E0CDE2B827',
113+
bigR: '0x0332188F0918B7DEBB0CC846B00B0AAD9300308260C2DAD25A85FDECA671C36B1B',
111114
compressedPublicKey:
112-
'0381ff5b9f673837eacd4dca7e9377084250dccfc13ebf13913e662182027d1482',
115+
'0x0381ff5b9f673837eacd4dca7e9377084250dccfc13ebf13913e662182027d1482',
113116
publicKey:
114-
'04156D7E068BF5ED014057B8B6365BF89053D567D38EC24030C699B94065F2D39B4D45F463464F1A138D7149D1C0EF41ACF9B8826050B9E3DCC847DE2127BDB726',
115-
sigType: 'K256',
117+
'0x04156D7E068BF5ED014057B8B6365BF89053D567D38EC24030C699B94065F2D39B4D45F463464F1A138D7149D1C0EF41ACF9B8826050B9E3DCC847DE2127BDB726',
118+
sigType: 'EcdsaK256Sha256',
116119
dataSigned:
117-
'7D87C5EA75F7378BB701E404C50639161AF3EFF66293E9F375B5F17EB50476F4',
120+
'0x7D87C5EA75F7378BB701E404C50639161AF3EFF66293E9F375B5F17EB50476F4',
118121
},
119122
{
120123
digest:
121-
'7D87C5EA75F7378BB701E404C50639161AF3EFF66293E9F375B5F17EB50476F4',
124+
'0x7D87C5EA75F7378BB701E404C50639161AF3EFF66293E9F375B5F17EB50476F4',
122125
shareId:
123-
'1A0369823607C6EF403D86BA41534DDB1420730C696060EAD7931DE5DB603937',
126+
'0x1A0369823607C6EF403D86BA41534DDB1420730C696060EAD7931DE5DB603937',
127+
peerId:
128+
'0x800ca9780644bb7e1908efa6bd1a0686f1095158c3ba6f1649ef9d2d67bfaf34',
124129
signatureShare:
125-
'B1AA643E88F8937B71CE2D43DCB73E0180AC96D1E39ECC579F0EC9635F37D4CB',
126-
bigR: '0332188F0918B7DEBB0CC846B00B0AAD9300308260C2DAD25A85FDECA671C36B1B',
130+
'0xB1AA643E88F8937B71CE2D43DCB73E0180AC96D1E39ECC579F0EC9635F37D4CB',
131+
bigR: '0x0332188F0918B7DEBB0CC846B00B0AAD9300308260C2DAD25A85FDECA671C36B1B',
127132
compressedPublicKey:
128-
'0381ff5b9f673837eacd4dca7e9377084250dccfc13ebf13913e662182027d1482',
133+
'0x0381ff5b9f673837eacd4dca7e9377084250dccfc13ebf13913e662182027d1482',
129134
publicKey:
130-
'04156D7E068BF5ED014057B8B6365BF89053D567D38EC24030C699B94065F2D39B4D45F463464F1A138D7149D1C0EF41ACF9B8826050B9E3DCC847DE2127BDB726',
131-
sigType: 'K256',
135+
'0x04156D7E068BF5ED014057B8B6365BF89053D567D38EC24030C699B94065F2D39B4D45F463464F1A138D7149D1C0EF41ACF9B8826050B9E3DCC847DE2127BDB726',
136+
sigType: 'EcdsaK256Sha256',
132137
dataSigned:
133-
'7D87C5EA75F7378BB701E404C50639161AF3EFF66293E9F375B5F17EB50476F4',
138+
'0x7D87C5EA75F7378BB701E404C50639161AF3EFF66293E9F375B5F17EB50476F4',
134139
},
135140
];
136141

@@ -143,11 +148,11 @@ describe('parsePkpSignResponse', () => {
143148
const responseData: PKPSignEndpointResponse[] = [
144149
{
145150
success: false,
146-
signedData: new Uint8Array([
151+
signedData: [
147152
116, 248, 31, 225, 103, 217, 155, 76, 180, 29, 109, 12, 205, 168, 34,
148153
120, 202, 238, 159, 62, 47, 37, 213, 229, 163, 147, 111, 243, 220,
149154
236, 96, 208,
150-
]),
155+
],
151156
signatureShare: {
152157
FrostSignedMessageShare: {
153158
message: 'fail',
@@ -164,11 +169,11 @@ describe('parsePkpSignResponse', () => {
164169
},
165170
{
166171
success: true,
167-
signedData: new Uint8Array([
172+
signedData: [
168173
116, 248, 31, 225, 103, 217, 155, 76, 180, 29, 109, 12, 205, 168, 34,
169174
120, 202, 238, 159, 62, 47, 37, 213, 229, 163, 147, 111, 243, 220,
170175
236, 96, 208,
171-
]),
176+
],
172177
signatureShare: {
173178
FrostSignedMessageShare: {
174179
message:
@@ -192,11 +197,11 @@ describe('parsePkpSignResponse', () => {
192197
},
193198
{
194199
success: true,
195-
signedData: new Uint8Array([
200+
signedData: [
196201
116, 248, 31, 225, 103, 217, 155, 76, 180, 29, 109, 12, 205, 168, 34,
197202
120, 202, 238, 159, 62, 47, 37, 213, 229, 163, 147, 111, 243, 220,
198203
236, 96, 208,
199-
]),
204+
],
200205
signatureShare: {
201206
FrostSignedMessageShare: {
202207
message:
@@ -230,45 +235,50 @@ describe('parsePkpSignResponse', () => {
230235
verifyingShare: '',
231236
publicKey: '',
232237
sigType: '',
238+
dataSigned: 'fail',
233239
},
234240
{
235241
message:
236-
'74f81fe167d99b4cb41d6d0ccda82278caee9f3e2f25d5e5a3936ff3dcec60d0',
242+
'0x74f81fe167d99b4cb41d6d0ccda82278caee9f3e2f25d5e5a3936ff3dcec60d0',
237243
shareId: new Uint8Array([
238244
21, 126, 1, 81, 188, 147, 173, 138, 16, 169, 115, 205, 1, 224, 43, 54,
239245
73, 148, 113, 48, 206, 233, 7, 6, 217, 224, 119, 81, 249, 220, 48, 41,
240246
]),
241247
peerId:
242-
'77b2a2f061adf273b52307fb1c9960137c854382a9ae8d54d60c149e006a0d7c',
248+
'0x77b2a2f061adf273b52307fb1c9960137c854382a9ae8d54d60c149e006a0d7c',
243249
signatureShare:
244-
'12f86c0d816e98076bdf9cfc39812f7d242f7ac73aefa3638fb7cd1cf63ef7ed',
250+
'0x12f86c0d816e98076bdf9cfc39812f7d242f7ac73aefa3638fb7cd1cf63ef7ed',
245251
signingCommitments:
246-
'00eed6b1b10396989fe69ba9f582ec87e14a01dcad420ad6fd1ec0ce1a63165f30947dc86fef029f61149ebcbd87868105bebd3582577a3c4b6c6a092c621a8a842940b04d8629',
252+
'0x00eed6b1b10396989fe69ba9f582ec87e14a01dcad420ad6fd1ec0ce1a63165f30947dc86fef029f61149ebcbd87868105bebd3582577a3c4b6c6a092c621a8a842940b04d8629',
247253
verifyingShare:
248-
'022ba83de8961efba1490d9d3603a51b9d1c0eb17245ce0cbd8295d62ccd7e886c',
254+
'0x022ba83de8961efba1490d9d3603a51b9d1c0eb17245ce0cbd8295d62ccd7e886c',
249255
publicKey:
250-
'02c5f80a840bc7d00f26dfb8c2a0075aeffc620df39d2188f3e0237ec42dbe920a',
256+
'0x02c5f80a840bc7d00f26dfb8c2a0075aeffc620df39d2188f3e0237ec42dbe920a',
251257
sigType: 'SchnorrK256Sha256',
258+
dataSigned:
259+
'0x74f81fe167d99b4cb41d6d0ccda82278caee9f3e2f25d5e5a3936ff3dcec60d0',
252260
},
253261
{
254262
message:
255-
'74f81fe167d99b4cb41d6d0ccda82278caee9f3e2f25d5e5a3936ff3dcec60d0',
263+
'0x74f81fe167d99b4cb41d6d0ccda82278caee9f3e2f25d5e5a3936ff3dcec60d0',
256264
shareId: new Uint8Array([
257265
226, 183, 233, 101, 218, 75, 198, 127, 202, 46, 107, 100, 150, 15,
258266
170, 176, 229, 25, 121, 33, 202, 13, 26, 6, 192, 49, 160, 84, 130, 11,
259267
169, 174,
260268
]),
261269
peerId:
262-
'8b714aa4b2b8cda1502834522c146d648b1d1eb71910b7064fa3adcb6269a575',
270+
'0x8b714aa4b2b8cda1502834522c146d648b1d1eb71910b7064fa3adcb6269a575',
263271
signatureShare:
264-
'5e6350c02c361f1ed97865ed57bd395190991c673ea55044c3c291155cc14c9b',
272+
'0x5e6350c02c361f1ed97865ed57bd395190991c673ea55044c3c291155cc14c9b',
265273
signingCommitments:
266-
'00eed6b1b102f72cf9291f23e939db9758123f155da75cf1150526b847c3c788de7e9b2f6e1f035a3db8a5664117f161e9eca110bbf515395a1c44625202aad1311d71b1b5df7a',
274+
'0x00eed6b1b102f72cf9291f23e939db9758123f155da75cf1150526b847c3c788de7e9b2f6e1f035a3db8a5664117f161e9eca110bbf515395a1c44625202aad1311d71b1b5df7a',
267275
verifyingShare:
268-
'02b680446e13263aea72c7da159393e64228110d4a4a6db36481bc55c92c616c46',
276+
'0x02b680446e13263aea72c7da159393e64228110d4a4a6db36481bc55c92c616c46',
269277
publicKey:
270-
'02c5f80a840bc7d00f26dfb8c2a0075aeffc620df39d2188f3e0237ec42dbe920a',
278+
'0x02c5f80a840bc7d00f26dfb8c2a0075aeffc620df39d2188f3e0237ec42dbe920a',
271279
sigType: 'SchnorrK256Sha256',
280+
dataSigned:
281+
'0x74f81fe167d99b4cb41d6d0ccda82278caee9f3e2f25d5e5a3936ff3dcec60d0',
272282
},
273283
];
274284

packages/lit-node-client-nodejs/src/lib/helpers/parse-pkp-sign-response.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import {
1919
export const parsePkpSignResponse = (
2020
responseData: PKPSignEndpointResponse[]
2121
): PKPSignEndpointSharesParsed[] => {
22-
const ecdsaSignedMessageShares =
23-
responseData.map<PKPSignEndpointSharesParsed>(({ signatureShare }) => {
22+
const parsedSignatureShares = responseData.map<PKPSignEndpointSharesParsed>(
23+
({ signatureShare }) => {
2424
// Determine if the object is lifted or contains a nested structure
2525
// Example scenarios this logic handles:
2626
// 1. If `signatureShare` is nested (e.g., { EcdsaSignedMessageShare: { ... } }),
@@ -65,7 +65,8 @@ export const parsePkpSignResponse = (
6565
delete parsedShare['result'];
6666

6767
return parsedShare as unknown as PKPSignEndpointSharesParsed;
68-
});
68+
}
69+
);
6970

70-
return ecdsaSignedMessageShares;
71+
return parsedSignatureShares;
7172
};

packages/misc/src/lib/misc.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ describe('utils', () => {
7777
});
7878

7979
it('throws when given an empty array, there is no most common response', () => {
80-
expect(utilsModule.findMostCommonResponse([])).toThrow();
80+
expect(() => utilsModule.findMostCommonResponse([])).toThrow(
81+
'findMostCommonResponse requires at least one response object'
82+
);
8183
});
8284

8385
it('handles nested objects recursively', () => {

0 commit comments

Comments
 (0)