Skip to content

Commit

Permalink
resolves comments on the PR: typos, new test
Browse files Browse the repository at this point in the history
  • Loading branch information
sudeepdino008 committed Feb 27, 2023
1 parent ea9f2f2 commit e935f9b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 20 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ COPY priv ./priv
COPY test ./test
COPY test-data ./test-data
COPY mix.exs .
COPY plugins ./plugins

# test release
RUN mix local.hex --force && \
Expand All @@ -35,7 +34,7 @@ FROM elixir:1.13.4-otp-25 as deployer

RUN apt-get update && apt-get install -y git bash curl netcat-traditional && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN mkdir -p /app/_build /app/config /app/deps /app/lib /app/plugins /app/priv node/test /app/test-data
RUN mkdir -p /app/_build /app/config /app/deps /app/lib /app/priv node/test /app/test-data

# used in case alpine image are used
# RUN apk update && apk add --no-cache git=2.36.3-r0 bash=5.1.16-r2 curl=7.83.1-r4 go=1.18.7-r0 make=4.3-r0 gcc=11.2.1_git20220219-r2
Expand Down
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ config :rudder,
proofchain_chain_id: 31337,
proofchain_node: "http://127.0.0.1:8545/",
ipfs_pinner_url: "http://127.0.0.1:3000",
evm_server_url: "http://127.0.0.1:3000"
evm_server_url: "http://127.0.0.1:3002"
17 changes: 10 additions & 7 deletions lib/rudder/evm/block_processor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@ defmodule Rudder.BlockProcessor do
content_type = Multipart.content_type(multipart, "multipart/form-data")
headers = [{"Content-Type", content_type}, {"Content-Length", to_string(content_length)}]

{:ok, %Finch.Response{body: body, headers: _, status: _}} =
case(
Finch.build("POST", evm_server_url, headers, {:stream, body_stream})
|> Finch.request(Rudder.Finch)
) do
{:ok, %Finch.Response{body: body, headers: _, status: _}} ->
case body |> Poison.decode!() do
%{"error" => error} -> {:reply, {:error, error}, state}
_ -> {:reply, {:ok, body}, state}
end

body_map = body |> Poison.decode!()

case body_map do
%{"error" => error} -> {:reply, {:error, error}, state}
_ -> {:reply, {:ok, body}, state}
{:error, errormsg} ->
{:reply, {:error, errormsg}, state}
end
end

def sync_queue(%Rudder.BlockSpecimen{} = block_specimen) do
Logger.info("submitting #{block_specimen.block_height} to evm plugin...")
Logger.info("submitting #{block_specimen.block_height} to evm http server...")

start_execute_ms = System.monotonic_time(:millisecond)

Expand Down
2 changes: 1 addition & 1 deletion lib/rudder/proof_chain/block_specimen_event_listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ defmodule Rudder.ProofChain.BlockSpecimenEventListener do
end)
end

def push_bsps_to_process(bsp_keys) do
defp push_bsps_to_process(bsp_keys) do
Enum.map(bsp_keys, fn bsp_key ->
Rudder.Journal.discover(bsp_key)
[_chain_id, block_height, _block_hash, specimen_hash] = String.split(bsp_key, "_")
Expand Down
2 changes: 0 additions & 2 deletions plugins/.gitignore

This file was deleted.

15 changes: 8 additions & 7 deletions test/evm/evm_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ defmodule SupervisionTreeTest do
alias TestHelper.EVMInputGenerator
alias TestHelper.SupervisorUtils

# sync_queue success: successful execution from a stateful worker -> status code = 0, workers executed once, response back to the api, WorkerSupervisor is cleared
# sync_queue success (wrong json structure): same as above, except status code != 0, and no retries of the worker (executed once)
# sync_queue failures: failure reason: evm executable not present -- test return value, retries of the worker, check if relevant processes are there, poolsupervisor should be closed

# multiple queueing - pool supervisors should be configured by a worker pool size (maximum # of simultaneous workers), and anything above that should block
# registry for worker name

test "successful scenarios - status code 0 execution" do
block_id = "1234_s_"

Expand All @@ -38,6 +31,14 @@ defmodule SupervisionTreeTest do
})
end

test "query-ing server at wrong port" do
block_id = "1234_f_"

specimen = get_sample_specimen!()
{:ok, bpid} = Rudder.BlockProcessor.start_link(["http://127.0.0.1:3100"])
{:error, errormsg} = GenServer.call(bpid, {:process, "dfjkejkjfd"}, 60000)
end

def get_sample_specimen!() do
path = Path.join([__DIR__, "data", "15548376-segment.json"])

Expand Down

0 comments on commit e935f9b

Please sign in to comment.