Skip to content

Commit

Permalink
Fix some unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmanzanera committed Jan 31, 2023
1 parent 74cf7eb commit afb3341
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions test/archethic_web/graphql_schema_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ defmodule ArchethicWeb.GraphQLSchemaTest do

_, %GetGenesisAddress{}, _ ->
{:ok, %NotFound{}}

_, %GetLastTransactionAddress{address: address}, _ ->
{:ok, %LastTransactionAddress{address: address}}
end)

conn =
Expand Down Expand Up @@ -473,8 +476,12 @@ defmodule ArchethicWeb.GraphQLSchemaTest do
addr = <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>

MockClient
|> stub(:send_message, fn _, %GetBalance{}, _ ->
{:ok, %Balance{uco: 218_000_000}}
|> stub(:send_message, fn
_, %GetBalance{}, _ ->
{:ok, %Balance{uco: 218_000_000}}

_, %GetLastTransactionAddress{address: address}, _ ->
{:ok, %LastTransactionAddress{address: address}}
end)

conn =
Expand All @@ -489,15 +496,19 @@ defmodule ArchethicWeb.GraphQLSchemaTest do
addr = <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>

MockClient
|> stub(:send_message, fn _, %GetBalance{}, _ ->
{:ok,
%Balance{
token: %{
{"@Token1", 0} => 200_000_000,
{"@Token2", 0} => 500_000_000,
{"@Token3", 0} => 1_000_000_000
}
}}
|> stub(:send_message, fn
_, %GetBalance{}, _ ->
{:ok,
%Balance{
token: %{
{"@Token1", 0} => 200_000_000,
{"@Token2", 0} => 500_000_000,
{"@Token3", 0} => 1_000_000_000
}
}}

_, %GetLastTransactionAddress{address: address}, _ ->
{:ok, %LastTransactionAddress{address: address}}
end)

conn =
Expand Down Expand Up @@ -549,6 +560,11 @@ defmodule ArchethicWeb.GraphQLSchemaTest do
test "should return same address", %{conn: conn} do
addr = <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>

MockClient
|> stub(:send_message, fn _, %GetGenesisAddress{}, _ ->
{:ok, %GenesisAddress{address: addr}}
end)

conn =
post(conn, "/api", %{
"query" => "query {
Expand Down

0 comments on commit afb3341

Please sign in to comment.