Skip to content

Commit

Permalink
add batch proxy addresses and clean tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier7delf committed Oct 20, 2022
1 parent 84431e3 commit 17608de
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ describe('erc20-batch-conversion-proxy', () => {
],
batchConvVersion,
wallet,
true,
),
).rejects.toThrowError(
new UnsupportedCurrencyError({
Expand All @@ -266,14 +265,13 @@ describe('erc20-batch-conversion-proxy', () => {
],
batchConvVersion,
wallet,
true,
),
).rejects.toThrowError('the enrichedRequest has no paymentSettings');
});
it('should throw an error if the request is ETH', async () => {
EURRequest.currencyInfo.type = RequestLogicTypes.CURRENCY.ETH;
await expect(
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet, true),
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet),
).rejects.toThrowError(`wrong request currencyInfo type`);
});
it('should throw an error if the request has a wrong network', async () => {
Expand All @@ -295,7 +293,7 @@ describe('erc20-batch-conversion-proxy', () => {
};

await expect(
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet, true),
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet),
).rejects.toThrowError('All the requests must have the same network');
});
it('should throw an error if the request has a wrong payment network id', async () => {
Expand All @@ -316,21 +314,21 @@ describe('erc20-batch-conversion-proxy', () => {
};

await expect(
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet, true),
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet),
).rejects.toThrowError(
'request cannot be processed, or is not an pn-any-to-erc20-proxy request',
);
});
it("should throw an error if one request's currencyInfo has no value", async () => {
EURRequest.currencyInfo.value = '';
await expect(
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet, true),
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet),
).rejects.toThrowError("The currency '' is unknown or not supported");
});
it('should throw an error if request has no extension', async () => {
EURRequest.extensions = [] as any;
await expect(
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet, true),
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet),
).rejects.toThrowError('no payment network found');
});
it('should throw an error if there is a wrong version mapping', async () => {
Expand All @@ -341,7 +339,7 @@ describe('erc20-batch-conversion-proxy', () => {
},
};
await expect(
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet, true),
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet),
).rejects.toThrowError('Every payment network type and version must be identical');
});
});
Expand Down Expand Up @@ -447,7 +445,6 @@ describe('erc20-batch-conversion-proxy', () => {
}),
batchConvVersion,
wallet,
true,
);
const confirmedTx = await tx.wait(1);
expect(confirmedTx.status).toEqual(1);
Expand Down Expand Up @@ -503,7 +500,6 @@ describe('erc20-batch-conversion-proxy', () => {
],
batchConvVersion,
wallet,
true,
);
const confirmedTx = await tx.wait(1);
expect(confirmedTx.status).toEqual(1);
Expand Down Expand Up @@ -557,14 +553,14 @@ describe('erc20-batch-conversion-proxy', () => {
it('should throw an error if the request is not erc20', async () => {
FAURequest.currencyInfo.type = RequestLogicTypes.CURRENCY.ETH;
await expect(
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet, true),
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet),
).rejects.toThrowError('wrong request currencyInfo type');
});

it("should throw an error if one request's currencyInfo has no value", async () => {
FAURequest.currencyInfo.value = '';
await expect(
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet, true),
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet),
).rejects.toThrowError(
'request cannot be processed, or is not an pn-erc20-fee-proxy-contract request',
);
Expand All @@ -573,7 +569,7 @@ describe('erc20-batch-conversion-proxy', () => {
it("should throw an error if one request's currencyInfo has no network", async () => {
FAURequest.currencyInfo.network = '';
await expect(
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet, true),
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet),
).rejects.toThrowError(
'request cannot be processed, or is not an pn-erc20-fee-proxy-contract request',
);
Expand All @@ -582,7 +578,7 @@ describe('erc20-batch-conversion-proxy', () => {
it('should throw an error if request has no extension', async () => {
FAURequest.extensions = [] as any;
await expect(
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet, true),
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet),
).rejects.toThrowError('no payment network found');
});

Expand All @@ -594,7 +590,7 @@ describe('erc20-batch-conversion-proxy', () => {
},
};
await expect(
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet, true),
payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet),
).rejects.toThrowError('Every payment network type and version must be identical');
});
});
Expand Down Expand Up @@ -650,12 +646,7 @@ describe('erc20-batch-conversion-proxy', () => {
const initialFAUFeeBalance = await getErc20Balance(FAUValidRequest, feeAddress, provider);

// Batch payment
const tx = await payBatchConversionProxyRequest(
enrichedRequests,
batchConvVersion,
wallet,
true,
);
const tx = await payBatchConversionProxyRequest(enrichedRequests, batchConvVersion, wallet);
const confirmedTx = await tx.wait(1);
expect(confirmedTx.status).toBe(1);
expect(tx.hash).not.toBeUndefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export const batchConversionPaymentsArtifact = new ContractArtifact<BatchConvers
address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
creationBlockNumber: 7791166,
},
// mainnet: {
// address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
// creationBlockNumber: 15537996,
// },
mainnet: {
address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
creationBlockNumber: 15789288,
},
matic: {
address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
creationBlockNumber: 34493278,
Expand All @@ -33,28 +33,28 @@ export const batchConversionPaymentsArtifact = new ContractArtifact<BatchConvers
address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
creationBlockNumber: 15686247,
},
// 'arbitrum-one': {
// address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
// creationBlockNumber: 24718550,
// },
// fantom: {
// address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
// creationBlockNumber: 46977185,
// },
// avalanche: {
// address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
// creationBlockNumber: 19892946,
// },
// // Caution: no ETHConversion proxy on xDai
// xdai: {
// address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
// creationBlockNumber: 24192455,
// },
'arbitrum-one': {
address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
creationBlockNumber: 30957509,
},
fantom: {
address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
creationBlockNumber: 49522660,
},
avalanche: {
address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
creationBlockNumber: 21258879,
},
// Caution: no ETHConversion proxy on xDai
xdai: {
address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
creationBlockNumber: 24654730,
},
// // Caution: no ERC20Conversion proxy on fuse
// fuse: {
// address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
// creationBlockNumber: 19146859,
// },
fuse: {
address: '0x0fD49d410fB50Dc1f308975E5D19B5c4551B0041',
creationBlockNumber: 19732873,
},
},
},
},
Expand Down

0 comments on commit 17608de

Please sign in to comment.