def test_get_all_bidders(self, client, master_node): """Tests that we can get all the bids in the price auction""" # Add leptons lepton_hash = hashlib.sha1('hello world 1'.encode('utf8')).hexdigest() master_node.add_lepton(lepton_hash, None, 1.5123456789123456789) # client 1 buys and provisions tokens client.buy_eth_worth_of_tokens(2) client.provision(16000) assert client.get_all_bidders() == [] # client 1 leases the blockchain lease_prc = 1000 client.lease_all(lease_prc, 1) assert client.get_all_bidders() == [ {'address': '0xA1C2684B68A98c9636FC22F3B4E4332eF35A2408', 'limit_price': lease_prc, 'requested_seats': 1}] assert client.get_all_bidders(active=True) == [ {'address': '0xA1C2684B68A98c9636FC22F3B4E4332eF35A2408', 'limit_price': lease_prc, 'requested_seats': 1}] # Add another bidder leases the blockchain client2 = DeviseClient(private_key=TEST_KEYS[2]) client2.buy_eth_worth_of_tokens(2) client2.provision(16000) client2.lease_all(lease_prc + 1, 1) assert client.get_all_bidders(active=True) == [ {'address': client.w3.eth.accounts[2], 'limit_price': lease_prc + 1, 'requested_seats': 1}, {'address': '0xA1C2684B68A98c9636FC22F3B4E4332eF35A2408', 'limit_price': lease_prc, 'requested_seats': 1}] # client 2 escrow balances drops below bid price, no longer active client2.withdraw(client2.dvz_balance_escrow) assert client.get_all_bidders(active=True) == [ {'address': '0xA1C2684B68A98c9636FC22F3B4E4332eF35A2408', 'limit_price': lease_prc, 'requested_seats': 1}]
def test_client_call_only(self, client): blank_client = DeviseClient() assert blank_client.price_per_bit_current_term == client.price_per_bit_current_term assert blank_client.rent_per_seat_current_term == client.rent_per_seat_current_term assert blank_client.indicative_rent_per_seat_next_term == client.indicative_rent_per_seat_next_term assert blank_client.total_incremental_usefulness == client.total_incremental_usefulness with raises(AssertionError): blank_client.provision(1000)