From 6fac8dcc81ce1c04290f24aac0909f179ce1e321 Mon Sep 17 00:00:00 2001 From: Artur Puzio Date: Wed, 28 Nov 2018 16:54:23 +0000 Subject: [PATCH] [GH-757] Fixed importing channels --- apps/aecore/lib/aecore/channel/channel_state_peer.ex | 6 ++++-- apps/aecore/test/aecore_channels_test.exs | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/aecore/lib/aecore/channel/channel_state_peer.ex b/apps/aecore/lib/aecore/channel/channel_state_peer.ex index decfd228..efe00812 100644 --- a/apps/aecore/lib/aecore/channel/channel_state_peer.ex +++ b/apps/aecore/lib/aecore/channel/channel_state_peer.ex @@ -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} diff --git a/apps/aecore/test/aecore_channels_test.exs b/apps/aecore/test/aecore_channels_test.exs index a28c631b..9abc8f0a 100644 --- a/apps/aecore/test/aecore_channels_test.exs +++ b/apps/aecore/test/aecore_channels_test.exs @@ -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) @@ -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