anchor.diff:      aecore_suite_utils:start_node(?NODE, Config),
       aecore_suite_utils:connect(NodeName),
   
  -    aecore_suite_utils:mine_key_blocks(NodeName, 3),
  +    ToMine = max(0, aecore_suite_utils:latest_fork_height()),
  +    ct:pal("ToMine ~p\n", [ToMine]),
  +    [ aecore_suite_utils:mine_key_blocks(NodeName, ToMine) || ToMine > 0 ],
   
       %% Prepare accounts, Alice, Bert, Carl and Diana.
   
  -    StartAmt = 100000,
  -    {APubkey, APrivkey, _} = new_account(StartAmt),
  -    {BPubkey, BPrivkey, _} = new_account(StartAmt),
  -    {CPubkey, CPrivkey, _} = new_account(StartAmt),
  -    {DPubkey, DPrivkey, _} = new_account(StartAmt),
  -
  -    {ok, [_KeyBlock,Block]} = aecore_suite_utils:mine_blocks(NodeName, 2),
  -    Txs = [_Spend1,_Spend2,_Spend3,_Spend4] = aec_blocks:txs(Block),
  -    ct:pal("Block txs ~p\n", [Txs]),
  +    StartAmt = 250000,
  +    {APubkey, APrivkey, STx1} = new_account(StartAmt),
  +    {BPubkey, BPrivkey, STx2} = new_account(StartAmt),
  +    {CPubkey, CPrivkey, STx3} = new_account(StartAmt),
  +    {DPubkey, DPrivkey, STx4} = new_account(StartAmt),
  +
  +    {ok, _} = aecore_suite_utils:mine_blocks_until_txs_on_chain(
  +                                    NodeName, [STx1, STx2, STx3, STx4], 5),
   
       %% Save account information.
       Accounts = #{acc_a => #{pub_key => APubkey,
  
positive.code:     %% Set the cost from the amount, decrease and diff in height.
      Cost = StartAmt - (Height1 - Height0) * Decrease,
  
      BBal2 = get_balance(BPubkey),
      CBal2 = get_balance(CPubkey),
  
      %% ct:pal("B Balances ~p, ~p, ~p\n", [BBal0,BBal1,BBal2]),
      %% ct:pal("Cost ~p, GasUsed ~p, Fee ~p\n", [Cost,GasUsed,Fee]),
      %% ct:pal("C Balances ~p, ~p, ~p\n", [CBal0,CBal1,CBal2]),
  
      %% Check that the balances are correct, don't forget the gas and the fee.
      BBal2 = BBal1 - Cost - GasUsed - Fee,
  
negative.code: %%                   Function, Arguments, CallerSet)
  %%  Call contract function with arguments and mine blocks until in chain.
  
  init_fun_calls() ->
      put(fun_calls, []), put(nonces, []).
  
  force_fun_calls(Node) ->
      Calls = put(fun_calls, []),
      put(nonces, []),
      Txs = [ TxHash || {TxHash, _} <- Calls ],
      aecore_suite_utils:mine_blocks_until_txs_on_chain(Node, Txs, 10),
      check_calls(Calls).
  
  check_calls(Calls) ->
      [ check_call(Call) || Call <- Calls ].
  
  check_call({TxHash, Check}) ->
      ct:log("Checking: ~p", [TxHash]),
      {ok, 200, CallReturn} = get_contract_call_object(TxHash),
      ct:pal("Call return ~p\n", [CallReturn]),
  
      #{<<"return_type">> := RetType, <<"return_value">> := Value} = CallReturn,
  
      %% Get the block where the tx was included
      case Check of
          none -> ?assertEqual(<<"ok">>, RetType);
          {Type, Fun} when is_function(Fun) ->
              ?assertEqual(<<"ok">>, RetType),
              {ok, 200, #{<<"block_hash">> := BlockHash}} = get_tx(TxHash),
              {ok, 200, BlockHeader} = get_micro_block_header(BlockHash),
              check_value(Value, {Type, Fun(BlockHeader)});
          {_, _} ->
              ?assertEqual(<<"ok">>, RetType),
              check_value(Value, Check);
          error ->
              ?assertEqual(<<"error">>, RetType)
      end.
  
  check_value(Val0, {Type, ExpVal}) ->
      #{<<"value">> := Val} = decode_data(Type, Val0),
      ct:log("~p decoded as ~p into ~p =??= ~p", [Val0, Type, Val, ExpVal]),
      ?assertEqual(ExpVal, Val).
  
  
  call_func(Pub, Priv, EncCPub, Fun, Args) ->
      call_func(Pub, Priv, EncCPub, Fun, Args, #{}, none).
  
  call_func(Pub, Priv, EncCPub, Fun, Args, Check) ->
      call_func(Pub, Priv, EncCPub, Fun, Args, #{}, Check).
  
  call_func(Pub, Priv, EncCPub, Fun, Args, CallerSet, Check) ->
      Nonce = get_nonce(Pub),
      CallTxHash =
          contract_call_compute_tx(Pub, Priv, Nonce, EncCPub, Fun, Args, CallerSet),
  
      Calls = get(fun_calls),
      put(fun_calls, Calls ++ [{CallTxHash, Check}]).
  
  get_nonce(Pub) ->
      Address = aec_base58c:encode(account_pubkey, Pub),
      %% Generate a nonce.
      {ok,200,#{<<"nonce">> := Nonce0}} = get_account_by_pubkey(Address),
      Nonces = get(nonces),
      case lists:keyfind(Pub, 1, Nonces) of
          false ->
              put(nonces, [{Pub, 1} | Nonces]),
              Nonce0 + 1;
          {Pub, NonceOff} ->
              put(nonces, lists:keyreplace(Pub, 1, Nonces, {Pub, NonceOff + 1})),
              Nonce0 + NonceOff + 1
      end.
  
  call_compute_func(NodeName, Pubkey, Privkey, EncodedContractPubkey,
                    Function, Argument) ->
      call_compute_func(NodeName, Pubkey, Privkey, EncodedContractPubkey,
  