diff --git a/app/core/RPCMethods/wallet_addEthereumChain.test.js b/app/core/RPCMethods/wallet_addEthereumChain.test.js index f84e2ebcd29..ff2bbd5cd61 100644 --- a/app/core/RPCMethods/wallet_addEthereumChain.test.js +++ b/app/core/RPCMethods/wallet_addEthereumChain.test.js @@ -291,6 +291,42 @@ describe('RPC Method - wallet_addEthereumChain', () => { } }); + it('should report native currency symbol length being too long', async () => { + const symbol = 'aaaaaaaaaaaaaaa'; + await expect( + wallet_addEthereumChain({ + req: { + params: [{ + ...correctParams, + nativeCurrency: { symbol, decimals: 18 }, + }], + }, + ...otherOptions, + }), + ).rejects.toThrow( + `Expected 1-6 character string 'nativeCurrency.symbol'. Received:\n${symbol}`, + ); + }); + + it('should allow 1 letter native currency symbols', async () => { + jest.mock('./networkChecker.util'); + jest + .spyOn(Engine.context.NetworkController, 'addNetwork') + .mockResolvedValue({ rpcEndpoints: [] }); + + await wallet_addEthereumChain({ + req: { + params: [ + { + ...correctParams, + nativeCurrency: { symbol: 'a', decimals: 18 }, + }, + ], + }, + ...otherOptions, + }); + }); + describe('Approval Flow', () => { it('should start and end a new approval flow if chain does not already exist', async () => { jest