How to create src/test/data/script_tests.json JSON file? #11636

issue ghost opened this issue on November 8, 2017
  1. ghost commented at 10:55 AM on November 8, 2017: none

    Hi! I'd like to know how to create src/test/data/script_tests.json JSON file? Thanks.

  2. fanquake added the label Tests on Nov 8, 2017
  3. sipsorcery commented at 11:05 AM on November 8, 2017: member

    The JSON file already exists, there's nothing you need to do to create it.

    Do you mean how to create the header file from the JSON file? The src/Makefile.test.include has the commands.

    %.json.h: %.json @$(MKDIR_P) $(@D) @{
    echo "namespace json_tests{" &&
    echo "static unsigned const char $(*F)[] = {" &&
    $(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' &&
    echo "};};";
    } > "$@.new" && mv -f "$@.new" "$@" @echo "Generated $@"

    Or to make it suitable for a standalone command line (you'll need to add the echos to the top and bottom if desired):

    hexdump script_tests.json -v -e '8/1 "0x%02x, "' -e '"\n"' | sed -e 's/0x ,//g'

  4. ghost commented at 11:09 AM on November 8, 2017: none

    @sipsorcery Nope. I am making my own bitcoin and I'd like to switch the existing file. I've founded this code and is there an way to activate this?

    bitcoin/src/test/script_tests.cpp:

    // Uncomment if you want to output updated JSON tests. // #define UPDATE_JSON_TESTS

  5. sipsorcery commented at 11:36 AM on November 8, 2017: member

    In that case you just do exactly as it says. Uncomment the define and then rebuild the bitcoin source. Once the build is complete run test_bitcoin and you should end up with a script_test.json.gen.

    Attached is the file I got from master.

    script_tests.json.zip

  6. fanquake closed this on Nov 8, 2017

  7. MarcoFalke locked this on Sep 8, 2021
Contributors
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 15:15 UTC

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