|
|
@ -14,17 +14,19 @@ defmodule Explorer.Validator.MetadataImporterTest do |
|
|
|
test "inserts new address names when there's none for the validators" do |
|
|
|
test "inserts new address names when there's none for the validators" do |
|
|
|
address = insert(:address) |
|
|
|
address = insert(:address) |
|
|
|
|
|
|
|
|
|
|
|
[%{address_hash: address.hash, name: "Testinit Unitorius", primary: true, metadata: %{"test" => "toast"}}] |
|
|
|
address_hash = address.hash |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[%{address_hash: address_hash, name: "Testinit Unitorius", primary: true, metadata: %{"test" => "toast"}}] |
|
|
|
|> MetadataImporter.import_metadata() |
|
|
|
|> MetadataImporter.import_metadata() |
|
|
|
|
|
|
|
|
|
|
|
address_names = |
|
|
|
address_names = |
|
|
|
from(an in Address.Name, where: an.address_hash == ^address.hash and an.primary == true) |
|
|
|
from(an in Address.Name, where: an.address_hash == ^address_hash and an.primary == true) |
|
|
|
|> Repo.all() |
|
|
|
|> Repo.all() |
|
|
|
|
|
|
|
|
|
|
|
expected_name = %Address.Name{address_hash: address.hash, name: "Testit Unitorus", metadata: %{"test" => "toast"}} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert length(address_names) == 1 |
|
|
|
assert length(address_names) == 1 |
|
|
|
assert expected_name = hd(address_names) |
|
|
|
|
|
|
|
|
|
|
|
assert %Address.Name{address_hash: ^address_hash, name: "Testinit Unitorius", metadata: %{"test" => "toast"}} = |
|
|
|
|
|
|
|
hd(address_names) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
test "updates the primary address name if the validator already has one" do |
|
|
|
test "updates the primary address name if the validator already has one" do |
|
|
@ -32,17 +34,19 @@ defmodule Explorer.Validator.MetadataImporterTest do |
|
|
|
|
|
|
|
|
|
|
|
insert(:address_name, address: address, primary: true, name: "Nodealus Faileddi") |
|
|
|
insert(:address_name, address: address, primary: true, name: "Nodealus Faileddi") |
|
|
|
|
|
|
|
|
|
|
|
[%{address_hash: address.hash, name: "Testit Unitorus", primary: true, metadata: %{"test" => "toast"}}] |
|
|
|
address_hash = address.hash |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[%{address_hash: address_hash, name: "Testit Unitorus", primary: true, metadata: %{"test" => "toast"}}] |
|
|
|
|> MetadataImporter.import_metadata() |
|
|
|
|> MetadataImporter.import_metadata() |
|
|
|
|
|
|
|
|
|
|
|
address_names = |
|
|
|
address_names = |
|
|
|
from(an in Address.Name, where: an.address_hash == ^address.hash and an.primary == true) |
|
|
|
from(an in Address.Name, where: an.address_hash == ^address.hash and an.primary == true) |
|
|
|
|> Repo.all() |
|
|
|
|> Repo.all() |
|
|
|
|
|
|
|
|
|
|
|
expected_name = %Address.Name{address_hash: address.hash, name: "Testit Unitorus", metadata: %{"test" => "toast"}} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert length(address_names) == 1 |
|
|
|
assert length(address_names) == 1 |
|
|
|
assert expected_name = hd(address_names) |
|
|
|
|
|
|
|
|
|
|
|
assert %Address.Name{address_hash: ^address_hash, name: "Testit Unitorus", metadata: %{"test" => "toast"}} = |
|
|
|
|
|
|
|
hd(address_names) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|