Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
alexandre-abrioux committed Feb 20, 2024
commit c6b8cee26d9cadb1e51ab74ddc051636d4d57fc9
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('extensions/payment-network/ethereum/any-to-eth-fee-proxy-contract', ()
requestCreatedNoExtension.currency = {
type: RequestLogicTypes.CURRENCY.ETH,
value: 'invalid value',
network: 'invalid network' as ChainTypes.IEvmChain,
network: 'invalid network',
};

const action: ExtensionTypes.IAction = deepCopy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '../../utils/payment-network/mocked_native_data';
import { AdvancedLogic } from '../../../src';
import { arbitraryTimestamp, payeeRaw } from '../../utils/test-data-generator';
import { CurrencyTypes, ExtensionTypes, RequestLogicTypes } from '@requestnetwork/types';
import { ExtensionTypes, RequestLogicTypes } from '@requestnetwork/types';
import { CurrencyManager } from '@requestnetwork/currency';
import NearTestnetNativeNativePaymentNetwork from '../../../src/extensions/payment-network/near/near-testnet-native';

Expand Down Expand Up @@ -154,7 +154,7 @@ describe('extensions/payment-network/native-token', () => {
expect(() => {
new NearNativePaymentNetwork(currencyManager).createCreationAction({
...partialCreationParams,
paymentNetworkName: 'another-chain' as ChainTypes.INearChain,
paymentNetworkName: 'another-chain',
});
}).toThrowError(
`Payment network 'another-chain' is not supported by this extension (only aurora)`,
Expand Down Expand Up @@ -331,7 +331,7 @@ describe('extensions/payment-network/native-token', () => {
});
it('throws on a wrong payment network', () => {
const advancedLogic = new AdvancedLogic(currencyManager);
const wrongNetwork = `wrong network` as ChainTypes.IEvmChain;
const wrongNetwork = `wrong network`;

const wrongNativeTokenRequestState: typeof requestStateNoExtensions = {
...requestStateNoExtensions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ describe('api/erc20/transferable-receivable-contract', () => {
txHash: '0x3e2d6cc2534b1d340ba2954f34e6cc819d6da64ff76863ea89c6d34b15d13c97',
from: '0x186e7fe6c34ea0eca7f9c2fd29651fc0443e3f29',
to: paymentAddress,
network: 'rinkeby' as ChainTypes.IEvmChain,
network: 'rinkeby',
salt: '0ee84db293a752c6',
amount: '30000000000000',
requestId: '0188791633ff0ec72a7dbdefb886d2db6cccfa98287320839c2f173c7a4e3ce7e1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const mockAdvancedLogic: AdvancedLogicTypes.IAdvancedLogic = {
const baseRequestData = {
creator: { type: IdentityTypes.TYPE.ETHEREUM_ADDRESS, value: '0x2' },
currency: {
network: 'private' as ChainTypes.IEvmChain,
network: 'private',
type: RequestLogicTypes.CURRENCY.ERC20,
value: '0x9FBDa871d559710256a2502A2517b794B482Db40', // local ERC20 token
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ beforeAll(async () => {
await revokeErc20Approval(proxyERC20Conv, alphaContractAddress, wallet);

proxyERC20Swap = erc20SwapToPayArtifact.getAddress(
validRequestERC20FeeProxy.currencyInfo.network! as ChainTypes.IEvmChain,
validRequestERC20FeeProxy.currencyInfo.network!,
);
await revokeErc20Approval(proxyERC20Swap, alphaContractAddress, wallet);

proxyERC20SwapConv = erc20SwapConversionArtifact.getAddress(
validRequestERC20FeeProxy.currencyInfo.network! as ChainTypes.IEvmChain,
validRequestERC20FeeProxy.currencyInfo.network!,
);
await revokeErc20Approval(proxyERC20SwapConv, alphaContractAddress, wallet);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ describe('Payment encoder handles ERC20 Swap Proxy', () => {
});

const proxyAddress = erc20SwapToPayArtifact.getAddress(
validRequestERC20FeeProxy.currencyInfo.network! as ChainTypes.IEvmChain,
validRequestERC20FeeProxy.currencyInfo.network!,
);

expect(paymentTransaction).toEqual({
Expand All @@ -335,7 +335,7 @@ describe('Payment encoder handles ERC20 Swap & Conversion Proxy', () => {
});

const proxyAddress = erc20SwapConversionArtifact.getAddress(
alphaConversionSettings.currency.network as ChainTypes.IEvmChain,
alphaConversionSettings.currency.network,
);

expect(paymentTransaction).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ const validRequest: ClientTypes.IRequestData = {
version: '1.0',
};

const escrowAddress = erc20EscrowToPayArtifact.getAddress(
validRequest.currencyInfo.network! as ChainTypes.IEvmChain,
);
const escrowAddress = erc20EscrowToPayArtifact.getAddress(validRequest.currencyInfo.network!);
const payerAddress = wallet.address;

describe('erc20-escrow-payment tests:', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('payErc20ProxyRequest', () => {

it('should throw an error if currencyInfo has no network', async () => {
const request = deepCopy(validRequest);
request.currencyInfo.network = '' as ChainTypes.IEvmChain;
request.currencyInfo.network = '';
await expect(payErc20ProxyRequest(request, wallet)).rejects.toThrowError(
'request cannot be processed, or is not an pn-erc20-proxy-contract request',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('erc777-stream', () => {

it('should throw an error if currencyInfo has no network', async () => {
const request = deepCopy(validRequest);
request.currencyInfo.network = '' as ChainTypes.IEvmChain;
request.currencyInfo.network = '';
await expect(payErc777StreamRequest(request, wallet)).rejects.toThrowError(
'request cannot be processed, or is not an pn-erc777-stream request',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('payBatchProxyRequest', () => {

it('should throw an error if in one request, currencyInfo has no network', async () => {
const request = deepCopy(validRequest);
request.currencyInfo.network = '' as ChainTypes.IEvmChain;
request.currencyInfo.network = '';
await expect(
payBatchProxyRequest([validRequest, request], batchVersion, wallet, batchFee),
).rejects.toThrowError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('payEthFeeProxyRequest', () => {

it('should throw an error if currencyInfo has no network', async () => {
const request = deepCopy(validRequest);
request.currencyInfo.network = '' as ChainTypes.IEvmChain;
request.currencyInfo.network = '';
await expect(payEthFeeProxyRequest(request, wallet)).rejects.toThrowError(
'request cannot be processed, or is not an pn-eth-fee-proxy-contract request',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('payEthInputDataRequest', () => {

it('should throw an error if currencyInfo has no network', async () => {
const request = deepCopy(validRequest);
request.currencyInfo.network = '' as ChainTypes.IEvmChain;
request.currencyInfo.network = '';
await expect(payEthInputDataRequest(request, wallet)).rejects.toThrowError(
'request cannot be processed, or is not an pn-eth-input-data request',
);
Expand Down
2 changes: 1 addition & 1 deletion packages/payment-processor/test/payment/eth-proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe('payEthProxyRequest', () => {

it('should throw an error if currencyInfo has no network', async () => {
const request = deepCopy(validRequest);
request.currencyInfo.network = '' as ChainTypes.IEvmChain;
request.currencyInfo.network = '';
await expect(payEthProxyRequest(request, wallet)).rejects.toThrowError(
'request cannot be processed, or is not an pn-eth-input-data request',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('swap-erc20-fee-proxy', () => {
beforeAll(async () => {
// revoke erc20SwapToPay approval
await revokeErc20Approval(
erc20SwapToPayArtifact.getAddress(validRequest.currencyInfo.network! as ChainTypes.IEvmChain),
erc20SwapToPayArtifact.getAddress(validRequest.currencyInfo.network!),
alphaErc20Address,
wallet.provider,
);
Expand All @@ -94,9 +94,7 @@ describe('swap-erc20-fee-proxy', () => {
beforeAll(async () => {
// revoke erc20SwapToPay approval
await revokeErc20Approval(
erc20SwapToPayArtifact.getAddress(
validRequest.currencyInfo.network! as ChainTypes.IEvmChain,
),
erc20SwapToPayArtifact.getAddress(validRequest.currencyInfo.network!),
alphaErc20Address,
wallet.provider,
);
Expand Down Expand Up @@ -124,7 +122,7 @@ describe('swap-erc20-fee-proxy', () => {

it('should throw an error if currencyInfo has no network', async () => {
const request = deepCopy(validRequest);
request.currencyInfo.network = '' as ChainTypes.IEvmChain;
request.currencyInfo.network = '';
await expect(
swapErc20FeeProxyRequest(request, wallet, validSwapSettings),
).rejects.toThrowError('Unsupported chain ');
Expand Down
6 changes: 3 additions & 3 deletions packages/smart-contracts/test/lib/artifact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ describe('Artifact', () => {
});

it('throws for a non-existing network', () => {
expect(() =>
erc20ProxyArtifact.getDeploymentInformation('fakenetwork' as ChainTypes.IEvmChain),
).toThrowError(`No deployment for network: fakenetwork`);
expect(() => erc20ProxyArtifact.getDeploymentInformation('fakenetwork')).toThrowError(
`No deployment for network: fakenetwork`,
);
});

it('throws for a non-existing version', () => {
Expand Down