Skip to content

Commit

Permalink
Fix invalid fee error
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix committed Jul 21, 2022
1 parent 2b7d801 commit 263d1ed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
11 changes: 10 additions & 1 deletion lib/archethic/mining/fee.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule Archethic.Mining.Fee do
alias Archethic.TransactionChain.TransactionData.Ledger
alias Archethic.TransactionChain.TransactionData.TokenLedger
alias Archethic.TransactionChain.TransactionData.UCOLedger
alias Archethic.TransactionChain.Transaction.ValidationStamp

@unit_uco 100_000_000

Expand Down Expand Up @@ -110,8 +111,16 @@ defmodule Archethic.Mining.Fee do
|> length()
end

defp get_number_replicas(%Transaction{
address: address,
validation_stamp: %ValidationStamp{timestamp: timestamp}
}) do
address
|> Election.chain_storage_nodes(P2P.authorized_nodes(timestamp))
|> length()
end

defp get_number_replicas(%Transaction{address: address}) do
# TODO: take the nodes at the time of the transaction's timestamp
address
|> Election.chain_storage_nodes(P2P.authorized_nodes())
|> length()
Expand Down
4 changes: 2 additions & 2 deletions test/archethic/bootstrap/network_init_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ defmodule Archethic.Bootstrap.NetworkInitTest do
available?: true,
geo_patch: "AAA",
network_patch: "AAA",
enrollment_date: DateTime.utc_now(),
authorization_date: DateTime.utc_now(),
enrollment_date: DateTime.add(DateTime.utc_now(), -1),
authorization_date: DateTime.add(DateTime.utc_now(), -1),
authorized?: true,
reward_address: <<0::8, :crypto.strong_rand_bytes(32)::binary>>
})
Expand Down
6 changes: 3 additions & 3 deletions test/archethic/replication_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ defmodule Archethic.ReplicationTest do
last_public_key: Crypto.last_node_public_key(),
authorized?: true,
available?: true,
authorization_date: DateTime.utc_now(),
authorization_date: DateTime.add(DateTime.utc_now(), -1),
geo_patch: "AAA",
network_patch: "AAA",
enrollment_date: DateTime.utc_now(),
enrollment_date: DateTime.add(DateTime.utc_now(), -1),
reward_address: <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>
}

Expand All @@ -167,7 +167,7 @@ defmodule Archethic.ReplicationTest do
available?: true,
geo_patch: "BBB",
network_patch: "BBB",
authorization_date: DateTime.utc_now(),
authorization_date: DateTime.add(DateTime.utc_now(), -1),
reward_address: <<0::8, :crypto.strong_rand_bytes(32)::binary>>
}
]
Expand Down

0 comments on commit 263d1ed

Please sign in to comment.