Commit d0d5223a authored by Evan Vigil-McClanahan's avatar Evan Vigil-McClanahan
Browse files

fix targeting on newer nodes, increase test stability

parent 79e0c0fd
Showing with 34 additions and 18 deletions
+34 -18
......@@ -601,27 +601,28 @@ set_next_block_timer(State=#state{blockchain=Chain, start_block_time=StartBlockT
StartHeight0 = application:get_env(miner, stabilization_period, 0),
StartHeight = max(1, Height - StartHeight0),
StartBlockTime = case StartBlockTime0 of
undefined ->
case Height > StartHeight of
true ->
case blockchain:find_first_block_after(StartHeight, Chain) of
{ok, _, StartBlock} ->
blockchain_block:time(StartBlock);
_ ->
undefined
end;
false ->
undefined
end;
Time ->
Time
end,
{ActualStartHeight, StartBlockTime} =
case StartBlockTime0 of
undefined ->
case Height > StartHeight of
true ->
case blockchain:find_first_block_after(StartHeight, Chain) of
{ok, Actual, StartBlock} ->
{Actual, blockchain_block:time(StartBlock)};
_ ->
{0, undefined}
end;
false ->
{0, undefined}
end;
Time ->
{StartHeight, Time}
end,
AvgBlockTime = case StartBlockTime of
undefined ->
BlockTime;
_ ->
(LastBlockTimestamp - StartBlockTime) / (Height - StartHeight)
(LastBlockTimestamp - StartBlockTime) / (Height - ActualStartHeight)
end,
BlockTimeDeviation0 = BlockTime - AvgBlockTime,
lager:info("average ~p block times ~p difference ~p", [Height, AvgBlockTime, BlockTime - AvgBlockTime]),
......
......@@ -105,6 +105,12 @@ init_per_testcase(TestCase, Config0) ->
true = lists:all(fun(Res) -> Res == ok end, DKGResults),
%% Get both consensus and non consensus miners
true = miner_ct_utils:wait_until(
fun() ->
{_ConsensusMiners, NCMiners} = miner_ct_utils:miners_by_consensus_state(Miners),
length(NCMiners) == 1
end, 25, 200),
{ConsensusMiners, NonConsensusMiners} = miner_ct_utils:miners_by_consensus_state(Miners),
ct:pal("ConsensusMiners: ~p, NonConsensusMiners: ~p", [ConsensusMiners, NonConsensusMiners]),
......@@ -790,9 +796,18 @@ snapshot_test(Config) ->
miner_ct_utils:start_miners([{Target, NewTargetEnv}]),
timer:sleep(5000),
miner_ct_utils:wait_until(
fun() ->
try
undefined =/= ct_rpc:call(Target, blockchain_worker, blockchain, [])
catch _:_ ->
false
end
end, 50, 200),
ok = ct_rpc:call(Target, blockchain, reset_ledger_to_snap, []),
ok = miner_ct_utils:wait_for_gte(height, Miners0, 25, all, 20),
ok.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment