|
|
@ -24,6 +24,12 @@ defmodule BlockScoutWeb.SmartContractViewTest do |
|
|
|
assert SmartContractView.address?(type) |
|
|
|
assert SmartContractView.address?(type) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "returns true when the type is equal to the string 'address payable'" do |
|
|
|
|
|
|
|
type = "address payable" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert SmartContractView.address?(type) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "returns false when the type is not equal the string 'address'" do |
|
|
|
test "returns false when the type is not equal the string 'address'" do |
|
|
|
type = "name" |
|
|
|
type = "name" |
|
|
|
|
|
|
|
|
|
|
@ -57,17 +63,27 @@ defmodule BlockScoutWeb.SmartContractViewTest do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "values/1" do |
|
|
|
describe "values/2" do |
|
|
|
test "joins the values when it is a list" do |
|
|
|
test "joins the values when it is a list of a given type" do |
|
|
|
values = [8, 6, 9, 2, 2, 37] |
|
|
|
values = [8, 6, 9, 2, 2, 37] |
|
|
|
|
|
|
|
|
|
|
|
assert SmartContractView.values(values) == "8,6,9,2,2,37" |
|
|
|
assert SmartContractView.values(values, "type") == "8,6,9,2,2,37" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "convert the value to string receiving a value and the 'address' type" do |
|
|
|
|
|
|
|
value = <<95, 38, 9, 115, 52, 182, 163, 43, 121, 81, 223, 97, 253, 12, 88, 3, 236, 93, 131, 84>> |
|
|
|
|
|
|
|
assert SmartContractView.values(value, "address") == "0x5f26097334b6a32b7951df61fd0c5803ec5d8354" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test "convert the value to string receiving a value and the 'address payable' type" do |
|
|
|
|
|
|
|
value = <<95, 38, 9, 115, 52, 182, 163, 43, 121, 81, 223, 97, 253, 12, 88, 3, 236, 93, 131, 84>> |
|
|
|
|
|
|
|
assert SmartContractView.values(value, "address payable") == "0x5f26097334b6a32b7951df61fd0c5803ec5d8354" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "returns the value" do |
|
|
|
test "returns the value when the type is neither 'address' nor 'address payable'" do |
|
|
|
value = "POA" |
|
|
|
value = "POA" |
|
|
|
|
|
|
|
|
|
|
|
assert SmartContractView.values(value) == "POA" |
|
|
|
assert SmartContractView.values(value, "not address") == "POA" |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|