Esempio n. 1
0
def test_compile_clvm_text():
    with TemporaryDirectory() as include_dir:
        include_path = f"{include_dir}/include.clvm"
        with open(include_path, "w") as f:
            f.write(INCLUDE_CODE)
        output = clvmc.compile_clvm_text(MAIN_CODE, search_paths=[include_dir])
        assert repr(output) == f"SExp({EXPECTED_HEX_OUTPUT})"
Esempio n. 2
0
def parse_program(program: str, include=[]):
    if '(' in program:
        prog = Program.to(assemble(program))
    elif '.' not in program:
        prog = Program.from_bytes(bytes.fromhex(program))
    else:
        with open(program, "r") as file:
            filestring = file.read()
            if '(' in filestring:
                if re.compile('\(mod\s').search(filestring):
                    prog = Program.to(
                        compile_clvm_text(filestring, append_include(include)))
                else:
                    prog = Program.to(assemble(filestring))
            else:
                prog = Program.from_bytes(bytes.fromhex(filestring))
    return prog
Esempio n. 3
0
    (defun go (deserialize-mod historical-generators)
    (c (first-block deserialize-mod historical-generators)
       (second-block deserialize-mod historical-generators)
    ))
    (go deserialize-mod historical-generators)
)
"""

COMPILED_GENERATOR_CODE = bytes.fromhex(
    "ff02ffff01ff04ffff02ff04ffff04ff02ffff04ff05ffff04ff0bff8080808080ffff02"
    "ff06ffff04ff02ffff04ff05ffff04ff0bff808080808080ffff04ffff01ffff02ff05ff"
    "1380ff02ff05ff2b80ff018080")

COMPILED_GENERATOR_CODE = bytes(
    Program.to(compile_clvm_text(GENERATOR_CODE, [])))

FIRST_GENERATOR = Program.to(
    binutils.assemble(
        '((parent_id (c 1 (q "puzzle blob")) 50000 "solution is here" extra data for coin))'
    )).as_bin()

SECOND_GENERATOR = Program.to(
    binutils.assemble("(extra data for block)")).as_bin()

FIRST_GENERATOR = Program.to(
    binutils.assemble("""
        ((0x0000000000000000000000000000000000000000000000000000000000000000 1 50000
        ((51 0x0000000000000000000000000000000000000000000000000000000000000001 500)) "extra" "data" "for" "coin" ))"""
                      )).as_bin()