Skip to content

Commit

Permalink
add lukso provder to any others tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNi245 committed Sep 6, 2024
1 parent 5063aa9 commit 7fc63ec
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/backend/src/profile/profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ const setUpApp = async (
db: IBackendDatabase,
web3Provider: ethers.providers.JsonRpcProvider,
serverSecret: string = 'my-secret',
luksoProvider: ethers.providers.JsonRpcProvider = {} as ethers.providers.JsonRpcProvider,
) => {
app.use(bodyParser.json());
const server = http.createServer(app);
app.use(profile(db, web3Provider, serverSecret));
app.use(profile(db, web3Provider, luksoProvider, serverSecret));
};

const createDbMock = async () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/delivery-service/src/profile/profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ const setUpApp = async (
db: IDatabase,
web3Provider: ethers.providers.JsonRpcProvider,
serverSecret: string = 'my-secret',
luksoProvider: ethers.providers.JsonRpcProvider = {} as ethers.providers.JsonRpcProvider,
) => {
app.use(bodyParser.json());
app.use(profile(db, web3Provider, serverSecret));
app.use(profile(db, web3Provider, luksoProvider, serverSecret));
};

const createDbMock = async () => {
Expand Down
8 changes: 6 additions & 2 deletions packages/lib/delivery/src/UserProfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ describe('UserProfile', () => {
const getAccount = () => Promise.resolve(null);

const singedUserProfile = await signProfile(emptyProfile);
const luksoProvider = {} as ethers.providers.BaseProvider;
const luksoProvider = {
_isProvider: true,
} as ethers.providers.BaseProvider;

await expect(async () => {
await submitUserProfile(
Expand All @@ -57,7 +59,9 @@ describe('UserProfile', () => {
singedUserProfile,
'my-secret',
);
}).rejects.toEqual(Error('Signature invalid.'));
}).rejects.toEqual(
Error('submit user profile failed - invalid profile'),
);
expect(setAccount).not.toBeCalled();
});

Expand Down
1 change: 1 addition & 0 deletions packages/lib/delivery/src/UserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export async function submitUserProfile(
);

if (!isValidProfile) {
console.error({ signedUserProfile, _address });
throw Error('submit user profile failed - invalid profile');
}

Expand Down
12 changes: 12 additions & 0 deletions packages/lib/profile/src/Profile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ describe('Account', () => {
{
resolveName: async () => profile.address,
} as any,
{
_isProvider: true,
} as any,

{
profile: profile.account.profile!,
Expand All @@ -184,6 +187,9 @@ describe('Account', () => {
{
resolveName: async () => profile.address,
} as any,
{
_isProvider: true,
} as any,
{
profile: {
...profile.account.profile!,
Expand Down Expand Up @@ -273,6 +279,9 @@ describe('Account', () => {
{
resolveName: async () => profile.address,
} as any,
{
_isProvider: true,
} as any,
profile.signedUserProfile,
profile.account.ensName,
),
Expand All @@ -286,6 +295,9 @@ describe('Account', () => {
{
resolveName: async () => profile.address,
} as any,
{
_isProvider: true,
} as any,
{
profile: {
...profile.account.profile!,
Expand Down

0 comments on commit 7fc63ec

Please sign in to comment.