Skip to content

Commit

Permalink
test: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
immortal-tofu committed Mar 7, 2024
1 parent 859d75e commit e0b59ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/sdk/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ describe('index', () => {
expect(instance.encrypt32(BigInt(838392))).toBeTruthy();
expect(instance.encrypt64(BigInt(3433434343))).toBeTruthy();

expect(
instance.encryptAddress('0x8ba1f109551bd432803012645ac136ddd64dba72'),
).toBeTruthy();

expect(() => instance.encryptBool(undefined as any)).toThrow(
'Missing value',
);
Expand Down Expand Up @@ -145,6 +149,12 @@ describe('index', () => {
expect(() => instance.encrypt64('wrong value' as any)).toThrow(
'Value must be a number or a bigint.',
);
expect(() => instance.encryptAddress('wrong value' as any)).toThrow(
'Value must be a valid address.',
);
expect(() => instance.encryptAddress(BigInt(32) as any)).toThrow(
'Value must be a string.',
);

// Check limit
expect(instance.encryptBool(1)).toBeTruthy();
Expand Down
1 change: 1 addition & 0 deletions src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export const createInstance = async (
throw new Error(
'Your instance has been created without the public blockchain key.',
);
if (typeof value !== 'string') throw new Error('Value must be a string.');
if (!isAddress(value)) throw new Error('Value must be a valid address.');
return encryptAddress(value, tfheCompactPublicKey);
},
Expand Down

0 comments on commit e0b59ab

Please sign in to comment.