Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nigthly tests #1222

Merged
merged 3 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages/integration-test/test/layers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
StorageTypes,
} from '@requestnetwork/types';
import { providers, Wallet } from 'ethers';
import { automine } from './scheduled/fixtures';

let advancedLogic: AdvancedLogicTypes.IAdvancedLogic;
let requestLogic: RequestLogicTypes.IRequestLogic;
Expand All @@ -38,14 +39,7 @@ let signatureProvider: any;

let dataAccess: DataAccessTypes.IDataAccess;

const interval = setInterval(async () => {
await provider.send('evm_mine', []);
// eslint-disable-next-line no-magic-numbers
}, 200);

afterAll(() => {
clearInterval(interval);
});
automine();

const mnemonic = 'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Types, Utils } from '@requestnetwork/request-client.js';

import { mockAdvancedLogic } from './mocks';
import {
automine,
erc20requestCreationHash,
localErc20PaymentNetworkParams,
payeeIdentity,
Expand All @@ -14,6 +15,8 @@ import {
} from './fixtures';
import { createMockErc20FeeRequest } from '../utils';

automine();

const pnFactory = new PaymentNetworkFactory(mockAdvancedLogic, CurrencyManager.getDefault());

const paidRequest = {
Expand Down
14 changes: 8 additions & 6 deletions packages/integration-test/test/scheduled/erc20-proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { mockAdvancedLogic } from './mocks';
import { Types, Utils } from '@requestnetwork/request-client.js';
import { CurrencyManager } from '@requestnetwork/currency';
import {
automine,
erc20requestCreationHash,
localErc20PaymentNetworkParams,
payeeIdentity,
Expand All @@ -13,6 +14,8 @@ import {
requestNetwork,
} from './fixtures';

automine();

const erc20ProxyAddressedBased = new Erc20PaymentNetwork.ERC20ProxyPaymentDetector({
advancedLogic: mockAdvancedLogic,
currencyManager: CurrencyManager.getDefault(),
Expand All @@ -29,6 +32,7 @@ describe('ERC20 Proxy detection test-suite', () => {
requestInfo: erc20requestCreationHash,
signer: payeeIdentity,
});
await request.waitForConfirmation();

let requestData = await request.declareReceivedPayment('1', 'OK', payeeIdentity);
const declarationTimestamp = Utils.getCurrentTimestampInSecond();
Expand Down Expand Up @@ -60,14 +64,12 @@ describe('ERC20 Proxy detection test-suite', () => {
requestInfo: erc20requestCreationHash,
signer: payeeIdentity,
});
const refreshedRequest = await request.waitForConfirmation();
expect(refreshedRequest.state).toBe('created');

// The payer declares a payment
let requestData: Types.IRequestDataWithEvents = await request.declareSentPayment(
'1',
'OK',
payerIdentity,
);
requestData = await new Promise((resolve): unknown => requestData.on('confirmed', resolve));
let requestData = await request.declareSentPayment('1', 'OK', payerIdentity);
requestData = await new Promise((resolve) => requestData.on('confirmed', resolve));
const balance = await erc20ProxyAddressedBased.getBalance({
...requestData,
currency: {
Expand Down
8 changes: 8 additions & 0 deletions packages/integration-test/test/scheduled/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IdentityTypes, PaymentTypes, ExtensionTypes } from '@requestnetwork/types';
import { RequestNetwork, Types } from '@requestnetwork/request-client.js';
import { EthereumPrivateKeySignatureProvider } from '@requestnetwork/epk-signature';
import { providers } from 'ethers';

export const httpConfig = {
getConfirmationDeferDelay: 1000,
Expand Down Expand Up @@ -67,3 +68,10 @@ export const localEthInputDataPaymentNetworkParams: PaymentTypes.PaymentNetworkC
paymentAddress: '0xf17f52151EbEF6C7334FAD080c5704D77216b732',
},
};

export const automine = (freq = 200) => {
const provider = new providers.JsonRpcProvider();
setInterval(async () => {
await provider.send('evm_mine', []);
}, freq).unref();
};