Skip to content

Commit

Permalink
Fix TransactionChain.fetch paging state
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix committed Dec 27, 2023
1 parent d701cbd commit 9f95206
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/archethic/transaction_chain.ex
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ defmodule Archethic.TransactionChain do
nil ->
{[], {paging_address, true, false}}

_ ->
%Transaction{address: next_paging_address} ->
{transactions, {next_paging_address, true, false}}
end
end
Expand Down
18 changes: 7 additions & 11 deletions test/archethic/transaction_chain_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -355,19 +355,15 @@ defmodule Archethic.TransactionChainTest do
end)

MockClient
|> stub(:send_message, fn
_, %GetTransactionChain{address: _}, _ ->
{:ok,
%TransactionList{
transactions: [
%Transaction{address: "Alice2"}
]
}}
end)
|> expect(
:send_message,
fn _, %GetTransactionChain{address: _, paging_state: "Alice1"}, _ ->
{:ok, %TransactionList{transactions: [%Transaction{address: "Alice2"}]}}
end
)

assert ["Alice1", "Alice2"] =
TransactionChain.fetch("Alice2", nodes)
|> Enum.map(& &1.address)
TransactionChain.fetch("Alice2", nodes) |> Enum.map(& &1.address)
end

test "should resolve the longest chain" do
Expand Down

0 comments on commit 9f95206

Please sign in to comment.