Skip to content

Commit 755bd25

Browse files
committed
chore: improves test utils
1 parent 23afaaf commit 755bd25

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
ENVIRONMENT=local
2+
PRIVATE_KEY=<private_key>

packages/client/src/test-utils.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,31 @@ import { schema } from '@aave/graphql/test-utils';
66
import type { TypedDocumentNode } from '@urql/core';
77
import { validate } from 'graphql';
88
import type { ValidationRule } from 'graphql/validation/ValidationContext';
9+
import { createWalletClient, http, type WalletClient } from 'viem';
10+
import { privateKeyToAccount } from 'viem/accounts';
11+
import { sepolia } from 'viem/chains';
912
import { expect } from 'vitest';
13+
import { AaveClient } from './client';
1014
import { GraphQLErrorCode } from './errors';
1115

16+
export const signer = privateKeyToAccount(import.meta.env.PRIVATE_KEY);
1217
export const environment =
1318
import.meta.env.ENVIRONMENT === 'local'
1419
? local
1520
: import.meta.env.ENVIRONMENT === 'staging'
1621
? staging
1722
: testnet;
1823

24+
export const client = AaveClient.create({
25+
environment,
26+
});
27+
28+
export const wallet: WalletClient = createWalletClient({
29+
account: signer,
30+
chain: sepolia,
31+
transport: http(),
32+
});
33+
1934
const messages: Record<GraphQLErrorCode, string> = {
2035
[GraphQLErrorCode.UNAUTHENTICATED]:
2136
"Unauthenticated - Authentication is required to access '<operation>'",

vite-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
interface ImportMetaEnv {
44
readonly ENVIRONMENT: 'testnet' | 'staging' | 'local' | undefined;
5+
readonly PRIVATE_KEY: `0x${string}`;
56
}
67

78
interface ImportMeta {

0 commit comments

Comments
 (0)