From 67561bc25ab03077ec390fb796a78536bf6ea847 Mon Sep 17 00:00:00 2001 From: Qwerty5Uiop Date: Fri, 2 Sep 2022 19:54:08 +0400 Subject: [PATCH] Fix token transfers tests --- .../instance/transfer_controller_test.exs | 44 +++++++------------ 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/apps/block_scout_web/test/block_scout_web/controllers/tokens/instance/transfer_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/tokens/instance/transfer_controller_test.exs index ee04094cc9..8f4a49cabb 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/tokens/instance/transfer_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/tokens/instance/transfer_controller_test.exs @@ -2,43 +2,29 @@ defmodule BlockScoutWeb.Tokens.Instance.TransferControllerTest do use BlockScoutWeb.ConnCase, async: false describe "GET token-transfers/2" do - test "works for ERC-721 tokens", %{conn: conn} do + test "fetches the instance", %{conn: conn} do contract_address = insert(:address) insert(:token, contract_address: contract_address) - token_id = 10 + contract_address_hash = contract_address.hash - %{log_index: log_index} = - insert(:token_transfer, - from_address: contract_address, - token_contract_address: contract_address, - token_id: token_id - ) + token_id = Decimal.new(10) - conn = get(conn, "/token/#{contract_address.hash}/instance/#{token_id}/token-transfers") + insert(:token_instance, + token_contract_address_hash: contract_address_hash, + token_id: token_id + ) - assert %{assigns: %{token_instance: %{log_index: ^log_index}}} = conn - end - - test "works for ERC-1155 tokens", %{conn: conn} do - contract_address = insert(:address) - - insert(:token, contract_address: contract_address) - - token_id = 10 - - %{log_index: log_index} = - insert(:token_transfer, - from_address: contract_address, - token_contract_address: contract_address, - token_id: nil, - token_ids: [token_id] - ) - - conn = get(conn, "/token/#{contract_address.hash}/instance/#{token_id}/token-transfers") + conn = get(conn, "/token/#{contract_address_hash}/instance/#{token_id}/token-transfers") - assert %{assigns: %{token_instance: %{log_index: ^log_index}}} = conn + assert %{ + assigns: %{ + token_instance: %{ + instance: %{token_contract_address_hash: ^contract_address_hash, token_id: ^token_id} + } + } + } = conn end end end