def test_transaction_is_affordable_agent_is_buyer(self):
     """Check if the agent has the money to cover the sender_amount (the agent=sender is the buyer)."""
     currency_endowment = {"FET": 100}
     good_endowment = {"good_id": 20}
     ownership_state = OwnershipState()
     ownership_state.set(
         amount_by_currency_id=currency_endowment,
         quantities_by_good_id=good_endowment,
     )
     assert ownership_state.is_affordable(
         terms=self.buyer_terms
     ), "We should have the money for the transaction!"
def test_is_affordable_for_uninitialized():
    """Test the initialisation of the ownership_state."""
    ownership_state = OwnershipState()
    buyer_terms = Terms(
        ledger_id=ETHEREUM,
        sender_address="pk1",
        counterparty_address="pk2",
        amount_by_currency_id={"FET": -1},
        is_sender_payable_tx_fee=True,
        quantities_by_good_id={"good_id": 10},
        nonce="transaction nonce",
    )
    assert ownership_state.is_affordable(
        terms=buyer_terms), "Any transaction should be classed as affordable."