def test_address(topic_map, raw_trace):
    events = decode_traceTransaction(
        raw_trace,
        topic_map,
        initial_address="0x31a66f30252cb3983cb4bf10dd6cb9bf67e304d9")
    assert events[0]["address"] == "0xd495633B90a237de510B4375c442C0469D3C161C"
    assert events[1]["address"] == "0x31A66F30252cb3983CB4BF10Dd6cb9Bf67e304D9"
Exemple #2
0
def _decode_trace(trace: Sequence) -> Union["EventDict", List[None]]:
    if not trace:
        return []
    events = eth_event.decode_traceTransaction(trace,
                                               _topics,
                                               allow_undecoded=True)
    events = [format_event(i) for i in events]
    return EventDict(events)
Exemple #3
0
def _decode_trace(trace: Sequence, initial_address: str) -> EventDict:
    if not trace:
        return EventDict()

    events = eth_event.decode_traceTransaction(
        trace, _topics, allow_undecoded=True, initial_address=initial_address
    )
    events = [format_event(i) for i in events]
    return EventDict(events)
def test_complex(topic_map, raw_trace):
    events = decode_traceTransaction(raw_trace[400:], topic_map)
    assert len(events) == 1
    assert events[0]["name"] == "BasicTypesEvent"
    assert [i["value"] for i in events[0]["data"]] == [
        23,
        -42,
        "0x31a66f30252cb3983cb4bf10dd6cb9bf67e304d9",
        True,
        "0x0000000000000000000000000000000000000000000000000000000000001234",
    ]
def test_decode_raises(topic_map, raw_trace):
    del raw_trace[371]["memory"]
    with pytest.raises(StructLogError):
        decode_traceTransaction(raw_trace[:400], topic_map)
    raw_trace[371]["stack"] = []
    with pytest.raises(StructLogError):
        decode_traceTransaction(raw_trace[:400], topic_map)
    del raw_trace[371]["stack"]
    with pytest.raises(StructLogError):
        decode_traceTransaction(raw_trace[:400], topic_map)
def test_not_allow_undecoded(raw_trace):
    with pytest.raises(UnknownEvent):
        decode_traceTransaction(raw_trace, [], allow_undecoded=False)
def test_allow_undecoded(raw_trace):
    decode_traceTransaction(raw_trace, [], allow_undecoded=True)
def test_no_address(topic_map, raw_trace):
    events = decode_traceTransaction(raw_trace, topic_map)
    assert events[0]["address"] is None
    assert events[1]["address"] is None
def test_multiple(topic_map, raw_trace):
    events = decode_traceTransaction(raw_trace, topic_map)
    assert len(events) == 2
def test_basic(topic_map, raw_trace):
    events = decode_traceTransaction(raw_trace[:400], topic_map)
    assert len(events) == 1
    assert events[0]["name"] == "ComplexTypesEvent"
    assert [i["value"] for i in events[0]["data"]] == ["hello", "0x6689"]