Skip to content

Commit

Permalink
Added setFaucetURL in common test helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
marcvelmer committed Oct 24, 2023
1 parent 9e2cc7e commit 46fd73d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/integration/account.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Wallet } from '@ethersproject/wallet';
import { Account, FaucetAPI, strip0x, VocdoniSDKClient } from '../../src';
// @ts-ignore
import { clientParams } from './util/client.params';
import { clientParams, setFaucetURL } from './util/client.params';

let client: VocdoniSDKClient;
let wallet: Wallet;

beforeEach(async () => {
wallet = Wallet.createRandom();
client = new VocdoniSDKClient(clientParams(wallet));
client.faucetService.url = process.env.FAUCET_URL ?? client.faucetService.url;
client = setFaucetURL(client);
});

describe('Account integration tests', () => {
Expand Down Expand Up @@ -135,8 +135,8 @@ describe('Account integration tests', () => {
expect(accountInfo.balance).toBeGreaterThan(0);

const destinationAccount = Wallet.createRandom();
const destinationClient = new VocdoniSDKClient(clientParams(destinationAccount));
destinationClient.faucetService.url = process.env.FAUCET_URL ?? destinationClient.faucetService.url;
let destinationClient = new VocdoniSDKClient(clientParams(destinationAccount));
destinationClient = setFaucetURL(destinationClient);
const destinationInfo = await destinationClient.createAccount();
expect(destinationInfo.balance).toBeGreaterThan(0);
expect(destinationInfo.balance).toEqual(accountInfo.balance);
Expand Down
6 changes: 6 additions & 0 deletions test/integration/util/client.params.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { ClientOptions, EnvOptions } from '../../../src';
import { Wallet } from '@ethersproject/wallet';
import { VocdoniSDKClient } from '@vocdoni/sdk';

export const clientParams = (wallet?: Wallet): ClientOptions => ({
env: EnvOptions.DEV,
api_url: process.env.API_URL,
wallet: wallet ?? Wallet.createRandom(),
});

export const setFaucetURL = (client: VocdoniSDKClient): VocdoniSDKClient => {
client.faucetService.url = process.env.FAUCET_URL ?? client.faucetService.url;
return client;
};

0 comments on commit 46fd73d

Please sign in to comment.