Skip to content

Commit

Permalink
[GH-757] Fixed importing channels
Browse files Browse the repository at this point in the history
  • Loading branch information
cytadela8 committed Nov 28, 2018
1 parent 299b300 commit 6fac8dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/aecore/lib/aecore/channel/channel_state_peer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,10 @@ defmodule Aecore.Channel.ChannelStatePeer do

Enum.reduce_while(offchain_tx_list_from_oldest, {:ok, initial_state}, fn tx, {:ok, state} ->
case process_fully_signed_tx(tx, state) do
{:ok, _} = new_acc ->
{:cont, new_acc}
{:ok, %ChannelStatePeer{mutually_signed_tx: prev_mutually_signed_tx} = new_state} ->
{:cont,
{:ok,
%ChannelStatePeer{new_state | mutually_signed_tx: [tx | prev_mutually_signed_tx]}}}

{:error, _} = err ->
{:halt, err}
Expand Down
5 changes: 5 additions & 0 deletions apps/aecore/test/aecore_channels_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,10 @@ defmodule AecoreChannelTest do
false

assert :ok == call_s3({:slashed, solo_close_tx, 10, 1, ctx.pk3, ctx.sk3})
[slash] = Map.values(Pool.get_pool())

TestUtils.assert_transactions_mined()
assert :ok == call_s1({:slashed, slash, 10, 1, ctx.pk1, ctx.sk1})

{:ok, s1_state} = call_s1({:get_channel, id})
{:ok, settle_tx} = ChannelStatePeer.settle(s1_state, 10, 2, ctx.sk1)
Expand Down Expand Up @@ -626,6 +628,9 @@ defmodule AecoreChannelTest do

assert ChannelStatePeer.calculate_state_hash(responder_state) ===
ChannelStatePeer.calculate_state_hash(imported_responder_state)

assert tx_list === ChannelStatePeer.get_signed_tx_list(imported_initiator_state)
assert tx_list === ChannelStatePeer.get_signed_tx_list(imported_responder_state)
end

@tag :channels
Expand Down

0 comments on commit 6fac8dc

Please sign in to comment.