aboutsummaryrefslogtreecommitdiffstats
path: root/python-packages/order_utils/test/test_abi_utils.py
blob: 49a2a4f2055a7643e4ea9789885b74c420eebd52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Tests of 0x.abi_utils."""

import pytest

from zero_ex.dev_utils.abi_utils import (
    elementary_name,
    event_id,
    method_id,
    parse_signature,
    simple_encode,
)


def test_parse_signature_type_error():
    """Test that passing in wrong types raises TypeError."""
    with pytest.raises(TypeError):
        parse_signature(123)


def test_parse_signature_bad_input():
    """Test that passing a non-signature string raises a ValueError."""
    with pytest.raises(ValueError):
        parse_signature("a string that's not even close to a signature")


def test_elementary_name_type_error():
    """Test that passing in wrong types raises TypeError."""
    with pytest.raises(TypeError):
        elementary_name(123)


def test_event_id_type_error():
    """Test that passing in wrong types raises TypeError."""
    with pytest.raises(TypeError):
        event_id(123, [])

    with pytest.raises(TypeError):
        event_id("valid string", 123)


def test_method_id_type_error():
    """Test that passing in wrong types raises TypeError."""
    with pytest.raises(TypeError):
        method_id(123, [])

    with pytest.raises(TypeError):
        method_id("ERC20Token", 123)


def test_simple_encode_type_error():
    """Test that passing in wrong types raises TypeError."""
    with pytest.raises(TypeError):
        simple_encode(123)