Exemplo n.º 1
0
    def test_score(self):
        le = ULedger(0)
        t0 = UTransaction(mocksubject(0, 1), 0)
        t1 = UTransaction(mocksubject(1, 1), 0)
        t2 = UTransaction(mocksubject(2, 1), 0)
        t3 = UTransaction(mocksubject(2, 1), 1)

        le.add(t0)
        le.add(t1)
        le.add(t2)
        le.add(t3)

        le.recalculate()

        assert le.score == (1 / 2, 2 / 5)
Exemplo n.º 2
0
    def test_no_gold(self):
        le = ULedger(0)
        for i in range(0):
            t = UTransaction(mocksubject(-1), 0)
            le.add(t)

        assert le.recalculate() == (0.5, 0.5)
Exemplo n.º 3
0
    def test_recalculate_1(self):
        le = ULedger(0)
        t0 = UTransaction(mocksubject(0, 0), 0)
        t1 = UTransaction(mocksubject(1, 1), 0)
        t2 = UTransaction(mocksubject(2, 1), 0)

        le.add(t0)
        le.add(t1)
        le.add(t2)

        assert le.recalculate() == (2 / 3, 1 / 4)
Exemplo n.º 4
0
    def test_recalculate_gamma(self):
        le = ULedger(0)
        t = [
            (0, 1, 0),
            (1, 1, 0),
            (2, 1, 0),
            (3, 1, 1),
            (4, 0, 0),
            (5, 0, 0),
            (6, 0, 0),
            (7, 0, 0),
        ]

        _ = [le.add(UTransaction(mocksubject(i, g), a)) for i, g, a in t]

        assert le.recalculate() == (9 / 14, 6 / 14)