Skip to content

Commit

Permalink
beamer: tests: add a test for L1 invalidation check command
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Stanković committed Aug 17, 2023
1 parent 9c48035 commit 258fbc4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Empty file added beamer/tests/check/__init__.py
Empty file.
54 changes: 54 additions & 0 deletions beamer/tests/check/test_invalidations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import json
from pathlib import Path

import ape
import apischema

import beamer.check.commands
from beamer.check.commands import Invalidation

from beamer.tests.util import deploy, get_repo_root, run_command, write_keystore_file


def test_initiate_l1_invalidations(tmp_path, deployer):
password = "test"
keystore_file = tmp_path / f"{deployer.address}.json"
write_keystore_file(keystore_file, deployer.private_key, password)

rpc_file, artifact = deploy(deployer, tmp_path)

root = get_repo_root()
output = tmp_path / "invalidations.json"
chain_id = ape.chain.chain_id
run_command(
beamer.check.commands.initiate_l1_invalidations,
"--keystore-file",
keystore_file,
"--password",
password,
"--rpc-file",
rpc_file,
"--abi-dir",
f"{root}/contracts/.build/",
"--artifacts-dir",
Path(artifact).parent,
"--output",
output,
str(chain_id),
str(chain_id),
)
with output.open("rt") as f:
data = json.load(f)

invalidation = apischema.deserialize(Invalidation, data[0])

assert invalidation.proof_source == chain_id
assert invalidation.proof_target == chain_id

w3 = ape.chain.provider.web3
receipt = w3.eth.get_transaction_receipt(invalidation.txhash)
fill_manager = ape.project.FillManager.at(receipt.to)
event = fill_manager.FillInvalidated.from_receipt(receipt)[0]
assert event.event_arguments == dict(
requestId=invalidation.request_id, fillId=invalidation.fill_id
)

0 comments on commit 258fbc4

Please sign in to comment.