Skip to content

Commit

Permalink
resolve dialyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorv-2204 committed Aug 22, 2022
1 parent d88b0a2 commit 4336fb8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
9 changes: 5 additions & 4 deletions lib/archethic/bootstrap.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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",
Expand Down
22 changes: 14 additions & 8 deletions test/archethic/bootstrap_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
}
Expand All @@ -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

0 comments on commit 4336fb8

Please sign in to comment.