Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix creation of RawEvents #209

Merged
merged 3 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boa/contracts/vyper/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ def __repr__(self):
return f"{self.event_type.name}({args})"


@dataclass
class RawEvent:
event_data: Any
44 changes: 44 additions & 0 deletions tests/integration/fork/test_logs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import pytest

import boa
from boa.contracts.vyper.event import RawEvent
from vyper.utils import keccak256

WETH_ADDRESS = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"

code = f"""

interface IWETH:
def deposit(): payable

weth9: constant(address) = {WETH_ADDRESS}

@external
@payable
def deposit():
IWETH(weth9).deposit(value=msg.value)

"""


@pytest.fixture(scope="module")
def simple_contract():
return boa.loads(code)


def test_logs(simple_contract):
eoa = boa.env.generate_address()
amount = 10**18
boa.env.set_balance(eoa, amount)
simple_contract.deposit(value=amount, sender=eoa)

topic0 = keccak256("Deposit(address,uint256)".encode())
expected_log = (
0,
int(WETH_ADDRESS, 16).to_bytes(20),
(int.from_bytes(topic0), int(simple_contract.address, 16)),
amount.to_bytes(32)
)

logs = simple_contract.get_logs()
assert logs == [RawEvent(expected_log)]
Loading