|
7 | 7 |
|
8 | 8 | from pyethapp.jsonrpc import address_encoder, address_decoder
|
9 | 9 |
|
| 10 | +from raiden.api.v1.encoding import HexAddressConverter |
10 | 11 | from raiden.tests.utils.apitestcontext import decode_response
|
11 | 12 | from raiden.utils import channel_to_api_dict
|
12 | 13 | from raiden.tests.utils.transfer import channel
|
@@ -40,6 +41,25 @@ def api_url_for(api_backend, endpoint, **kwargs):
|
40 | 41 | return url_for('v1_resources.{}'.format(endpoint), **kwargs)
|
41 | 42 |
|
42 | 43 |
|
| 44 | +def test_hex_converter(): |
| 45 | + converter = HexAddressConverter(map=None) |
| 46 | + |
| 47 | + # invalid hex data |
| 48 | + with pytest.raises(Exception): |
| 49 | + converter.to_python('-') |
| 50 | + |
| 51 | + # invalid address, too short |
| 52 | + with pytest.raises(Exception): |
| 53 | + converter.to_python('1234') |
| 54 | + |
| 55 | + # missing prefix 0x |
| 56 | + with pytest.raises(Exception): |
| 57 | + converter.to_python('414d72a6f6e28f4950117696081450d63d56c354') |
| 58 | + |
| 59 | + address = b'AMr\xa6\xf6\xe2\x8fIP\x11v\x96\x08\x14P\xd6=V\xc3T' |
| 60 | + assert converter.to_python('0x414d72a6f6e28f4950117696081450d63d56c354') == address |
| 61 | + |
| 62 | + |
43 | 63 | @pytest.mark.parametrize('blockchain_type', ['geth'])
|
44 | 64 | @pytest.mark.parametrize('number_of_nodes', [2])
|
45 | 65 | def test_channel_to_api_dict(raiden_network, token_addresses, settle_timeout):
|
|
0 commit comments