From 2b0191764dcf5789c0c8e00c1d21e062d467631b Mon Sep 17 00:00:00 2001 From: bchamagne Date: Tue, 8 Oct 2024 17:24:44 +0200 Subject: [PATCH 1/2] fix acceptance resolver when resyncing --- lib/archethic/self_repair/network_chain.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/archethic/self_repair/network_chain.ex b/lib/archethic/self_repair/network_chain.ex index fb41f9c1e..c10b78b50 100644 --- a/lib/archethic/self_repair/network_chain.ex +++ b/lib/archethic/self_repair/network_chain.ex @@ -165,7 +165,8 @@ defmodule Archethic.SelfRepair.NetworkChain do case TransactionChain.fetch_last_address(genesis_address, nodes, consistency_level: 8, - acceptance_resolver: &(&1.timestamp > local_last_address_timestamp) + acceptance_resolver: + &(DateTime.compare(&1.timestamp, local_last_address_timestamp) == :gt) ) do {:ok, remote_last_address} -> {:error, {genesis_address, remote_last_address}} From f725af9363dc72b57ac272655b7f10874f9cbe57 Mon Sep 17 00:00:00 2001 From: bchamagne Date: Tue, 8 Oct 2024 17:38:17 +0200 Subject: [PATCH 2/2] fix acceptance resolver in tests --- test/archethic/transaction_chain_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/archethic/transaction_chain_test.exs b/test/archethic/transaction_chain_test.exs index 04b2430e6..739b5eed7 100644 --- a/test/archethic/transaction_chain_test.exs +++ b/test/archethic/transaction_chain_test.exs @@ -288,7 +288,7 @@ defmodule Archethic.TransactionChainTest do nodes = P2P.authorized_and_available_nodes() acceptance_resolver = fn %LastTransactionAddress{timestamp: remote_last_address_timestamp} -> - now < remote_last_address_timestamp + DateTime.compare(now, remote_last_address_timestamp) == :lt end assert {:error, :acceptance_failed} = @@ -331,7 +331,7 @@ defmodule Archethic.TransactionChainTest do nodes = P2P.authorized_and_available_nodes() acceptance_resolver = fn %LastTransactionAddress{timestamp: remote_last_address_timestamp} -> - now < remote_last_address_timestamp + DateTime.compare(now, remote_last_address_timestamp) == :lt end assert {:ok, ^latest_address} =