def test_p2_singleton():
    launcher_id = LAUNCHER_ID
    innerpuz = Program.to(1)
    singleton_full_puzzle = singleton_puzzle(launcher_id, LAUNCHER_PUZZLE_HASH, innerpuz)
    p2_singleton_coin_id = Program.to(['test_hash']).get_tree_hash()
    expected_announcement = Announcement(singleton_full_puzzle.get_tree_hash(), p2_singleton_coin_id).name()
    p2_singleton_full = p2_singleton_puzzle(launcher_id, LAUNCHER_PUZZLE_HASH)
    solution = Program.to([innerpuz.get_tree_hash(), p2_singleton_coin_id])
    (cost, result) = p2_singleton_full.run_with_cost(INFINITE_COST, solution)
    (err, conditions) = parse_sexp_to_conditions(result)
    assert (err is None)
    p2_singleton_full = p2_singleton_puzzle(launcher_id, LAUNCHER_PUZZLE_HASH)
    solution = Program.to([innerpuz.get_tree_hash(), p2_singleton_coin_id])
    (cost, result) = p2_singleton_full.run_with_cost(INFINITE_COST, solution)
    assert (result.first().rest().first().as_atom() == expected_announcement)
    assert (conditions[0].vars[0] == expected_announcement)
def test_p2_singleton():
    launcher_id = LAUNCHER_ID
    innerpuz = Program.to(1)
    singleton_full_puzzle = singleton_puzzle(launcher_id, LAUNCHER_PUZZLE_HASH, innerpuz)
    p2_singleton_coin_id = Program.to(['test_hash']).get_tree_hash()
    expected_announcement = Announcement(singleton_full_puzzle.get_tree_hash(), p2_singleton_coin_id).name()
    p2_singleton_full = p2_singleton_puzzle(launcher_id, LAUNCHER_PUZZLE_HASH)
    solution = Program.to([innerpuz.get_tree_hash(), p2_singleton_coin_id])
    (cost, result) = p2_singleton_full.run_with_cost(INFINITE_COST, solution)
    (err, conditions) = parse_sexp_to_conditions(result)
    assert (err is None)
    p2_singleton_full = p2_singleton_puzzle(launcher_id, LAUNCHER_PUZZLE_HASH)
    solution = Program.to([innerpuz.get_tree_hash(), p2_singleton_coin_id])
    (cost, result) = p2_singleton_full.run_with_cost(INFINITE_COST, solution)
    assert (result.first().rest().first().as_atom() == expected_announcement)
    assert (conditions[0].vars[0] == expected_announcement)