anchor.diff:      KeyBlock = wait_for_block_created(),
       assert_leader(true),
       assert_generation_state(running),
  +    wait_for_top_block_hash(block_hash(KeyBlock)),
   
       ok = aec_tx_pool:push(tx(Keys)),
  -
       MicroBlock = wait_for_micro_block_created(),
  -    {ok, KeyHash} = aec_blocks:hash_internal_representation(KeyBlock),
  -    ?assertEqual(KeyHash, aec_blocks:prev_key_hash(MicroBlock)),
  +    wait_for_top_block_hash(block_hash(MicroBlock)),
  +
  +    ok = prev_on_chain(MicroBlock, KeyBlock),
       ok.
   
   test_two_mined_block_signing() ->
  
positive.code:     KeyBlock1 = wait_for_block_created(),
      assert_leader(true),
      assert_generation_state(running),
      KeyBlock2 = wait_for_block_created(),
      assert_leader(true),
      assert_generation_state(running),
  
      ok = aec_tx_pool:push(tx(Keys)),
  
      MicroBlock = wait_for_micro_block_created(),
      {ok, KeyHash1} = aec_blocks:hash_internal_representation(KeyBlock1),
      {ok, KeyHash2} = aec_blocks:hash_internal_representation(KeyBlock2),
      ?assertEqual(KeyHash1, aec_blocks:prev_key_hash(KeyBlock2)),
      ?assertEqual(KeyHash2, aec_blocks:prev_key_hash(MicroBlock)),
      ok.
  
  test_received_block_signing() ->
  
negative.code:                                   ttl => 0,
                                    payload => <<"">>}),
      aec_test_utils:sign_tx(Tx, Priv).
  
  prev_on_chain(Block, Target) ->
      prev_on_chain(Block, block_hash(Block), block_hash(Target)).
  
  prev_on_chain(_, Hash, Hash) -> ok;
  prev_on_chain(Block, _, Target) ->
      NewHash = aec_blocks:prev_hash(Block),
      case aec_chain:get_block(NewHash) of
          error -> {error, not_found};
          {ok, NewBlock} -> prev_on_chain(NewBlock, block_hash(Block), Target)
      end.
  
  
  assert_stopped() ->
      ?assertEqual(stopped, ?TEST_MODULE:get_mining_state()).
  