From 672a4796089b16dac9ad35fc2762070e60248e7e Mon Sep 17 00:00:00 2001 From: Bastien Chamagne Date: Wed, 19 Jul 2023 14:35:33 +0200 Subject: [PATCH] add optional timeout to send_transaction_with_await_replication --- lib/archethic/utils/regression/playbook.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/archethic/utils/regression/playbook.ex b/lib/archethic/utils/regression/playbook.ex index 7d0c20486..b26d61a2c 100644 --- a/lib/archethic/utils/regression/playbook.ex +++ b/lib/archethic/utils/regression/playbook.ex @@ -219,7 +219,8 @@ defmodule Archethic.Utils.Regression.Playbook do host, port, curve \\ Crypto.default_curve(), - proto \\ :http + proto \\ :http, + opts \\ [] ) do chain_length = get_chain_size(transaction_seed, curve, host, port, proto) @@ -256,7 +257,10 @@ defmodule Archethic.Utils.Regression.Playbook do proto ) do {:ok, %{"status" => "pending"}} -> - case Task.yield(replication_attestation, 5_000) || Task.shutdown(replication_attestation) do + await_timeout = Keyword.get(opts, :await_timeout, 5_000) + + case Task.yield(replication_attestation, await_timeout) || + Task.shutdown(replication_attestation) do {:ok, :ok} -> {:ok, tx.address}