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: shuffling tests not being generated #502

Merged
merged 1 commit into from
Dec 7, 2023
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
15 changes: 11 additions & 4 deletions lib/mix/tasks/generate_spec_tests.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,30 @@ defmodule Mix.Tasks.GenerateSpecTests do
use Mix.Task
require Logger

@configs ["mainnet", "minimal"]
@forks ["altair", "deneb", "phase0"]
@configs ["mainnet", "minimal", "general"]
@forks ["phase0", "altair", "bellatrix", "capella", "deneb"]

@shortdoc "Generates tests for spec test files"
@impl Mix.Task
def run(_args) do
{:ok, file_names} = File.ls(Path.join(["lib", "spec", "runners"]))
runners = Enum.map(file_names, fn file_name -> Path.basename(file_name, ".ex") end)
runners = Enum.map(file_names, &Path.basename(&1, ".ex"))

# Generate all tests for Capella fork
for config <- @configs, runner <- runners do
generate_test(config, "capella", runner)
end

# Generate tests for all forks in general preset
for fork <- @forks, runner <- runners do
generate_test("general", fork, runner)
end

# Generate shuffling tests for all testcases
for config <- @configs, fork <- @forks do
generate_test(config, fork, "shuffling")
end

File.touch(Path.join(["test", "generated"]))
end

Expand All @@ -45,9 +52,9 @@ defmodule Mix.Tasks.GenerateSpecTests do
end

defp test_module(cases, config, fork, runner) do
r = Macro.camelize(runner)
c = Macro.camelize(config)
f = Macro.camelize(fork)
r = Macro.camelize(runner)

module_name = "Elixir.#{c}.#{f}.#{r}Test" |> String.to_atom()
runner_module = "Elixir.#{r}TestRunner" |> String.to_atom()
Expand Down
9 changes: 5 additions & 4 deletions lib/spec/runners/shuffling.ex
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
defmodule ShufflingTestRunner do
alias LambdaEthereumConsensus.StateTransition.Misc
use ExUnit.CaseTemplate
use TestRunner

@moduledoc """
Runner for Operations test cases. See: https://github.com/ethereum/consensus-specs/tree/dev/tests/formats/shuffling
"""

use ExUnit.CaseTemplate
use TestRunner

alias LambdaEthereumConsensus.StateTransition.Misc

# Remove handler from here once you implement the corresponding functions
@disabled_handlers [
# "core"
Expand Down
Loading