|
| 1 | +"""Test ETH address.""" |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | + |
| 4 | +# external |
| 5 | +import pytest |
| 6 | + |
| 7 | +# local |
| 8 | +from validators import eth_address, ValidationFailure |
| 9 | + |
| 10 | + |
| 11 | +@pytest.mark.parametrize( |
| 12 | + "value", |
| 13 | + [ |
| 14 | + "0x8ba1f109551bd432803012645ac136ddd64dba72", |
| 15 | + "0x9cc14ba4f9f68ca159ea4ebf2c292a808aaeb598", |
| 16 | + "0x5AEDA56215b167893e80B4fE645BA6d5Bab767DE", |
| 17 | + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", |
| 18 | + "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", |
| 19 | + "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", |
| 20 | + "0x1234567890123456789012345678901234567890", |
| 21 | + "0x57Ab1ec28D129707052df4dF418D58a2D46d5f51", |
| 22 | + ], |
| 23 | +) |
| 24 | +def test_returns_true_on_valid_eth_address(value: str): |
| 25 | + """Test returns true on valid eth address.""" |
| 26 | + assert eth_address(value) |
| 27 | + |
| 28 | + |
| 29 | +@pytest.mark.parametrize( |
| 30 | + "value", |
| 31 | + [ |
| 32 | + "0x742d35Cc6634C0532925a3b844Bc454e4438f44g", |
| 33 | + "0x742d35Cc6634C0532925a3b844Bc454e4438f44", |
| 34 | + "0xAbcdefg1234567890Abcdefg1234567890Abcdefg", |
| 35 | + "0x7c8EE9977c6f96b6b9774b3e8e4Cc9B93B12b2c72", |
| 36 | + "0x80fBD7F8B3f81D0e1d6EACAb69AF104A6508AFB1", |
| 37 | + "0x7c8EE9977c6f96b6b9774b3e8e4Cc9B93B12b2c7g", |
| 38 | + "0x7c8EE9977c6f96b6b9774b3e8e4Cc9B93B12b2c", |
| 39 | + "0x7Fb21a171205f3B8d8E4d88A2d2f8A56E45DdB5c", |
| 40 | + "validators.eth", |
| 41 | + ], |
| 42 | +) |
| 43 | +def test_returns_failed_validation_on_invalid_eth_address(value: str): |
| 44 | + """Test returns failed validation on invalid eth address.""" |
| 45 | + assert isinstance(eth_address(value), ValidationFailure) |
0 commit comments