def test_p2_delegated_conditions(self):
        payments, conditions = default_payments_and_conditions()

        pk = public_key_bytes_for_index(1)

        puzzle_program = p2_delegated_conditions.puzzle_for_pk(pk)
        puzzle_hash = ProgramHash(puzzle_program)
        solution = p2_delegated_conditions.solution_for_conditions(
            puzzle_program, conditions)

        run_test(puzzle_hash, solution, payments)
 def solution_maker(coin, remote):
     print(coin.name())
     if fuzz_coin:
         coin = fuzz_coin(remote, puzzle_hash)
         print(coin.name())
     id_condition = make_assert_my_coin_id_condition(coin.name())
     delegated_puzzle = p2_conditions.puzzle_for_conditions(
         conditions + [id_condition])
     delegated_solution = p2_delegated_conditions.solution_for_conditions(
         delegated_puzzle, [])
     solution = p2_m_of_n_delegate_direct.solution_for_delegated_puzzle(
         M, pks, selectors, delegated_puzzle, delegated_solution)
     return solution
    def test_p2_delegated_puzzle_graftroot(self):
        payments, conditions = default_payments_and_conditions()

        delegated_puzzle = p2_delegated_conditions.puzzle_for_pk(
            public_key_bytes_for_index(8))
        delegated_solution = p2_delegated_conditions.solution_for_conditions(
            delegated_puzzle, conditions)

        puzzle_program = p2_delegated_puzzle.puzzle_for_pk(
            public_key_bytes_for_index(1))
        puzzle_hash = ProgramHash(puzzle_program)
        solution = p2_delegated_puzzle.solution_for_delegated_puzzle(
            puzzle_program, delegated_solution)

        run_test(puzzle_hash, solution, payments)
    def test_p2_puzzle_hash(self):
        payments, conditions = default_payments_and_conditions()

        underlying_puzzle = p2_delegated_conditions.puzzle_for_pk(
            public_key_bytes_for_index(4))
        underlying_solution = p2_delegated_conditions.solution_for_conditions(
            underlying_puzzle, conditions)
        underlying_puzzle_hash = ProgramHash(underlying_puzzle)

        puzzle_program = p2_puzzle_hash.puzzle_for_puzzle_hash(
            underlying_puzzle_hash)
        puzzle_hash = ProgramHash(puzzle_program)
        solution = p2_puzzle_hash.solution_for_puzzle_and_solution(
            underlying_puzzle, underlying_solution)

        run_test(puzzle_hash, solution, payments)
 def solution_maker(coin, remote):
     if fuzz_coin:
         coin = fuzz_coin(remote, puzzle_hash)
     id_condition = make_assert_my_coin_id_condition(coin.name())
     return p2_delegated_conditions.solution_for_conditions(
         puzzle_program, conditions + [id_condition])