-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db881a5
commit 6e6f106
Showing
2 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
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
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,52 @@ | ||
defmodule LightClientTestRunner do | ||
alias LambdaEthereumConsensus.StateTransition.Predicates | ||
use ExUnit.CaseTemplate | ||
use TestRunner | ||
|
||
@moduledoc """ | ||
Runner for LightClient test cases. See: https://github.com/ethereum/consensus-specs/tree/dev/tests/formats/light_client | ||
""" | ||
|
||
# Remove handler from here once you implement the corresponding functions | ||
@disabled_handlers [ | ||
# "single_merkle_proof", | ||
"sync", | ||
"update_ranking" | ||
] | ||
|
||
@impl TestRunner | ||
def skip?(%SpecTestCase{} = testcase) do | ||
Enum.member?(@disabled_handlers, testcase.handler) | ||
end | ||
|
||
@impl TestRunner | ||
def run_test_case(%SpecTestCase{} = testcase) do | ||
handle(testcase.handler, testcase) | ||
end | ||
|
||
defp handle("single_merkle_proof", testcase) do | ||
case_dir = SpecTestCase.dir(testcase) | ||
|
||
object_root = | ||
SpecTestUtils.read_ssz_from_file!( | ||
case_dir <> "/object.ssz_snappy", | ||
String.to_existing_atom("Elixir.SszTypes." <> testcase.suite) | ||
) | ||
|> Ssz.hash_tree_root!() | ||
|
||
%{leaf: leaf, leaf_index: leaf_index, branch: branch} = | ||
YamlElixir.read_from_file!(case_dir <> "/proof.yaml") | ||
|> SpecTestUtils.sanitize_yaml() | ||
|
||
res = | ||
Predicates.is_valid_merkle_branch?( | ||
leaf, | ||
branch, | ||
Constants.deposit_contract_tree_depth() + 1, | ||
leaf_index, | ||
object_root | ||
) | ||
|
||
assert true == res | ||
end | ||
end |