def __init__(self, event_abi, formatter=None): self.event_abi = event_abi self.formatter = formatter self.event_topic = initialize_event_topics(self.event_abi) self.args = AttributeDict( _build_argument_filters_from_event_abi(event_abi)) self._ordered_arg_names = tuple(arg['name'] for arg in event_abi['inputs'])
def stub_block(timestamp): return AttributeDict({ 'timestamp': timestamp, 'number': 123, })
def test_attributedict_inequality(dict1, dict2): assert AttributeDict(dict1) != dict2 assert AttributeDict(dict1) != AttributeDict(dict2) assert dict1 != AttributeDict(dict2)
('0x0', '0x0'), ('0x1', '0x1'), ('0x0001', '0x0001'), ('0x10', '0x10'), ('0xF', '0xf'), ('F', '0xf'), ), ) def test_to_hex_cleanup_only(val, expected): assert Web3.toHex(hexstr=val) == expected @pytest.mark.parametrize( 'val, expected', ( (AttributeDict({'one': HexBytes('0x1')}), '{"one": "0x01"}'), (AttributeDict({'two': HexBytes(2)}), '{"two": "0x02"}'), (AttributeDict({'three': AttributeDict({'four': 4}) }), '{"three": {"four": 4}}'), ({ 'three': 3 }, '{"three": 3}'), ), ) def test_to_json(val, expected): assert Web3.toJSON(val) == expected @pytest.mark.parametrize( 'tx, expected', (
def test_attributedict_equality(dict1, dict2): assert AttributeDict(dict1) == dict2 assert AttributeDict(dict1) == AttributeDict(dict2) assert dict1 == AttributeDict(dict2)
def test_attributedict_delitem_invalid(): container = AttributeDict({'a': 1}) with pytest.raises(TypeError): del container['a'] assert container['a'] == 1
def test_attributedict_setattr_invalid(): container = AttributeDict({'a': 1}) with pytest.raises(TypeError): container.a = 0 assert container.a == 1
def test_attributedict_repr(): dict1 = AttributeDict({'a': 1}) dict2 = eval(repr(dict1)) assert dict1 == dict2
def test_attributedict_access(): container = AttributeDict({'a': 1}) assert container.a == 1