def testOCEAN(): w = AgentWallet() w.depositOCEAN(13.25) assert w.OCEAN() == 13.25 w.depositOCEAN(1.00) assert w.OCEAN() == 14.25 w.withdrawOCEAN(2.10) assert w.OCEAN() == 12.15 w.depositOCEAN(0.0) w.withdrawOCEAN(0.0) assert w.OCEAN() == 12.15 assert w.totalOCEANin() == (13.25 + 1.0) with pytest.raises(AssertionError): w.depositOCEAN(-5.0) with pytest.raises(AssertionError): w.withdrawOCEAN(-5.0) with pytest.raises(ValueError): w.withdrawOCEAN(1000.0)
def testFloatingPointRoundoff_OCEAN(): w = AgentWallet(OCEAN=2.4) w.withdrawOCEAN(2.4000000000000004) #should not get ValueError assert w.USD() == 0.0 assert w.OCEAN() == 0.0