Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/relayer-provider/v1/networkV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '@sdk/lowlevel/constants';
import { fetchRelayerV1Get } from './fetchRelayerV1';
import { isNonEmptyString, removeSuffix } from '@base/string';
import { TFHEError } from '../../errors/TFHEError';

// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type CachedKey = {
Expand Down Expand Up @@ -142,7 +143,8 @@ export async function getKeysFromRelayer(
keyurlCache[versionUrl] = result;
return result;
} catch (e) {
throw new Error('Impossible to fetch public key: wrong relayer url.', {
throw new TFHEError({
message: 'Failed to fetch keys from relayer',
cause: e,
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/sdk/lowlevel/TFHEPkeCrs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,19 +270,19 @@ describeIfFetchMock('TFHEPkeCrs', () => {
it('throws on invalid params (missing id)', async () => {
await expect(
TFHEPkeCrs.fetch({ srcUrl: testUrl, capacity: 2048 } as any),
).rejects.toThrow('Impossible to fetch public key: wrong relayer url.');
).rejects.toThrow('Failed to fetch CRS');
});

it('throws on invalid params (missing srcUrl)', async () => {
await expect(
TFHEPkeCrs.fetch({ id: assetPublicParamsId, capacity: 2048 } as any),
).rejects.toThrow('Impossible to fetch public key: wrong relayer url.');
).rejects.toThrow('Failed to fetch CRS');
});

it('throws on invalid params (missing capacity)', async () => {
await expect(
TFHEPkeCrs.fetch({ id: assetPublicParamsId, srcUrl: testUrl } as any),
).rejects.toThrow('Impossible to fetch public key: wrong relayer url.');
).rejects.toThrow('Failed to fetch CRS');
});

it('throws on fetch error', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/lowlevel/TFHEPkeCrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class TFHEPkeCrs {
return await TFHEPkeCrs.#fetch(params);
} catch (e) {
throw new TFHEError({
message: 'Impossible to fetch public key: wrong relayer url.',
message: 'Failed to fetch CRS',
cause: e,
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/sdk/lowlevel/TFHEPkeParams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ describe('TFHEPkeParams', () => {
capacity: 2048,
},
}),
).rejects.toThrow('Impossible to fetch public key: wrong relayer url.');
).rejects.toThrow('Failed to fetch PKE params');
});

it('throws on invalid pkeCrs bytes', async () => {
Expand All @@ -334,7 +334,7 @@ describe('TFHEPkeParams', () => {
capacity: 2048,
},
}),
).rejects.toThrow('Impossible to fetch public key: wrong relayer url.');
).rejects.toThrow('Failed to fetch PKE params');
});
});
});
2 changes: 1 addition & 1 deletion src/sdk/lowlevel/TFHEPkeParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class TFHEPkeParams {
});
} catch (e) {
throw new TFHEError({
message: 'Impossible to fetch public key: wrong relayer url.',
message: 'Failed to fetch PKE params',
cause: e,
});
}
Expand Down
6 changes: 3 additions & 3 deletions src/sdk/lowlevel/TFHEPublicKey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,13 @@ describe('TFHEPublicKey', () => {
it('throws on invalid params (missing id)', async () => {
await expect(
TFHEPublicKey.fetch({ srcUrl: testUrl } as any),
).rejects.toThrow('Impossible to fetch public key: wrong relayer url.');
).rejects.toThrow('Failed to fetch public key');
});

it('throws on invalid params (missing srcUrl)', async () => {
await expect(
TFHEPublicKey.fetch({ id: tfhePublicKeyBytes.id } as any),
).rejects.toThrow('Impossible to fetch public key: wrong relayer url.');
).rejects.toThrow('Failed to fetch public key');
});

it('throws on fetch error', async () => {
Expand All @@ -318,7 +318,7 @@ describe('TFHEPublicKey', () => {
id: tfhePublicKeyBytes.id,
srcUrl: testUrl,
}),
).rejects.toThrow('Impossible to fetch public key: wrong relayer url.');
).rejects.toThrow('Failed to fetch public key');
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/sdk/lowlevel/TFHEPublicKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class TFHEPublicKey {
return await TFHEPublicKey.#fetch(params);
} catch (e) {
throw new TFHEError({
message: 'Impossible to fetch public key: wrong relayer url.',
message: 'Failed to fetch public key',
cause: e,
});
}
Expand Down