Esempio n. 1
0
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"
Esempio n. 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)
Esempio n. 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)
Esempio n. 4
0
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",
    ]
Esempio n. 5
0
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)
Esempio n. 6
0
def test_not_allow_undecoded(raw_trace):
    with pytest.raises(UnknownEvent):
        decode_traceTransaction(raw_trace, [], allow_undecoded=False)
Esempio n. 7
0
def test_allow_undecoded(raw_trace):
    decode_traceTransaction(raw_trace, [], allow_undecoded=True)
Esempio n. 8
0
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
Esempio n. 9
0
def test_multiple(topic_map, raw_trace):
    events = decode_traceTransaction(raw_trace, topic_map)
    assert len(events) == 2
Esempio n. 10
0
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"]