@pytest.mark.asyncio
async def test_generate_zero_val(self, two_wallet_nodes):
    num_blocks = 4
    (full_nodes, wallets) = two_wallet_nodes
    full_node_api = full_nodes[0]
    full_node_server = full_node_api.server
    (wallet_node, server_2) = wallets[0]
    (wallet_node_2, server_3) = wallets[1]
    wallet = wallet_node.wallet_state_manager.main_wallet
    wallet2 = wallet_node_2.wallet_state_manager.main_wallet
    ph = (await wallet.get_new_puzzlehash())
    (await server_2.start_client(PeerInfo('localhost', uint16(full_node_server._port)), None))
    (await server_3.start_client(PeerInfo('localhost', uint16(full_node_server._port)), None))
    for i in range(1, num_blocks):
        (await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(ph)))
    funds = sum([(calculate_pool_reward(uint32(i)) + calculate_base_farmer_reward(uint32(i))) for i in range(1, (num_blocks - 1))])
    (await time_out_assert(15, wallet.get_confirmed_balance, funds))
    cc_wallet: CCWallet = (await CCWallet.create_new_cc(wallet_node.wallet_state_manager, wallet, uint64(100)))
    (await asyncio.sleep(1))
    ph = (await wallet2.get_new_puzzlehash())
    for i in range(1, num_blocks):
        (await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(ph)))
    (await time_out_assert(15, cc_wallet.get_confirmed_balance, 100))
    (await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 100))
    assert (cc_wallet.cc_info.my_genesis_checker is not None)
    colour = cc_wallet.get_colour()
    cc_wallet_2: CCWallet = (await CCWallet.create_wallet_for_cc(wallet_node_2.wallet_state_manager, wallet2, colour))
    (await asyncio.sleep(1))
    assert (cc_wallet.cc_info.my_genesis_checker == cc_wallet_2.cc_info.my_genesis_checker)
    spend_bundle = (await cc_wallet_2.generate_zero_val_coin())
    (await asyncio.sleep(1))
    (await time_out_assert(15, tx_in_pool, True, full_node_api.full_node.mempool_manager, spend_bundle.name()))
    for i in range(1, num_blocks):
        (await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(ph)))

    async def unspent_count():
        unspent: List[WalletCoinRecord] = list((await cc_wallet_2.wallet_state_manager.get_spendable_coins_for_wallet(cc_wallet_2.id())))
        return len(unspent)
    (await time_out_assert(15, unspent_count, 1))
    unspent: List[WalletCoinRecord] = list((await cc_wallet_2.wallet_state_manager.get_spendable_coins_for_wallet(cc_wallet_2.id())))
    assert (unspent.pop().coin.amount == 0)
@pytest.mark.asyncio
async def test_generate_zero_val(self, two_wallet_nodes):
    num_blocks = 4
    (full_nodes, wallets) = two_wallet_nodes
    full_node_api = full_nodes[0]
    full_node_server = full_node_api.server
    (wallet_node, server_2) = wallets[0]
    (wallet_node_2, server_3) = wallets[1]
    wallet = wallet_node.wallet_state_manager.main_wallet
    wallet2 = wallet_node_2.wallet_state_manager.main_wallet
    ph = (await wallet.get_new_puzzlehash())
    (await server_2.start_client(PeerInfo('localhost', uint16(full_node_server._port)), None))
    (await server_3.start_client(PeerInfo('localhost', uint16(full_node_server._port)), None))
    for i in range(1, num_blocks):
        (await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(ph)))
    funds = sum([(calculate_pool_reward(uint32(i)) + calculate_base_farmer_reward(uint32(i))) for i in range(1, (num_blocks - 1))])
    (await time_out_assert(15, wallet.get_confirmed_balance, funds))
    cc_wallet: CCWallet = (await CCWallet.create_new_cc(wallet_node.wallet_state_manager, wallet, uint64(100)))
    (await asyncio.sleep(1))
    ph = (await wallet2.get_new_puzzlehash())
    for i in range(1, num_blocks):
        (await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(ph)))
    (await time_out_assert(15, cc_wallet.get_confirmed_balance, 100))
    (await time_out_assert(15, cc_wallet.get_unconfirmed_balance, 100))
    assert (cc_wallet.cc_info.my_genesis_checker is not None)
    colour = cc_wallet.get_colour()
    cc_wallet_2: CCWallet = (await CCWallet.create_wallet_for_cc(wallet_node_2.wallet_state_manager, wallet2, colour))
    (await asyncio.sleep(1))
    assert (cc_wallet.cc_info.my_genesis_checker == cc_wallet_2.cc_info.my_genesis_checker)
    spend_bundle = (await cc_wallet_2.generate_zero_val_coin())
    (await asyncio.sleep(1))
    (await time_out_assert(15, tx_in_pool, True, full_node_api.full_node.mempool_manager, spend_bundle.name()))
    for i in range(1, num_blocks):
        (await full_node_api.farm_new_transaction_block(FarmNewBlockProtocol(ph)))

    async def unspent_count():
        unspent: List[WalletCoinRecord] = list((await cc_wallet_2.wallet_state_manager.get_spendable_coins_for_wallet(cc_wallet_2.id())))
        return len(unspent)
    (await time_out_assert(15, unspent_count, 1))
    unspent: List[WalletCoinRecord] = list((await cc_wallet_2.wallet_state_manager.get_spendable_coins_for_wallet(cc_wallet_2.id())))
    assert (unspent.pop().coin.amount == 0)