diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 000000000..d2cda26ed --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/.gitignore b/.gitignore index b263cd10f..71f58e1c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,30 @@ -/_build -/cover -/deps -/doc +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# Ignore .fetch files in case you like to edit your project deps locally. /.fetch + +# If the VM crashes, it generates a dump, let's ignore it too. erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). *.ez + +# Ignore package tarball (built via "mix hex.build"). +lambda_ethereum_consensus-*.tar + +# Temporary files, for example, from tests. +/tmp/ + *.beam /config/*.secret.exs .elixir_ls/ diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..32f899108 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +.PHONY: iex deps test + +# Run an interactive terminal with the main supervisor setup. +iex: + iex -S mix + +# Install mix dependencies. +deps: + mix deps.get + +# Run tests +test: + mix test diff --git a/README.md b/README.md index 38eee67d3..2a9a572cb 100644 --- a/README.md +++ b/README.md @@ -1 +1,17 @@ -# lambda_ethereum_consensus \ No newline at end of file +# lambda_ethereum_consensus + +## Prerequisites + +- Elixir and mix [installed](https://elixir-lang.org/install.html) (e.g. with asdf, or brew). + +## Installing and running + +There are Makefile targets for these tasks. + +```shell +make deps # Installs dependencies +make iex # Runs a terminal with the application started +make test # Runs tests +``` + +The iex terminal can be closed by pressing ctrl+c two times. diff --git a/lib/lambda_ethereum_consensus.ex b/lib/lambda_ethereum_consensus.ex new file mode 100644 index 000000000..d36e512fe --- /dev/null +++ b/lib/lambda_ethereum_consensus.ex @@ -0,0 +1,18 @@ +defmodule LambdaEthereumConsensus do + @moduledoc """ + Documentation for `LambdaEthereumConsensus`. + """ + + @doc """ + Hello world. + + ## Examples + + iex> LambdaEthereumConsensus.hello() + :world + + """ + def hello do + :world + end +end diff --git a/lib/lambda_ethereum_consensus/application.ex b/lib/lambda_ethereum_consensus/application.ex new file mode 100644 index 000000000..da03b2ae7 --- /dev/null +++ b/lib/lambda_ethereum_consensus/application.ex @@ -0,0 +1,20 @@ +defmodule LambdaEthereumConsensus.Application do + # See https://hexdocs.pm/elixir/Application.html + # for more information on OTP Applications + @moduledoc false + + use Application + + @impl true + def start(_type, _args) do + children = [ + # Starts a worker by calling: LambdaEthereumConsensus.Worker.start_link(arg) + # {LambdaEthereumConsensus.Worker, arg} + ] + + # See https://hexdocs.pm/elixir/Supervisor.html + # for other strategies and supported options + opts = [strategy: :one_for_one, name: LambdaEthereumConsensus.Supervisor] + Supervisor.start_link(children, opts) + end +end diff --git a/mix.exs b/mix.exs new file mode 100644 index 000000000..b9aa7a504 --- /dev/null +++ b/mix.exs @@ -0,0 +1,29 @@ +defmodule LambdaEthereumConsensus.MixProject do + use Mix.Project + + def project do + [ + app: :lambda_ethereum_consensus, + version: "0.1.0", + elixir: "~> 1.14", + start_permanent: Mix.env() == :prod, + deps: deps() + ] + end + + # Run "mix help compile.app" to learn about applications. + def application do + [ + extra_applications: [:logger], + mod: {LambdaEthereumConsensus.Application, []} + ] + end + + # Run "mix help deps" to learn about dependencies. + defp deps do + [ + # {:dep_from_hexpm, "~> 0.3.0"}, + # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} + ] + end +end diff --git a/test/lambda_ethereum_consensus_test.exs b/test/lambda_ethereum_consensus_test.exs new file mode 100644 index 000000000..9c2661c74 --- /dev/null +++ b/test/lambda_ethereum_consensus_test.exs @@ -0,0 +1,8 @@ +defmodule LambdaEthereumConsensusTest do + use ExUnit.Case + doctest LambdaEthereumConsensus + + test "greets the world" do + assert LambdaEthereumConsensus.hello() == :world + end +end diff --git a/test/test_helper.exs b/test/test_helper.exs new file mode 100644 index 000000000..869559e70 --- /dev/null +++ b/test/test_helper.exs @@ -0,0 +1 @@ +ExUnit.start()