fuzz: Use mocktime in process_message* fuzz targets #20908

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2101-fuzzMocktime changing 2 files +11 −6
  1. MarcoFalke commented at 6:05 AM on January 12, 2021: member

    Use mocktime to allow time to advance deterministically during execution of a fuzz input. This also allows to drop the call to JumpOutOfIbd.

  2. fanquake added the label Tests on Jan 12, 2021
  3. in src/test/fuzz/process_message.cpp:74 in fa70ebeee9 outdated
      71 |      FillNode(fuzzed_data_provider, p2p_node);
      72 |      p2p_node.fSuccessfullyConnected = true;
      73 |      connman.AddTestNode(p2p_node);
      74 |      g_setup->m_node.peerman->InitializeNode(&p2p_node);
      75 |  
      76 | +    const auto time = ConsumeTime(fuzzed_data_provider);
    


    practicalswift commented at 9:06 PM on January 12, 2021:

    Nit: Could use the name t to avoid shadowing time(2)?

    #include <time.h>
    
    time_t time(time_t *tloc);
    

    MarcoFalke commented at 6:50 AM on January 13, 2021:

    thanks, fixed

  4. in src/test/fuzz/process_messages.cpp:64 in fa70ebeee9 outdated
      58 | @@ -59,10 +59,11 @@ FUZZ_TARGET_INIT(process_messages, initialize_process_messages)
      59 |      }
      60 |  
      61 |      while (fuzzed_data_provider.ConsumeBool()) {
      62 | -        if (!jump_out_of_ibd) jump_out_of_ibd = fuzzed_data_provider.ConsumeBool();
      63 | -        if (jump_out_of_ibd && chainstate.IsInitialBlockDownload()) chainstate.JumpOutOfIbd();
      64 |          const std::string random_message_type{fuzzed_data_provider.ConsumeBytesAsString(CMessageHeader::COMMAND_SIZE).c_str()};
      65 |  
      66 | +        const auto time = ConsumeTime(fuzzed_data_provider);
    


    practicalswift commented at 9:06 PM on January 12, 2021:

    Same nit applies here too.


    MarcoFalke commented at 6:50 AM on January 13, 2021:

    thanks, fixed

  5. practicalswift commented at 9:07 PM on January 12, 2021: contributor

    cr ACK fa70ebeee9e01240716df98aeccd7fbabcbc0ab8 modulo nits

  6. fuzz: Use mocktime in process_message* fuzz targets fa0a864b38
  7. MarcoFalke force-pushed on Jan 13, 2021
  8. in src/test/fuzz/process_message.cpp:66 in fa0a864b38
      64 |      const std::string random_message_type{fuzzed_data_provider.ConsumeBytesAsString(CMessageHeader::COMMAND_SIZE).c_str()};
      65 |      if (!LIMIT_TO_MESSAGE_TYPE.empty() && random_message_type != LIMIT_TO_MESSAGE_TYPE) {
      66 |          return;
      67 |      }
      68 | -    const bool jump_out_of_ibd{fuzzed_data_provider.ConsumeBool()};
      69 | -    if (jump_out_of_ibd) chainstate.JumpOutOfIbd();
    


    practicalswift commented at 10:29 AM on January 13, 2021:

    Now that TestChainState::JumpOutOfIbd is unused we can drop it?


    MarcoFalke commented at 10:34 AM on January 13, 2021:

    I think there are some other pull requests using it, so I'll keep it for now



    practicalswift commented at 10:57 AM on January 13, 2021:

    Makes sense. Thanks for clarifying!

  9. practicalswift commented at 10:58 AM on January 13, 2021: contributor

    cr ACK fa0a864b383a794910cdb215bb836dae12357bc6

  10. MarcoFalke merged this on Jan 15, 2021
  11. MarcoFalke closed this on Jan 15, 2021

  12. MarcoFalke deleted the branch on Jan 15, 2021
  13. sidhujag referenced this in commit baf56382b8 on Jan 16, 2021
  14. DrahtBot locked this on Aug 16, 2022
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 06:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me