def test_loan_history(federation, bob, carol, spool_regtest, spider, transferred_edition_two_hashes, rpconn):
    from .conftest import reload_address
    edition_number = 2
    (loan_start, loan_end) = ('171017', '181018')
    piece_hash = transferred_edition_two_hashes[0]
    reload_address(bob, rpconn)
    txid = spool_regtest.loan(('', bob), carol, transferred_edition_two_hashes, b'bob-secret', 2, loan_start, loan_end, min_confirmations=1)
    rpconn.generate(1)
    history = spider.history(piece_hash)
    assert (len(history) == 3)
    assert ('' in history)
    assert (0 in history)
    assert (edition_number in history)
    assert (len(history['']) == 1)
    assert (len(history[0]) == 1)
    assert (len(history[edition_number]) == 3)
    loan_data = history[edition_number][2]
    assert (loan_data['action'] == 'LOAN')
    assert (loan_data['edition_number'] == edition_number)
    assert (loan_data['from_address'] == bob)
    assert (loan_data['number_editions'] == 3)
    assert (loan_data['piece_address'] == piece_hash)
    assert loan_data['timestamp_utc']
    assert (loan_data['to_address'] == carol)
    assert (loan_data['txid'] == txid)
    assert (loan_data['verb'] == b'ASCRIBESPOOL01LOAN2/171017181018')
def test_loan_history(federation, bob, carol, spool_regtest, spider, transferred_edition_two_hashes, rpconn):
    from .conftest import reload_address
    edition_number = 2
    (loan_start, loan_end) = ('171017', '181018')
    piece_hash = transferred_edition_two_hashes[0]
    reload_address(bob, rpconn)
    txid = spool_regtest.loan((, bob), carol, transferred_edition_two_hashes, b'bob-secret', 2, loan_start, loan_end, min_confirmations=1)
    rpconn.generate(1)
    history = spider.history(piece_hash)
    assert (len(history) == 3)
    assert ( in history)
    assert (0 in history)
    assert (edition_number in history)
    assert (len(history[]) == 1)
    assert (len(history[0]) == 1)
    assert (len(history[edition_number]) == 3)
    loan_data = history[edition_number][2]
    assert (loan_data['action'] == 'LOAN')
    assert (loan_data['edition_number'] == edition_number)
    assert (loan_data['from_address'] == bob)
    assert (loan_data['number_editions'] == 3)
    assert (loan_data['piece_address'] == piece_hash)
    assert loan_data['timestamp_utc']
    assert (loan_data['to_address'] == carol)
    assert (loan_data['txid'] == txid)
    assert (loan_data['verb'] == b'ASCRIBESPOOL01LOAN2/171017181018')