Example #1
0
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)
Example #2
0
def test_transferOCEAN():
    w1 = AgentWallet(OCEAN=10.0)
    w2 = AgentWallet(OCEAN=1.0)

    w1.transferOCEAN(w2, 2.0)

    assert w1.OCEAN() == (10.0 - 2.0)
    assert w2.OCEAN() == (1.0 + 2.0)
Example #3
0
def testFloatingPointRoundoff_USD():
    w = AgentWallet(USD=2.4)
    w.withdrawUSD(2.4000000000000004)  #should not get ValueError
    assert w.USD() == 0.0
    assert w.OCEAN() == 0.0
Example #4
0
def testInitiallyFilled():
    w = AgentWallet(USD=1.2, OCEAN=3.4)

    assert w.USD() == 1.2
    assert w.OCEAN() == 3.4
Example #5
0
def testInitiallyEmpty():
    w = AgentWallet()

    assert w.USD() == 0.0
    assert w.OCEAN() == 0.0