def test_LockSet():
    ls = LockSet(num_eligible_votes=len(privkeys))
    assert not ls
    assert len(ls) == 0

    bh = '0' * 32
    r, h = 2, 3
    v1 = VoteBlock(h, r, bh)

    # add not signed
    with pytest.raises(InvalidVoteError):
        ls.add(v1)
    assert not ls
    assert v1 not in ls

    # add signed
    v1.sign(privkeys[0])
    ls.add(v1)

    assert ls
    assert len(ls) == 1
    lsh = ls.hash
    ls.add(v1)
    assert lsh == ls.hash
    assert len(ls) == 1

    # second vote same sender
    v2 = VoteBlock(h, r, bh)
    v2.sign(privkeys[0])
    ls.add(v1)
    ls.add(v2)
    assert lsh == ls.hash
    assert len(ls) == 1

    # third vote
    v3 = VoteBlock(h, r, bh)
    v3.sign(privkeys[1])
    ls.add(v1)
    ls.add(v3)
    assert lsh != ls.hash
    assert len(ls) == 2
    assert v3 in ls

    lsh = ls.hash

    # vote wrong round
    v4 = VoteBlock(h, r + 1, bh)
    v4.sign(privkeys[2])
    with pytest.raises(InvalidVoteError):
        ls.add(v4)
    assert lsh == ls.hash
    assert len(ls) == 2
    assert v4 not in ls

    # vote twice
    v3_2 = VoteBlock(h, r, blockhash='1' * 32)
    v3_2.sign(privkeys[1])
    with pytest.raises(DoubleVotingError):
        ls.add(v3_2)
    assert lsh == ls.hash
    assert len(ls) == 2
    assert ls not in v3_2
dataset/ETHPy150Open HydraChain/hydrachain/hydrachain/tests/test_base.py/test_LockSet/swapped operands of `not in`