From 4336fb846baf4033e446e4336fe729ef15c272dc Mon Sep 17 00:00:00 2001 From: Apoorv Date: Mon, 22 Aug 2022 19:34:02 +0530 Subject: [PATCH] resolve dialyzer --- lib/archethic/bootstrap.ex | 9 +++++---- test/archethic/bootstrap_test.exs | 22 ++++++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/archethic/bootstrap.ex b/lib/archethic/bootstrap.ex index 3d451e4d2d..aec900ac8c 100644 --- a/lib/archethic/bootstrap.ex +++ b/lib/archethic/bootstrap.ex @@ -209,7 +209,8 @@ defmodule Archethic.Bootstrap do end nodes = P2P.authorized_and_available_nodes() - resync_network_chain([:oracle, :node_shared_secrets], nodes) + # mint reward resync req to load gen addr from db + resync_network_chain([:oracle, :node_shared_secrets, :mint_rewards], nodes) Sync.publish_end_of_sync() SelfRepair.start_scheduler() @@ -237,15 +238,15 @@ defmodule Archethic.Bootstrap do addr -> # get last txn locally available - last_addr = TransactionChain.get_last_address(addr) + {last_addr, _dt} = TransactionChain.get_last_address(addr) try do # fetch txs remotely post last_addr TransactionChain.stream_remotely(last_addr, nodes, last_addr) |> Enum.to_list() |> List.flatten() - |> Enum.each(fn tx -> - if TransactionChain.transaction_exists?(tx.addr) do + |> Enum.each(fn tx = %TransactionChain.Transaction{} -> + if TransactionChain.transaction_exists?(tx.address) do # if tx already exists , Dont validate_and_store Logger.info( "Enforced Resyncing Network Transactions: , #{tx.address |> Base.encode16()} status: :aklready_available", diff --git a/test/archethic/bootstrap_test.exs b/test/archethic/bootstrap_test.exs index f9472d1596..eb4771a8ad 100644 --- a/test/archethic/bootstrap_test.exs +++ b/test/archethic/bootstrap_test.exs @@ -501,12 +501,12 @@ defmodule Archethic.BootstrapTest do synced?: true }) - addr = Crypto.derive_keypair("oracle_summary_test", 1) |> elem(0) |> Crypto.derive_address() + addr = Crypto.derive_keypair("nss_test", 1) |> elem(0) |> Crypto.derive_address() MockDB - |> expect(:list_addresses_by_type, 1, fn :oracle -> [addr] end) - |> expect(:get_last_chain_address, 1, fn addr -> addr end) - |> stub(:transaction_exists?, fn _ -> true end) + |> expect(:list_addresses_by_type, 1, fn :node_shared_secrets -> [addr] end) + |> expect(:get_last_chain_address, 1, fn addr -> {addr, DateTime.utc_now()} end) + |> stub(:transaction_exists?, fn _ -> false end) MockClient |> stub(:send_message, fn @@ -518,20 +518,23 @@ defmodule Archethic.BootstrapTest do %TransactionList{ transactions: [ %Transaction{ + type: :node_shared_secrets, address: - Crypto.derive_keypair("oracle_summary_test", 2) + Crypto.derive_keypair("nss_test", 2) |> elem(0) |> Crypto.derive_address() }, %Transaction{ + type: :node_shared_secrets, address: - Crypto.derive_keypair("oracle_summary_test", 3) + Crypto.derive_keypair("nss_test", 3) |> elem(0) |> Crypto.derive_address() }, %Transaction{ + type: :node_shared_secrets, address: - Crypto.derive_keypair("oracle_summary_test", 4) + Crypto.derive_keypair("nss_test", 4) |> elem(0) |> Crypto.derive_address() } @@ -540,7 +543,10 @@ defmodule Archethic.BootstrapTest do end) :ok = - Bootstrap.resync_network_chain([:oracle], _nodes = P2P.authorized_and_available_nodes()) + Bootstrap.resync_network_chain( + [:node_shared_secrets], + _nodes = P2P.authorized_and_available_nodes() + ) end end end