Skip to content

Commit

Permalink
fix: fixing scheduled tests (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
KolevDarko committed Mar 11, 2022
1 parent c4c2276 commit 332e3ab
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('ERC20 Fee Proxy detection test-suite', () => {
expect(params?.to).toBe('0x4E64C2d06d19D13061e62E291b2C4e9fe5679b93');
expect(balance.events[0].amount).toBe('1000000000000000000');
expect(balance.events[0].timestamp).toBe(1599070058);
});
}, 10000);

it('can getBalance on a rinkeby request', async () => {
const mockRequest = createMockErc20FeeRequest({
Expand All @@ -63,7 +63,7 @@ describe('ERC20 Fee Proxy detection test-suite', () => {
expect(params?.to).toBe('0x4E64C2d06d19D13061e62E291b2C4e9fe5679b93');
expect(balance.events[0].amount).toBe('1000000000000000000000');
expect(balance.events[0].timestamp).toBe(1599013969);
});
}, 10000);

it('can getBalance on a matic request, with TheGraph', async () => {
const mockRequest = createMockErc20FeeRequest({
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('ERC20 Fee Proxy detection test-suite', () => {
expect(balance.events[0].name).toBe('payment');
expect(balance.events[0].amount).toBe('1');
expect(Math.abs(declarationTimestamp - (balance.events[0].timestamp ?? 0))).toBeLessThan(5);
});
}, 15000);

it('getBalance = 0 if the payer declared the payment', async () => {
// Create a request
Expand All @@ -141,5 +141,5 @@ describe('ERC20 Fee Proxy detection test-suite', () => {
});
expect(balance.balance).toBe('0');
expect(balance.events).toHaveLength(0);
});
}, 15000);
});
4 changes: 2 additions & 2 deletions packages/integration-test/test/scheduled/erc20-proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('ERC20 Proxy detection test-suite', () => {
expect(balance.events[0].name).toBe('payment');
expect(balance.events[0].amount).toBe('1');
expect(Math.abs(declarationTimestamp - (balance.events[0].timestamp ?? 0))).toBeLessThan(5);
});
}, 10000);

it('getBalance = 0 if the payer declared the payment', async () => {
// Create a request
Expand Down Expand Up @@ -75,5 +75,5 @@ describe('ERC20 Proxy detection test-suite', () => {
});
expect(balance.balance).toBe('0');
expect(balance.events).toHaveLength(0);
});
}, 10000);
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ describe('ETH Fee proxy detection test-suite', () => {
const balance = await ethInputContract.getBalance({
...requestData,
currency: {
network: 'private',
network: 'rinkeby',
type: RequestLogicTypes.CURRENCY.ETH,
value: privateErc20Address,
},
});

expect(balance.error).toBeUndefined();
expect(balance.balance).toBe('50000000000000000');
expect(balance.events).toHaveLength(1);
expect(balance.events[0].name).toBe('payment');
expect(balance.events[0].amount).toBe('1');
expect(balance.events[0].amount).toBe('50000000000000000');
expect(Math.abs(declarationTimestamp - (balance.events[0].timestamp ?? 0))).toBeLessThan(5);
});
}, 20000);

it('getBalance = 0 if the payer declared the payment', async () => {
// Create a request
Expand Down
4 changes: 3 additions & 1 deletion packages/integration-test/test/scheduled/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const erc20requestCreationHash: Types.IRequestInfo = {

export const ethInputDataCreationHash: Types.IRequestInfo = {
currency: {
network: 'private',
network: 'rinkeby',
type: Types.RequestLogic.CURRENCY.ETH,
value: privateErc20Address, // TODO: Change to ETH address
},
Expand All @@ -56,6 +56,8 @@ export const localErc20PaymentNetworkParams: PaymentTypes.IPaymentNetworkCreateP
id: PaymentTypes.PAYMENT_NETWORK_ID.ERC20_FEE_PROXY_CONTRACT,
parameters: {
paymentAddress: '0xf17f52151EbEF6C7334FAD080c5704D77216b732',
feeAddress: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
feeAmount: '0',
},
};

Expand Down
20 changes: 18 additions & 2 deletions packages/integration-test/test/scheduled/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const mockAdvancedLogic: AdvancedLogicTypes.IAdvancedLogic = {
createCreationAction,
},
feeProxyContractErc20: {
supportedNetworks: ['mainnet', 'rinkeby'],
supportedNetworks: ['mainnet', 'rinkeby', 'private', 'matic'],
createAddPaymentAddressAction,
createAddRefundAddressAction,
createCreationAction,
Expand All @@ -28,13 +28,29 @@ export const mockAdvancedLogic: AdvancedLogicTypes.IAdvancedLogic = {
createAddRefundInstructionAction,
},
proxyContractErc20: {
supportedNetworks: ['rinkeby'],
supportedNetworks: ['rinkeby', 'private'],
createAddPaymentAddressAction,
createAddRefundAddressAction,
createCreationAction,
// inheritance from declarative
createAddPaymentInstructionAction,
createAddRefundInstructionAction,
},
feeProxyContractEth: {
supportedNetworks: ['rinkeby', 'private'],
createAddPaymentAddressAction,
createAddRefundAddressAction,
createCreationAction,
createAddPaymentInstructionAction,
createAddRefundInstructionAction,
},
ethereumInputData: {
supportedNetworks: ['rinkeby', 'private'],
createAddPaymentAddressAction,
createAddRefundAddressAction,
createCreationAction,
createAddPaymentInstructionAction,
createAddRefundInstructionAction,
},
},
};

0 comments on commit 332e3ab

Please sign in to comment.