diff --git a/api/api/api.py b/api/api/api.py index 2d61d13..7105574 100644 --- a/api/api/api.py +++ b/api/api/api.py @@ -160,6 +160,9 @@ def ask(): amount_wei = w3.to_wei(amount, 'ether') try: + # convert to checksum address + recipient = w3.to_checksum_address(recipient) + if token_address == 'native': tx_hash = claim_native(w3, app.config['FAUCET_ADDRESS'], recipient, amount_wei) else: diff --git a/api/tests/test_api.py b/api/tests/test_api.py index 63379e5..fa11a7e 100644 --- a/api/tests/test_api.py +++ b/api/tests/test_api.py @@ -5,7 +5,7 @@ import os from conftest import api_prefix # from mock import patch -from temp_env_var import TEMP_ENV_VARS, NATIVE_TRANSFER_TX_HASH, TOKEN_TRANSFER_TX_HASH, ZERO_ADDRESS, CAPTCHA_TEST_RESPONSE_TOKEN, NATIVE_TOKEN_AMOUNT, NATIVE_TOKEN_ADDRESS, ERC20_TOKEN_ADDRESS +from temp_env_var import TEMP_ENV_VARS, NATIVE_TRANSFER_TX_HASH, TOKEN_TRANSFER_TX_HASH, ZERO_ADDRESS, CAPTCHA_TEST_RESPONSE_TOKEN, NATIVE_TOKEN_AMOUNT, NATIVE_TOKEN_ADDRESS, ERC20_TOKEN_AMOUNT, ERC20_TOKEN_ADDRESS class BaseTest: @@ -82,6 +82,15 @@ def test_ask_route_parameters(self, client): }) assert response.status_code == 400 + response = client.post(api_prefix + '/ask', json={ + 'captcha': CAPTCHA_TEST_RESPONSE_TOKEN, + 'chainId': TEMP_ENV_VARS['FAUCET_CHAIN_ID'], + 'amount': ERC20_TOKEN_AMOUNT, + 'recipient': '0x00000123', + 'tokenAddress': ERC20_TOKEN_ADDRESS + }) + assert response.status_code == 400 + # missing token address, should return 400 response = client.post(api_prefix + '/ask', json={ 'captcha': CAPTCHA_TEST_RESPONSE_TOKEN,