diff --git a/lib/archethic/mining/validation_context.ex b/lib/archethic/mining/validation_context.ex index 150d80204e..8a6d25eca1 100644 --- a/lib/archethic/mining/validation_context.ex +++ b/lib/archethic/mining/validation_context.ex @@ -112,20 +112,20 @@ defmodule Archethic.Mining.ValidationContext do iex> ValidationContext.new( ...> transaction: %Transaction{}, - ...> welcome_node: %Node{last_public_key: "key1", availability_history: <<1::1>>}, - ...> coordinator_node: %Node{last_public_key: "key2", availability_history: <<1::1>>}, - ...> cross_validation_nodes: [%Node{last_public_key: "key3", availability_history: <<1::1>>}], - ...> chain_storage_nodes: [%Node{last_public_key: "key4", availability_history: <<1::1>>}, %Node{last_public_key: "key5", availability_history: <<1::1>>}], - ...> beacon_storage_nodes: [%Node{last_public_key: "key6", availability_history: <<1::1>>}, %Node{last_public_key: "key7", availability_history: <<1::1>>}] + ...> welcome_node: %Node{last_public_key: "key1"}, + ...> coordinator_node: %Node{last_public_key: "key2"}, + ...> cross_validation_nodes: [%Node{last_public_key: "key3"}], + ...> chain_storage_nodes: [%Node{last_public_key: "key4"}, %Node{last_public_key: "key5"}], + ...> beacon_storage_nodes: [%Node{last_public_key: "key6"}, %Node{last_public_key: "key7"}] ...> ) %ValidationContext{ transaction: %Transaction{}, - welcome_node: %Node{last_public_key: "key1", availability_history: <<1::1>>}, - coordinator_node: %Node{last_public_key: "key2", availability_history: <<1::1>>}, - cross_validation_nodes: [%Node{last_public_key: "key3", availability_history: <<1::1>>}], + welcome_node: %Node{last_public_key: "key1"}, + coordinator_node: %Node{last_public_key: "key2"}, + cross_validation_nodes: [%Node{last_public_key: "key3"}], cross_validation_nodes_confirmation: <<0::1>>, - chain_storage_nodes: [%Node{last_public_key: "key4", availability_history: <<1::1>>}, %Node{last_public_key: "key5", availability_history: <<1::1>>}], - beacon_storage_nodes: [%Node{last_public_key: "key6", availability_history: <<1::1>>}, %Node{last_public_key: "key7", availability_history: <<1::1>>}] + chain_storage_nodes: [%Node{last_public_key: "key4"}, %Node{last_public_key: "key5"}], + beacon_storage_nodes: [%Node{last_public_key: "key6"}, %Node{last_public_key: "key7"}] } """ @spec new(opts :: Keyword.t()) :: t() diff --git a/lib/archethic/p2p/client/connection.ex b/lib/archethic/p2p/client/connection.ex index a42d758731..ee5f515ff4 100644 --- a/lib/archethic/p2p/client/connection.ex +++ b/lib/archethic/p2p/client/connection.ex @@ -14,7 +14,6 @@ defmodule Archethic.P2P.Client.Connection do alias Archethic.P2P.Client.ConnectionRegistry alias Archethic.P2P.Client.ConnectionSupervisor - alias Archethic.P2P.MemTable alias Archethic.P2P.Message alias Archethic.P2P.MessageEnvelop @@ -150,7 +149,6 @@ defmodule Archethic.P2P.Client.Connection do ) do Logger.warning("Connection closed", node: Base.encode16(node_public_key)) - MemTable.decrease_node_availability(node_public_key) ConnectionSupervisor.set_node_disconnected(node_public_key) # Stop availability timer @@ -185,7 +183,6 @@ defmodule Archethic.P2P.Client.Connection do {:connected, _socket}, data = %{node_public_key: node_public_key} ) do - MemTable.increase_node_availability(node_public_key) ConnectionSupervisor.set_node_connected(node_public_key) # Start availability timer @@ -347,7 +344,6 @@ defmodule Archethic.P2P.Client.Connection do message_id: msg_id ) - MemTable.decrease_node_availability(node_public_key) ConnectionSupervisor.set_node_disconnected(node_public_key) # Stop availability timer @@ -455,7 +451,6 @@ defmodule Archethic.P2P.Client.Connection do {:next_state, :disconnected, data} {:ok, msg} -> - MemTable.increase_node_availability(node_public_key) ConnectionSupervisor.set_node_connected(node_public_key) # Start availability timer diff --git a/lib/archethic/p2p/mem_table.ex b/lib/archethic/p2p/mem_table.ex index 89a21ca6d4..2224f7c893 100644 --- a/lib/archethic/p2p/mem_table.ex +++ b/lib/archethic/p2p/mem_table.ex @@ -25,16 +25,15 @@ defmodule Archethic.P2P.MemTable do geo_patch: 6, network_patch: 7, average_availability: 8, - availability_history: 9, - enrollment_date: 10, - transport: 11, - reward_address: 12, - last_address: 13, - origin_public_key: 14, - synced?: 15, - last_update_date: 16, - available?: 17, - availability_update: 18 + enrollment_date: 9, + transport: 10, + reward_address: 11, + last_address: 12, + origin_public_key: 13, + synced?: 14, + last_update_date: 15, + available?: 16, + availability_update: 17 ] @doc """ @@ -55,6 +54,21 @@ defmodule Archethic.P2P.MemTable do {:ok, []} end + def code_change("1.1.1", state, _extra) do + # This match_spec remove the key :"$9" which is the availability_history + match_spec = [ + {{:"$1", :"$2", :"$3", :"$4", :"$5", :"$6", :"$7", :"$8", :"$9", :"$10", :"$11", :"$12", + :"$13", :"$14", :"$15", :"$16", :"$17", :"$18"}, [], + [ + {{:"$1", :"$2", :"$3", :"$4", :"$5", :"$6", :"$7", :"$8", :"$10", :"$11", :"$12", :"$13", + :"$14", :"$15", :"$16", :"$17", :"$18"}} + ]} + ] + + :ets.select_replace(@discovery_table, match_spec) + {:ok, state} + end + @doc """ Add a node into the P2P view. @@ -71,7 +85,6 @@ defmodule Archethic.P2P.MemTable do ...> last_public_key: "key2", ...> geo_patch: "AFZ", ...> network_patch: "AAA", - ...> availability_history: <<1::1, 1::1>>, ...> average_availability: 0.9, ...> available?: true, ...> synced?: true, @@ -97,7 +110,7 @@ defmodule Archethic.P2P.MemTable do { # Discovery table [{ - "key1", "key2", {127, 0, 0, 1}, 3000, 4000, "AFZ", "AAA", 0.9, <<1::1, 1::1>>, ~U[2020-10-22 23:19:45.797109Z], :tcp, + "key1", "key2", {127, 0, 0, 1}, 3000, 4000, "AFZ", "AAA", 0.9, ~U[2020-10-22 23:19:45.797109Z], :tcp, <<0, 163, 237, 233, 93, 14, 241, 241, 8, 144, 218, 105, 16, 138, 243, 223, 17, 182, 87, 9, 7, 53, 146, 174, 125, 5, 244, 42, 35, 209, 142, 24, 164>>, <<0, 165, 32, 187, 102, 112, 133, 38, 17, 232, 54, 228, 173, 254, 94, 179, 32, 173, @@ -123,7 +136,6 @@ defmodule Archethic.P2P.MemTable do ...> last_public_key: "key2", ...> geo_patch: "AFZ", ...> network_patch: "AAA", - ...> availability_history: <<1::1, 1::1>>, ...> average_availability: 0.9, ...> available?: true, ...> synced?: true, @@ -148,7 +160,6 @@ defmodule Archethic.P2P.MemTable do ...> first_public_key: "key1", ...> last_public_key: "key5", ...> average_availability: 90, - ...> availability_history: <<1::1, 1::1>>, ...> last_update_date: ~U[2020-10-22 23:20:45.797109Z], ...> synced?: false, ...> availability_update: ~U[2020-10-23 23:20:45.797109Z], @@ -171,7 +182,6 @@ defmodule Archethic.P2P.MemTable do "AFZ", "AAA", 90, - <<1::1, 1::1>>, ~U[2020-10-22 23:19:45.797109Z], :sctp, <<0, 163, 237, 233, 93, 14, 241, 241, 8, 144, 218, 105, 16, 138, 243, 223, 17, 182, 87, 9, 7, 53, 146, 174, 125, 5, 244, 42, 35, 209, 142, 24, 164>>, @@ -230,7 +240,6 @@ defmodule Archethic.P2P.MemTable do enrollment_date: enrollment_date, synced?: synced?, average_availability: average_availability, - availability_history: availability_history, transport: transport, reward_address: reward_address, last_address: last_address, @@ -239,17 +248,11 @@ defmodule Archethic.P2P.MemTable do available?: available?, availability_update: availability_update }) do - availability_history = - if first_public_key == Crypto.first_node_public_key(), - do: <<1::1>>, - else: availability_history - :ets.insert( @discovery_table, {first_public_key, last_public_key, ip, port, http_port, geo_patch, network_patch, - average_availability, availability_history, enrollment_date, transport, reward_address, - last_address, origin_public_key, synced?, last_update_date, available?, - availability_update} + average_availability, enrollment_date, transport, reward_address, last_address, + origin_public_key, synced?, last_update_date, available?, availability_update} ) end @@ -836,86 +839,6 @@ defmodule Archethic.P2P.MemTable do :ok end - @doc """ - Set the node as available if previously flagged as offline - - ## Examples - - iex> MemTable.start_link() - iex> node = %Node{ - ...> ip: {127, 0, 0, 1}, - ...> port: 3000, - ...> http_port: 4000, - ...> first_public_key: "key1", - ...> last_public_key: "key2", - ...> availability_history: <<0::1>> - ...> } - iex> MemTable.add_node(node) - iex> :ok = MemTable.increase_node_availability("key1") - iex> {:ok, %Node{availability_history: <<1::1, 0::1>>}} = MemTable.get_node("key1") - """ - @spec increase_node_availability(first_public_key :: Crypto.key()) :: :ok - def increase_node_availability(first_public_key) when is_binary(first_public_key) do - if :ets.member(@discovery_table, first_public_key) do - tuple_pos = Keyword.fetch!(@discovery_index_position, :availability_history) - - case :ets.lookup_element(@discovery_table, first_public_key, tuple_pos) do - <<1::1, _::bitstring>> -> - :ok - - <<0::1, _::bitstring>> = history -> - new_history = <<1::1, history::bitstring>> - true = :ets.update_element(@discovery_table, first_public_key, {tuple_pos, new_history}) - Logger.info("P2P availability increase", node: Base.encode16(first_public_key)) - notify_node_update(first_public_key) - :ok - end - else - :ok - end - end - - @doc """ - Set the node as unavailable if previously flagged as online - - ## Examples - - iex> MemTable.start_link() - iex> node = %Node{ - ...> ip: {127, 0, 0, 1}, - ...> port: 3000, - ...> http_port: 4000, - ...> first_public_key: "key1", - ...> last_public_key: "key2", - ...> availability_history: <<1::1>> - ...> } - iex> MemTable.add_node(node) - iex> :ok = MemTable.decrease_node_availability("key1") - iex> {:ok, %Node{availability_history: <<0::1, 1::1>>}} = MemTable.get_node("key1") - """ - @spec decrease_node_availability(first_public_key :: Crypto.key()) :: :ok - def decrease_node_availability(first_public_key) when is_binary(first_public_key) do - if :ets.member(@discovery_table, first_public_key) do - tuple_pos = Keyword.fetch!(@discovery_index_position, :availability_history) - - case :ets.lookup_element(@discovery_table, first_public_key, tuple_pos) do - <<0::1, _::bitstring>> -> - :ok - - <<1::1, _::bitstring>> = history -> - new_history = <<0::1, history::bitstring>> - - true = :ets.update_element(@discovery_table, first_public_key, {tuple_pos, new_history}) - - Logger.info("P2P availability decrease", node: Base.encode16(first_public_key)) - notify_node_update(first_public_key) - :ok - end - else - :ok - end - end - @doc """ Update the average availability of the node and reset the history @@ -941,15 +864,10 @@ defmodule Archethic.P2P.MemTable do def update_node_average_availability(first_public_key, avg_availability) when is_binary(first_public_key) and is_float(avg_availability) do avg_availability_pos = Keyword.fetch!(@discovery_index_position, :average_availability) - availability_history_pos = Keyword.fetch!(@discovery_index_position, :availability_history) - - <> = - :ets.lookup_element(@discovery_table, first_public_key, availability_history_pos) true = :ets.update_element(@discovery_table, first_public_key, [ - {avg_availability_pos, avg_availability}, - {availability_history_pos, <>} + {avg_availability_pos, avg_availability} ]) Logger.info("New average availability: #{avg_availability}}", diff --git a/lib/archethic/p2p/node.ex b/lib/archethic/p2p/node.ex index 56df1e2c0a..3c844ce2fa 100755 --- a/lib/archethic/p2p/node.ex +++ b/lib/archethic/p2p/node.ex @@ -31,7 +31,6 @@ defmodule Archethic.P2P.Node do available?: false, synced?: false, average_availability: 1.0, - availability_history: <<0::1>>, authorized?: false, authorization_date: nil, transport: :tcp, @@ -178,7 +177,6 @@ defmodule Archethic.P2P.Node do available?: boolean(), synced?: boolean(), average_availability: float(), - availability_history: bitstring(), authorized?: boolean(), enrollment_date: nil | DateTime.t(), authorization_date: nil | DateTime.t(), @@ -193,9 +191,8 @@ defmodule Archethic.P2P.Node do @spec cast(tuple()) :: __MODULE__.t() def cast( {first_public_key, last_public_key, ip, port, http_port, geo_patch, network_patch, - average_availability, availability_history, enrollment_date, transport, reward_address, - last_address, origin_public_key, synced?, last_update_date, available?, - availability_update} + average_availability, enrollment_date, transport, reward_address, last_address, + origin_public_key, synced?, last_update_date, available?, availability_update} ) do %__MODULE__{ ip: ip, @@ -206,7 +203,6 @@ defmodule Archethic.P2P.Node do geo_patch: geo_patch, network_patch: network_patch, average_availability: average_availability, - availability_history: availability_history, enrollment_date: enrollment_date, synced?: synced?, transport: transport, diff --git a/test/archethic/beacon_chain_test.exs b/test/archethic/beacon_chain_test.exs index ae55b5afe4..f4e2574c7c 100644 --- a/test/archethic/beacon_chain_test.exs +++ b/test/archethic/beacon_chain_test.exs @@ -121,8 +121,7 @@ defmodule Archethic.BeaconChainTest do available?: true, authorization_date: summary_time |> DateTime.add(-10), authorized?: true, - reward_address: <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>, - availability_history: <<1::1>> + reward_address: <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>> } node2 = %Node{ @@ -135,8 +134,7 @@ defmodule Archethic.BeaconChainTest do available?: true, authorization_date: summary_time |> DateTime.add(-10), authorized?: true, - reward_address: <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>, - availability_history: <<1::1>> + reward_address: <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>> } node3 = %Node{ @@ -149,8 +147,7 @@ defmodule Archethic.BeaconChainTest do available?: true, authorization_date: summary_time |> DateTime.add(-10), authorized?: true, - reward_address: <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>, - availability_history: <<1::1>> + reward_address: <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>> } node4 = %Node{ @@ -163,8 +160,7 @@ defmodule Archethic.BeaconChainTest do available?: true, authorization_date: summary_time |> DateTime.add(-10), authorized?: true, - reward_address: <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>, - availability_history: <<1::1>> + reward_address: <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>> } P2P.add_and_connect_node(node1) diff --git a/test/archethic/bootstrap/sync_test.exs b/test/archethic/bootstrap/sync_test.exs index c7ec697c1a..ef4361b1b0 100644 --- a/test/archethic/bootstrap/sync_test.exs +++ b/test/archethic/bootstrap/sync_test.exs @@ -351,7 +351,6 @@ defmodule Archethic.Bootstrap.SyncTest do http_port: 4000, first_public_key: "key1", last_public_key: "key1", - availability_history: <<1::1>>, authorized?: true, available?: true, authorization_date: DateTime.utc_now(), @@ -372,7 +371,6 @@ defmodule Archethic.Bootstrap.SyncTest do enrollment_date: DateTime.utc_now(), authorized?: true, available?: true, - availability_history: <<1::1>>, network_patch: "AAA" } @@ -383,7 +381,6 @@ defmodule Archethic.Bootstrap.SyncTest do first_public_key: "key2", last_public_key: "key2", authorized?: true, - availability_history: <<1::1>>, available?: true } diff --git a/test/archethic/bootstrap/transaction_handler_test.exs b/test/archethic/bootstrap/transaction_handler_test.exs index f5529efe3b..dfa9e5ebad 100644 --- a/test/archethic/bootstrap/transaction_handler_test.exs +++ b/test/archethic/bootstrap/transaction_handler_test.exs @@ -46,8 +46,7 @@ defmodule Archethic.Bootstrap.TransactionHandlerTest do available?: true, authorized?: true, authorization_date: DateTime.utc_now() |> DateTime.add(-10), - enrollment_date: DateTime.utc_now(), - availability_history: <<1::1>> + enrollment_date: DateTime.utc_now() } :ok = P2P.add_and_connect_node(node) diff --git a/test/archethic/p2p_test.exs b/test/archethic/p2p_test.exs index 05ffb16d7d..e663e6f6b2 100644 --- a/test/archethic/p2p_test.exs +++ b/test/archethic/p2p_test.exs @@ -45,7 +45,6 @@ defmodule Archethic.P2PTest do first_public_key: pub1, last_public_key: pub1, available?: true, - availability_history: <<1::1>>, network_patch: "AAA", geo_patch: "AAA" }, @@ -55,7 +54,6 @@ defmodule Archethic.P2PTest do first_public_key: pub2, last_public_key: pub2, available?: true, - availability_history: <<1::1>>, network_patch: "AAA", geo_patch: "AAA" }, @@ -65,7 +63,6 @@ defmodule Archethic.P2PTest do first_public_key: pub3, last_public_key: pub3, available?: true, - availability_history: <<1::1>>, network_patch: "AAA", geo_patch: "AAA" }, @@ -75,7 +72,6 @@ defmodule Archethic.P2PTest do first_public_key: pub4, last_public_key: pub4, available?: true, - availability_history: <<1::1>>, network_patch: "AAA", geo_patch: "AAA" }, @@ -85,7 +81,6 @@ defmodule Archethic.P2PTest do first_public_key: pub5, last_public_key: pub5, available?: true, - availability_history: <<1::1>>, network_patch: "AAA", geo_patch: "AAA" } diff --git a/test/archethic/self_repair/notifier_test.exs b/test/archethic/self_repair/notifier_test.exs index 9c0b65e3d8..f023a893e6 100644 --- a/test/archethic/self_repair/notifier_test.exs +++ b/test/archethic/self_repair/notifier_test.exs @@ -197,8 +197,7 @@ defmodule Archethic.SelfRepair.NotifierTest do authorized?: true, authorization_date: DateTime.utc_now() |> DateTime.add(-11, :minute), available?: true, - enrollment_date: enrollment_date, - availability_history: <<1::1>> + enrollment_date: enrollment_date } P2P.add_and_connect_node(node) @@ -212,8 +211,7 @@ defmodule Archethic.SelfRepair.NotifierTest do network_patch: "AAA", authorized?: true, authorization_date: DateTime.utc_now(), - available?: true, - availability_history: <<1::1>> + available?: true } end) diff --git a/test/archethic/self_repair/self_repair_test.exs b/test/archethic/self_repair/self_repair_test.exs index 534f5a5c9f..04d22bc295 100644 --- a/test/archethic/self_repair/self_repair_test.exs +++ b/test/archethic/self_repair/self_repair_test.exs @@ -35,8 +35,7 @@ defmodule Archethic.SelfRepairTest do geo_patch: "AAA", authorized?: true, authorization_date: ~U[2022-11-27 00:00:00Z], - available?: true, - availability_history: <<1::1>> + available?: true } me = self() diff --git a/test/archethic/transaction_chain_test.exs b/test/archethic/transaction_chain_test.exs index a5b8bf504b..f1a76ab0e8 100644 --- a/test/archethic/transaction_chain_test.exs +++ b/test/archethic/transaction_chain_test.exs @@ -125,22 +125,19 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node1", ip: {127, 0, 0, 1}, port: 3000, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node2", last_public_key: "node2", ip: {127, 0, 0, 1}, - port: 3001, - availability_history: <<1::1>> + port: 3001 }, %Node{ first_public_key: "node3", last_public_key: "node3", ip: {127, 0, 0, 1}, - port: 3002, - availability_history: <<1::1>> + port: 3002 } ] @@ -161,24 +158,21 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node1", ip: {127, 0, 0, 1}, port: 3000, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node2", last_public_key: "node2", ip: {127, 0, 0, 1}, port: 3001, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node3", last_public_key: "node3", ip: {127, 0, 0, 1}, port: 3002, - available?: true, - availability_history: <<1::1>> + available?: true } ] @@ -208,24 +202,21 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node1", ip: {127, 0, 0, 1}, port: 3000, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node2", last_public_key: "node2", ip: {127, 0, 0, 1}, port: 3001, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node3", last_public_key: "node3", ip: {127, 0, 0, 1}, port: 3002, - available?: true, - availability_history: <<1::1>> + available?: true } ] @@ -255,24 +246,21 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node1", ip: {127, 0, 0, 1}, port: 3000, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node2", last_public_key: "node2", ip: {127, 0, 0, 1}, port: 3001, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node3", last_public_key: "node3", ip: {127, 0, 0, 1}, port: 3002, - available?: true, - availability_history: <<1::1>> + available?: true } ] @@ -329,24 +317,21 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node1", ip: {127, 0, 0, 1}, port: 3000, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node2", last_public_key: "node2", ip: {127, 0, 0, 1}, port: 3001, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node3", last_public_key: "node3", ip: {127, 0, 0, 1}, port: 3002, - available?: true, - availability_history: <<1::1>> + available?: true } ] @@ -382,24 +367,21 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node1", ip: {127, 0, 0, 1}, port: 3000, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node2", last_public_key: "node2", ip: {127, 0, 0, 1}, port: 3001, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node3", last_public_key: "node3", ip: {127, 0, 0, 1}, port: 3002, - available?: true, - availability_history: <<1::1>> + available?: true } ] @@ -466,24 +448,21 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node1", ip: {127, 0, 0, 1}, port: 3000, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node2", last_public_key: "node2", ip: {127, 0, 0, 1}, port: 3001, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node3", last_public_key: "node3", ip: {127, 0, 0, 1}, port: 3002, - available?: true, - availability_history: <<1::1>> + available?: true } ] @@ -520,24 +499,21 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node1", ip: {127, 0, 0, 1}, port: 3000, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node2", last_public_key: "node2", ip: {127, 0, 0, 1}, port: 3001, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node3", last_public_key: "node3", ip: {127, 0, 0, 1}, port: 3002, - available?: true, - availability_history: <<1::1>> + available?: true } ] @@ -607,24 +583,21 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node1", ip: {127, 0, 0, 1}, port: 3000, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node2", last_public_key: "node2", ip: {127, 0, 0, 1}, port: 3001, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node3", last_public_key: "node3", ip: {127, 0, 0, 1}, port: 3002, - available?: true, - availability_history: <<1::1>> + available?: true } ] @@ -645,24 +618,21 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node1", ip: {127, 0, 0, 1}, port: 3000, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node2", last_public_key: "node2", ip: {127, 0, 0, 1}, port: 3001, - available?: true, - availability_history: <<1::1>> + available?: true }, %Node{ first_public_key: "node3", last_public_key: "node3", ip: {127, 0, 0, 1}, port: 3002, - available?: true, - availability_history: <<1::1>> + available?: true } ] @@ -693,7 +663,6 @@ defmodule Archethic.TransactionChainTest do ip: {127, 0, 0, 1}, port: 3000, available?: true, - availability_history: <<1::1>>, authorized?: true, geo_patch: "AAA", authorization_date: DateTime.utc_now() @@ -703,7 +672,6 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node2", ip: {127, 0, 0, 1}, port: 3001, - availability_history: <<1::1>>, geo_patch: "AAA", authorized?: true, authorization_date: DateTime.utc_now() @@ -714,7 +682,6 @@ defmodule Archethic.TransactionChainTest do geo_patch: "AAA", ip: {127, 0, 0, 1}, port: 3002, - availability_history: <<1::1>>, authorized?: true, authorization_date: DateTime.utc_now() } @@ -859,7 +826,6 @@ defmodule Archethic.TransactionChainTest do ip: {127, 0, 0, 1}, port: 3000, available?: true, - availability_history: <<1::1>>, authorized?: true, geo_patch: "AAA", authorization_date: DateTime.utc_now() @@ -869,7 +835,6 @@ defmodule Archethic.TransactionChainTest do last_public_key: "node2", ip: {127, 0, 0, 1}, port: 3001, - availability_history: <<1::1>>, geo_patch: "AAA", authorized?: true, authorization_date: DateTime.utc_now() @@ -880,7 +845,6 @@ defmodule Archethic.TransactionChainTest do geo_patch: "AAA", ip: {127, 0, 0, 1}, port: 3002, - availability_history: <<1::1>>, authorized?: true, authorization_date: DateTime.utc_now() } @@ -932,7 +896,6 @@ defmodule Archethic.TransactionChainTest do ip: {127, 0, 0, 1}, port: 3000, available?: true, - availability_history: <<1::1>>, authorized?: true, geo_patch: "AAA", authorization_date: DateTime.utc_now() @@ -943,7 +906,6 @@ defmodule Archethic.TransactionChainTest do ip: {127, 0, 0, 1}, port: 3001, available?: true, - availability_history: <<1::1>>, geo_patch: "AAA", authorized?: true, authorization_date: DateTime.utc_now() diff --git a/test/support/template.ex b/test/support/template.ex index 01c1822114..9efcc3186f 100644 --- a/test/support/template.ex +++ b/test/support/template.ex @@ -184,8 +184,7 @@ defmodule ArchethicCase do end) MockClient - |> stub(:new_connection, fn _, _, _, public_key -> - P2PMemTable.increase_node_availability(public_key) + |> stub(:new_connection, fn _, _, _, _ -> {:ok, make_ref()} end) |> stub(:send_message, fn