-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
beamer: tests: add a test for L1 invalidation check command
- Loading branch information
Ivan Stanković
committed
Aug 17, 2023
1 parent
9c48035
commit 258fbc4
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |