Skip to content

Commit

Permalink
Add test to ensure condition return false
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix committed Apr 3, 2023
1 parent 89d6ef0 commit c4dfaad
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,24 @@ defmodule Archethic.Contracts.Interpreter.Legacy.ConditionInterpreterTest do
})
end

test "should invalidate condition on uco_transfers size" do
address = <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>

refute Interpreter.sanitize_code(~s"""
condition transaction: [
uco_transfers: size() > 10
]
""")
|> elem(1)
|> ConditionInterpreter.parse()
|> elem(2)
|> ConditionInterpreter.valid_conditions?(%{
"transaction" => %{
"uco_transfers" => %{"#{address}" => 12}
}
})
end

test "should validate oracle condition" do
assert Interpreter.sanitize_code(~s"""
condition oracle: [
Expand Down

0 comments on commit c4dfaad

Please sign in to comment.