Skip to content

Commit

Permalink
Add some test with float amount
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix authored and samuelmanzanera committed Apr 21, 2023
1 parent 14d0efd commit a2285a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ defmodule Archethic.Contracts.Interpreter.ActionInterpreterTest do
code = ~s"""
actions triggered_by: transaction do
if transaction.uco_transfers["#{address_hex}"] == 2 do
if List.at(transaction.token_transfers["#{address2_hex}"], 0).amount == 3 do
if List.at(transaction.token_transfers["#{address2_hex}"], 0).amount == 3.12345 do
Contract.set_content "ok"
end
end
Expand All @@ -966,7 +966,7 @@ defmodule Archethic.Contracts.Interpreter.ActionInterpreterTest do
transfers: [
%TokenTransfer{
to: address2,
amount: Archethic.Utils.to_bigint(3),
amount: Archethic.Utils.to_bigint(3.12345),
token_address: token_address,
token_id: 1
}
Expand Down
12 changes: 6 additions & 6 deletions test/archethic/contracts/interpreter/library/contract_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,15 @@ defmodule Archethic.Contracts.Interpreter.Library.ContractTest do
code = ~s"""
actions triggered_by: transaction do
transfers = [
[to: "#{Base.encode16(address)}", amount: 1234],
[to: "#{Base.encode16(address2)}", amount: 5678]
[to: "#{Base.encode16(address)}", amount: 12.34],
[to: "#{Base.encode16(address2)}", amount: 567.8]
]
Contract.add_uco_transfers(transfers)
end
"""

expected_amount1 = Archethic.Utils.to_bigint(1234)
expected_amount2 = Archethic.Utils.to_bigint(5678)
expected_amount1 = Archethic.Utils.to_bigint(12.34)
expected_amount2 = Archethic.Utils.to_bigint(567.8)

assert %Transaction{
data: %TransactionData{
Expand All @@ -433,14 +433,14 @@ defmodule Archethic.Contracts.Interpreter.Library.ContractTest do
code = ~s"""
actions triggered_by: transaction do
transfers = [
[to: "#{Base.encode16(address)}", amount: 14, token_address: "#{Base.encode16(token_address)}"],
[to: "#{Base.encode16(address)}", amount: 14.1864, token_address: "#{Base.encode16(token_address)}"],
[to: "#{Base.encode16(address2)}", amount: 3,token_id: 4, token_address: "#{Base.encode16(token_address)}"]
]
Contract.add_token_transfers(transfers)
end
"""

expected_amount1 = Archethic.Utils.to_bigint(14)
expected_amount1 = Archethic.Utils.to_bigint(14.1864)
expected_amount2 = Archethic.Utils.to_bigint(3)

assert %Transaction{
Expand Down

0 comments on commit a2285a5

Please sign in to comment.