コード例 #1
0
def propagate_message(tag):

        client = Client(device_type='test_device',
                        device_name='test',
                        encrypt=False,
                        reuse_address=False,
                        iota_node="http://localhost:14700",
                        route_pow=False)

        transactions = client.get_transactions(tags=[tag], count=1)
        data = client.get_transaction_data(transactions[0])
        time = client.post_to_tangle(data=data, address_level=1)
        return client.tag, data, time
コード例 #2
0
def test_mwm(number_of_transactions, mwm):

    # Create a client object
    client = Client(device_type='test_device',
                    seed='',
                    device_name='test',
                    reuse_address=False,
                    iota_node="http://localhost:14700",
                    route_pow=False)

    results = []
    for _ in range(0, number_of_transactions):
        tx_time = client.post_to_tangle(data='', mwm=mwm)
        results.append(tx_time)
    average = sum(results) / number_of_transactions
    return average
コード例 #3
0
def test_setup(number_of_devices):

    # Variable to store total time
    total_time = 0

    for _ in range(0, number_of_devices):
        # Setting up a client device
        client = Client(device_type='test_device',
                        seed='',
                        device_name='test',
                        iota_node="http://localhost:14700",
                        route_pow=False)

        # Send a zero value transaction to attach address to tangle
        time = client.post_to_tangle(data='')

        # Add found time to total time
        total_time += time
    return total_time
コード例 #4
0
def test_latency(number_of_devices, message_size, mwm):

    total_time = 0

    client = Client(device_type='test_device',
                    device_name='test',
                    encrypt=False,
                    reuse_address=False,
                    iota_node="http://localhost:14700",
                    route_pow=False)

    data = ''.join(random.choice(string.ascii_uppercase) for _ in range(message_size))

    t = client.post_to_tangle(data=data, address_level=1, verbose=True, mwm=mwm)

    tag = client.tag

    for _ in range(0, number_of_devices):
        total_time += t
        tag, data, t = propagate_message(tag)
    return total_time
コード例 #5
0
def test_reuse(number_of_transactions, average_over, reuse):

    # Stores results
    results = []

    # Create a client object
    client = Client(device_type='test_device',
                    seed='',
                    device_name='test',
                    reuse_address=reuse,
                    iota_node="http://localhost:14700",
                    route_pow=False)

    # Get results
    for i in range(0, number_of_transactions):
        times = []
        for j in range(0, average_over):
            time = client.post_to_tangle(data='')
            times.append(time)
        avg = sum(times) / average_over
        results.append(avg)
    return results
コード例 #6
0
def transaction_test(number_of_txs, wait):

    # List to store times
    times = []

    for _ in range(0, number_of_txs):

        client = Client(device_type='test_device',
                        seed='',
                        device_name='test',
                        iota_node="http://localhost:14700",
                        route_pow=False)

        # Send a zero value transaction to attach address to tangle
        t = client.post_to_tangle(data='')

        # Add found time to total time
        times.append(t)

        # Wait time
        time.sleep(wait)

    return times