Пример #1
0
def test_non_equality_of_copies_off_genesis(empty_just):
    validator_0 = Validator("v0", 10)
    validator_1 = Validator("v1", 11)

    block_0 = Block(None, empty_just, validator_0, 0, 0)
    block_1 = Block(None, empty_just, validator_1, 0, 0)

    assert block_0 != block_1
Пример #2
0
def test_non_equality_of_copies_off_genesis():
    validator_0 = Validator("v0", 10)
    validator_1 = Validator("v1", 11)

    block_0 = Block(None, Justification(), validator_0)
    block_1 = Block(None, Justification(), validator_1)

    assert block_0 != block_1
Пример #3
0
def test_non_equality_of_copies_off_genesis():
    validator_0 = Validator("v0", 10)
    validator_1 = Validator("v1", 11)

    message_0 = Message(None, Justification(), validator_0)
    message_1 = Message(None, Justification(), validator_1)

    assert message_0 != message_1
Пример #4
0
def test_is_in_blockchain__separate_genesis(empty_just):
    validator_0 = Validator("v0", 10)
    validator_1 = Validator("v1", 11)

    block_0 = Block(None, empty_just, validator_0, 0, 0)
    block_1 = Block(None, empty_just, validator_1, 0, 0)

    assert not block_0.is_in_blockchain(block_1)
    assert not block_1.is_in_blockchain(block_0)
Пример #5
0
def test_new_validator(name, weight, error):
    if isinstance(error, type) and issubclass(error, Exception):
        with pytest.raises(error):
            Validator(name, weight)
        return

    validator = Validator(name, weight)
    assert validator.name == name
    assert validator.weight == weight
Пример #6
0
def test_is_in_blockchain__separate_genesis():
    validator_0 = Validator("v0", 10)
    validator_1 = Validator("v1", 11)

    block_0 = Block(None, Justification(), validator_0)
    block_1 = Block(None, Justification(), validator_1)

    assert not block_0.is_in_blockchain(block_1)
    assert not block_1.is_in_blockchain(block_0)
Пример #7
0
 def __init__(self, weights, protocol=BlockchainProtocol):
     self.validators = {
         Validator(name, weights[name], protocol, self)
         for name in weights
     }
Пример #8
0
def test_validator_created_with_inital_message(rand_start_protocol):
    validator = Validator(0, 1, rand_start_protocol)
    assert validator.my_latest_message() is not None
Пример #9
0
def test_validator_created_with_genesis(genesis_protocol):
    validator = Validator(0, 1, genesis_protocol)
    assert validator.view.last_finalized_block is not None
Пример #10
0
def validator():
    return Validator("Name", 15.5)
Пример #11
0
def test_check_estimate_safety_without_validator_set():
    validator = Validator("cool", 10.2)
    block = Block(None, Justification(), validator)

    with pytest.raises(AttributeError):
        validator.check_estimate_safety(block)
Пример #12
0
def test_validator_saves_initial_message(view, message):
    validator = Validator(0, 1, None, view, message)
    validator.initialize_view(set())
    assert validator.view is not None
Пример #13
0
def test_validator_not_created_with_view(view, message):
    validator = Validator(0, 1, None, view, message)
    assert validator.view is None