From 4f2e7e2715caf3b209a9d09da63878e4498f9c33 Mon Sep 17 00:00:00 2001 From: Samuel Manzanera Date: Mon, 22 Jul 2024 18:14:23 +0200 Subject: [PATCH] fix --- lib/archethic/mining/pending_transaction_validation.ex | 4 +++- test/archethic/bootstrap/sync_test.exs | 7 ++++--- test/archethic/mining/distributed_workflow_test.exs | 3 ++- .../mining/pending_transaction_validation_test.exs | 6 ++++-- test/archethic/shared_secrets/mem_tables_loader_test.exs | 5 +++-- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/archethic/mining/pending_transaction_validation.ex b/lib/archethic/mining/pending_transaction_validation.ex index 09acf8c98..a9076a12b 100644 --- a/lib/archethic/mining/pending_transaction_validation.ex +++ b/lib/archethic/mining/pending_transaction_validation.ex @@ -333,7 +333,9 @@ defmodule Archethic.Mining.PendingTransactionValidation do {:transfers, true} <- {:transfers, Enum.all?(token_transfers, &Reward.is_reward_token?(&1.token_address))}, {:mining_public_key, true} <- - {:mining_public_key, Crypto.valid_public_key?(mining_public_key)} do + {:mining_public_key, + Crypto.valid_public_key?(mining_public_key) and + Crypto.get_public_key_curve(mining_public_key) == :bls} do :ok else :error -> diff --git a/test/archethic/bootstrap/sync_test.exs b/test/archethic/bootstrap/sync_test.exs index ec22a85eb..94dea3858 100644 --- a/test/archethic/bootstrap/sync_test.exs +++ b/test/archethic/bootstrap/sync_test.exs @@ -313,9 +313,10 @@ defmodule Archethic.Bootstrap.SyncTest do 3000, 4000, :tcp, - <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>, - <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>, - :crypto.strong_rand_bytes(64) + ArchethicCase.random_public_key(), + ArchethicCase.random_public_key(), + :crypto.strong_rand_bytes(64), + Crypto.generate_random_keypair(:bls) |> elem(0) ) }) diff --git a/test/archethic/mining/distributed_workflow_test.exs b/test/archethic/mining/distributed_workflow_test.exs index 8ab1628d1..62b81ffa7 100644 --- a/test/archethic/mining/distributed_workflow_test.exs +++ b/test/archethic/mining/distributed_workflow_test.exs @@ -112,7 +112,8 @@ defmodule Archethic.Mining.DistributedWorkflowTest do <<0, 0, 16, 233, 156, 172, 143, 228, 236, 12, 227, 76, 1, 80, 12, 236, 69, 10, 209, 6, 234, 172, 97, 188, 240, 207, 70, 115, 64, 117, 44, 82, 132, 186>>, origin_public_key, - certificate + certificate, + Crypto.generate_random_keypair(:bls) |> elem(0) ) }) diff --git a/test/archethic/mining/pending_transaction_validation_test.exs b/test/archethic/mining/pending_transaction_validation_test.exs index a4ce6c619..861edcebe 100644 --- a/test/archethic/mining/pending_transaction_validation_test.exs +++ b/test/archethic/mining/pending_transaction_validation_test.exs @@ -548,7 +548,8 @@ defmodule Archethic.Mining.PendingTransactionValidationTest do <<0, 0, 4, 221, 19, 74, 75, 69, 16, 50, 149, 253, 24, 115, 128, 241, 110, 118, 139, 7, 48, 217, 58, 43, 145, 233, 77, 125, 190, 207, 31, 64, 157, 137>>, origin_public_key, - certificate + certificate, + Crypto.generate_random_keypair(:bls) |> elem(0) ) tx = TransactionFactory.create_non_valided_transaction(type: :node, content: content) @@ -581,7 +582,8 @@ defmodule Archethic.Mining.PendingTransactionValidationTest do <<0, 0, 4, 221, 19, 74, 75, 69, 16, 50, 149, 253, 24, 115, 128, 241, 110, 118, 139, 7, 48, 217, 58, 43, 145, 233, 77, 125, 190, 207, 31, 64, 157, 137>>, <<0::8, 0::8, :crypto.strong_rand_bytes(32)::binary>>, - certificate + certificate, + Crypto.generate_random_keypair(:bls) |> elem(0) ) tx = diff --git a/test/archethic/shared_secrets/mem_tables_loader_test.exs b/test/archethic/shared_secrets/mem_tables_loader_test.exs index c94036c82..21d820c0f 100644 --- a/test/archethic/shared_secrets/mem_tables_loader_test.exs +++ b/test/archethic/shared_secrets/mem_tables_loader_test.exs @@ -47,7 +47,8 @@ defmodule Archethic.SharedSecrets.MemTablesLoaderTest do :tcp, ArchethicCase.random_address(), origin_public_key, - ArchethicCase.random_public_key() + :crypto.strong_rand_bytes(32), + Crypto.generate_random_keypair(:bls) |> elem(0) ) } } @@ -159,7 +160,7 @@ defmodule Archethic.SharedSecrets.MemTablesLoaderTest do ArchethicCase.random_address(), node_origin_public_key, :crypto.strong_rand_bytes(32), - ArchethicCase.random_public_key() + Crypto.generate_random_keypair(:bls) |> elem(0) ) } }