コード例 #1
0
    def initialize_api(self, node, seed):
        if node is None:
            if self.testnet:
                node = 'https://nodes.comnet.thetangle.org:443'
            else:
                node = 'https://nodes.thetangle.org:443'

        async_api = AsyncIota(adapter=node, seed=seed, devnet=self.testnet)
        return async_api
コード例 #2
0
    async def test_wireup_async(self):
        """
    Verify that the command is wired up correctly. (async)

    The API method indeed calls the appropiate command.
    """
        with patch('iota.commands.core.get_tips.GetTipsCommand.__call__',
                   MagicMock(return_value=async_return(
                       'You found me!'))) as mocked_command:

            api = AsyncIota(self.adapter)

            response = await api.get_tips()

            self.assertTrue(mocked_command.called)

            self.assertEqual(response, 'You found me!')
コード例 #3
0
    async def test_wireup_async(self):
        """
        Verify that the command is wired up correctly. (async)

        The API method indeed calls the appropiate command.
        """
        with patch(
                'iota.commands.core.were_addresses_spent_from.WereAddressesSpentFromCommand.__call__',
                MagicMock(return_value=async_return(
                    'You found me!'))) as mocked_command:

            api = AsyncIota(self.adapter)

            response = await api.were_addresses_spent_from('addresses')

            self.assertTrue(mocked_command.called)

            self.assertEqual(response, 'You found me!')
コード例 #4
0
    async def test_wireup_async(self):
        """
    Verify that the command is wired up correctly. (async)

    The API method indeed calls the appropiate command.
    """
        with patch(
                'iota.commands.core.attach_to_tangle.AttachToTangleCommand.__call__',
                MagicMock(return_value=async_return(
                    'You found me!'))) as mocked_command:

            api = AsyncIota(self.adapter)

            response = await api.attach_to_tangle('trunk', 'branch', 'trytes')

            self.assertTrue(mocked_command.called)

            self.assertEqual(response, 'You found me!')
コード例 #5
0
    async def test_wireup_async(self):
        """
    Verify that the command is wired up correctly. (async)

    The API method indeed calls the appropiate command.
    """
        with patch(
                'iota.commands.extended.get_account_data.GetAccountDataCommand.__call__',
                MagicMock(return_value=async_return(
                    'You found me!'))) as mocked_command:

            api = AsyncIota(self.adapter)

            # Don't need to call with proper args here.
            response = await api.get_account_data()

            self.assertTrue(mocked_command.called)

            self.assertEqual(response, 'You found me!')
コード例 #6
0
from iota import AsyncIota, ProposedTransaction, Address, TryteString
from typing import List
import asyncio
import json

with open('config.json', 'r') as f:
    data = json.load(f)
    url = data['url']


# Asynchronous API instance.
api = AsyncIota(
        adapter=url,
        devnet=True,
)

# An arbitrary address to send zero-value transactions to.
addy = Address('PZITJTHCIIANKQWEBWXUPHWPWVNBKW9GMNALMGGSIAUOYCKNWDLUUIGAVMJYCHZXHUBRIVPLFZHUVDLME')

# Timeout after which confirmation monitoring stops (seconds).
timeout = 120
# How often should we poll for confirmation? (seconds)
polling_interval = 5


async def send_and_monitor(
    transactions: List[ProposedTransaction]
) -> bool:
    """
    Send a list of transactions as a bundle and monitor their confirmation
    by the network.