def test_committed(): r = PbftInstance(0, 4) request = (r._REQUEST, b"message", 10, b"100") prepr = (r._PREPREPARE, 0, 1, request, 0) p0 = (r._COMMIT, 0, 1, r.hash(request), 0) p1 = (r._COMMIT, 0, 1, r.hash(request), 1) p2 = (r._COMMIT, 0, 1, r.hash(request), 2) M = set([prepr, p0, p1, p2]) assert r.committed(request, 0, 1, M) M = set([p0, p1, p2]) assert not r.committed(request, 0, 1, M) M = set([request, p0, p1, p2]) assert r.committed(request, 0, 1, M) M = set([prepr, p0, p1]) assert not r.committed(request, 0, 1, M)
def test_proposed(): r = PbftInstance(0, 4) request = (r._REQUEST, b"message", 10, b"100") prepr = (r._PREPREPARE, 0, 1, request, 0) p1 = (r._PREPARE, 0, 1, r.hash(request), 1) M = set([prepr, p1]) assert not r.prepared(request, 0, 1, M) p2 = (r._PREPARE, 0, 1, r.hash(request), 2) M.add(p2) assert r.prepared(request, 0, 1, M) p3 = (r._PREPARE, 0, 1, r.hash(request), 3) M.add(p3) assert r.prepared(request, 0, 1, M) M = set([p1, p2, p3]) assert not r.prepared(request, 0, 1, M) p0 = (r._PREPARE, 0, 1, r.hash(request), 0) M = set([prepr, p0, p1]) assert not r.prepared(request, 0, 1, M)