Skip to content

Commit

Permalink
fix tests, SiweErrorType has no values, is not object
Browse files Browse the repository at this point in the history
  • Loading branch information
chunningham committed Nov 25, 2024
1 parent 95730e2 commit add709f
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions packages/siwe/lib/client.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import * as fs from "fs";
import * as fs from 'fs';

const parsingPositive: object = JSON.parse(fs.readFileSync('../../test/parsing_positive.json', 'utf8'));
const parsingNegative: object = JSON.parse(fs.readFileSync('../../test/parsing_negative.json', 'utf8'));
const parsingNegativeObjects: object = JSON.parse(fs.readFileSync('../../test/parsing_negative_objects.json', 'utf8'));
const verificationPositive: object = JSON.parse(fs.readFileSync('../../test/verification_positive.json', 'utf8'));
const verificationNegative: object = JSON.parse(fs.readFileSync('../../test/verification_negative.json', 'utf8'));
const EIP1271: object = JSON.parse(fs.readFileSync('../../test/eip1271.json', 'utf8'));
const parsingPositive: object = JSON.parse(
fs.readFileSync('../../test/parsing_positive.json', 'utf8')
);
const parsingNegative: object = JSON.parse(
fs.readFileSync('../../test/parsing_negative.json', 'utf8')
);
const parsingNegativeObjects: object = JSON.parse(
fs.readFileSync('../../test/parsing_negative_objects.json', 'utf8')
);
const verificationPositive: object = JSON.parse(
fs.readFileSync('../../test/verification_positive.json', 'utf8')
);
const verificationNegative: object = JSON.parse(
fs.readFileSync('../../test/verification_negative.json', 'utf8')
);
const EIP1271: object = JSON.parse(
fs.readFileSync('../../test/eip1271.json', 'utf8')
);

import {
// @ts-expect-error -- ethers v6 compatibility hack
Expand All @@ -30,8 +42,9 @@ describe(`Message Generation`, () => {
(n, test) => {
try {
new SiweMessage(test);
expect(false).toBeTruthy();
} catch (error) {
expect(Object.values(SiweErrorType).includes(error));
expect(true).toBeTruthy();
}
}
);
Expand All @@ -41,8 +54,9 @@ describe(`Message Generation`, () => {
(n, test) => {
try {
new SiweMessage(test as any);
expect(false).toBeTruthy();
} catch (error) {
expect(Object.values(SiweErrorType).includes(error));
expect(true).toBeTruthy();
}
}
);
Expand All @@ -67,7 +81,9 @@ describe(`Message verification without suppressExceptions`, () => {
.then(async ({ data }) => {
jest
.useFakeTimers()
.setSystemTime(new Date((test_fields as any).time || test_fields.issuedAt));
.setSystemTime(
new Date((test_fields as any).time || test_fields.issuedAt)
);
const res = await msg.validate(test_fields.signature);
return res === data;
})
Expand Down

0 comments on commit add709f

Please sign in to comment.