Skip to content

Commit

Permalink
fix: shuffling tests not being generated (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaRedHand authored Dec 7, 2023
1 parent 6e6f106 commit b5a1adc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
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

0 comments on commit b5a1adc

Please sign in to comment.