Skip to content

Commit

Permalink
fix: randomly failing tests (#1718)
Browse files Browse the repository at this point in the history
* fix: randomly failing test

Co-authored-by: Mihail Dobrev <mixaildobrev@gmail.com>

* fix: formatting

---------

Co-authored-by: Mihail Dobrev <mixaildobrev@gmail.com>
  • Loading branch information
vatanasov and yaboiishere committed Mar 29, 2024
1 parent af232e4 commit 41e74c1
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions lib/ae_mdw/aexn_transfers.ex
Expand Up @@ -51,7 +51,7 @@ defmodule AeMdw.AexnTransfers do
def fetch_contract_transfers(state, contract_pk, {nil, account_pk}, pagination, cursor) do
case Origin.tx_index(state, {:contract, contract_pk}) do
{:ok, create_txi} ->
with {:ok, cursors} <- deserialize_account_cursors(state, cursor) do
with {:ok, cursors} <- deserialize_account_cursors(state, cursor, account_pk) do
key_boundary = key_boundary(create_txi, account_pk)

paginated_transfers =
Expand Down Expand Up @@ -229,26 +229,19 @@ defmodule AeMdw.AexnTransfers do
end
end

defp deserialize_account_cursors(_state, nil), do: {:ok, {nil, nil}}
defp deserialize_account_cursors(_state, nil, _account_pk), do: {:ok, {nil, nil}}

defp deserialize_account_cursors(state, cursor_bin) do
defp deserialize_account_cursors(_state, cursor_bin, account_pk) do
with {:ok, cursor} <- deserialize_cursor(cursor_bin) do
{create_txi, call_txi, pk1, pk2, token_id, log_idx} = cursor
cursor = {create_txi, pk1, call_txi, pk2, token_id, log_idx}

if State.exists?(state, Model.AexnContractFromTransfer, cursor) do
{:ok,
{
cursor,
{create_txi, pk2, call_txi, pk1, token_id, log_idx}
}}
else
{:ok,
{
cursor,
cursor
}}
end

cursor =
case account_pk do
^pk1 -> {create_txi, pk1, call_txi, pk2, token_id, log_idx}
^pk2 -> {create_txi, pk2, call_txi, pk1, token_id, log_idx}
end

{:ok, {cursor, cursor}}
end
end

Expand Down

0 comments on commit 41e74c1

Please sign in to comment.