Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien Chamagne committed Aug 22, 2023
1 parent 74625b0 commit 8a58dae
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
10 changes: 8 additions & 2 deletions test/archethic/contracts/interpreter/action_interpreter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,21 @@ defmodule Archethic.Contracts.Interpreter.ActionInterpreterTest do
|> Interpreter.sanitize_code()
|> elem(1)
# mark as existing
|> ActionInterpreter.parse(FunctionKeys.add_public(%{}, "hello", 0))
|> ActionInterpreter.parse(
FunctionKeys.new()
|> FunctionKeys.add_public("hello", 0)
)

# private function
assert {:ok, _, _} =
code
|> Interpreter.sanitize_code()
|> elem(1)
# mark as existing
|> ActionInterpreter.parse(FunctionKeys.add_private(%{}, "hello", 0))
|> ActionInterpreter.parse(
FunctionKeys.new()
|> FunctionKeys.add_private("hello", 0)
)
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ defmodule Archethic.Contracts.Interpreter.ConditionInterpreterTest do
|> Interpreter.sanitize_code()
|> elem(1)
# mark function as existing
|> ConditionInterpreter.parse(FunctionKeys.add_public(%{}, "get_uco_transfers", 0))
|> ConditionInterpreter.parse(
FunctionKeys.new()
|> FunctionKeys.add_public("get_uco_transfers", 0)
)

assert is_tuple(ast) && :ok == Macro.validate(ast)
end
Expand Down
25 changes: 20 additions & 5 deletions test/archethic/contracts/interpreter/function_interpreter_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ defmodule Archethic.Contracts.Interpreter.FunctionInterpreterTest do
|> Interpreter.sanitize_code()
|> elem(1)
# mark function as declared
|> FunctionInterpreter.parse(FunctionKeys.add_public(%{}, "hello", 0))
|> FunctionInterpreter.parse(
FunctionKeys.new()
|> FunctionKeys.add_public("hello", 0)
)
end

test "should not be able to use IO functions in public function with dynamic access" do
Expand All @@ -135,7 +138,10 @@ defmodule Archethic.Contracts.Interpreter.FunctionInterpreterTest do
|> Interpreter.sanitize_code()
|> elem(1)
# mark function as declared
|> FunctionInterpreter.parse(FunctionKeys.add_public(%{}, "hello", 0))
|> FunctionInterpreter.parse(
FunctionKeys.new()
|> FunctionKeys.add_public("hello", 0)
)
end

test "should return an error if module is unknown" do
Expand Down Expand Up @@ -218,7 +224,10 @@ defmodule Archethic.Contracts.Interpreter.FunctionInterpreterTest do
|> Interpreter.sanitize_code()
|> elem(1)
# mark function as declared
|> FunctionInterpreter.parse(FunctionKeys.add_public(%{}, "hello", 0))
|> FunctionInterpreter.parse(
FunctionKeys.new()
|> FunctionKeys.add_public("hello", 0)
)
end

test "should not be able to call declared private function from private function" do
Expand All @@ -233,7 +242,10 @@ defmodule Archethic.Contracts.Interpreter.FunctionInterpreterTest do
|> Interpreter.sanitize_code()
|> elem(1)
# mark function as declared
|> FunctionInterpreter.parse(FunctionKeys.add_private(%{}, "hello", 0))
|> FunctionInterpreter.parse(
FunctionKeys.new()
|> FunctionKeys.add_private("hello", 0)
)
end

test "should not be able to call declared function from public function" do
Expand Down Expand Up @@ -277,7 +289,10 @@ defmodule Archethic.Contracts.Interpreter.FunctionInterpreterTest do
|> Interpreter.sanitize_code()
|> elem(1)
# pass allowed function
|> FunctionInterpreter.parse(FunctionKeys.add_public(%{}, "hello", 0))
|> FunctionInterpreter.parse(
FunctionKeys.new()
|> FunctionKeys.add_public("hello", 0)
)

function_constant = %{:functions => %{{"hello", 0} => %{args: [], ast: ast_hello}}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Archethic.Contracts.Interpreter.FunctionKeysTest do

test "add_public/3 and add_private/3 should add function in map" do
function_keys =
%{}
FunctionKeys.new()
|> FunctionKeys.add_private("private_function", 0)
|> FunctionKeys.add_public("public_function", 1)
|> FunctionKeys.add_private("private_function", 1)
Expand Down

0 comments on commit 8a58dae

Please sign in to comment.