Here are the examples of the python api test_validator_registry_view.mocks.MockStateView taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
5 Examples
3
Source : tests.py
with Apache License 2.0
from hyperledger
with Apache License 2.0
from hyperledger
def test_get_validator_info_not_exists(self):
"""Given a state view that does not contain a state view for a given
validator info, verify that it throws a key error on `get`.
"""
state_view = MockStateView({})
validator_registry_view = ValidatorRegistryView(state_view)
with self.assertRaises(KeyError):
validator_registry_view.get_validator_info('my_id')
def test_has_validator_info(self):
3
Source : tests.py
with Apache License 2.0
from hyperledger
with Apache License 2.0
from hyperledger
def test_has_validator_info_not_exists(self):
"""Given a state view that does not contain a state view for a given
validator info, verify that has_validator_info returns False with an
unkown id.
"""
state_view = MockStateView({})
validator_registry_view = ValidatorRegistryView(state_view)
self.assertFalse(validator_registry_view.has_validator_info('my_id'))
def test_get_validators(self):
0
Source : tests.py
with Apache License 2.0
from hyperledger
with Apache License 2.0
from hyperledger
def test_get_validator_info(self):
"""Given a state view that contains a state entry for a given validator
info, verify that the validator registry returns a ValidatorInfo when
get_validator_info is called with the validator's id."""
state_view = MockStateView({
to_address('my_id'): ValidatorInfo(
name='my_validator',
id='my_id',
signup_info=SignUpInfo(poet_public_key='my_public_key',
proof_data='beleive me',
anti_sybil_id='no sybil'),
transaction_id="signature"
).SerializeToString()
})
validator_registry_view = ValidatorRegistryView(state_view)
info = validator_registry_view.get_validator_info('my_id')
self.assertEqual('my_id', info.id)
self.assertEqual('my_validator', info.name)
self.assertEqual("signature", info.transaction_id)
self.assertEqual('my_public_key', info.signup_info.poet_public_key)
self.assertEqual('beleive me', info.signup_info.proof_data)
self.assertEqual('no sybil', info.signup_info.anti_sybil_id)
def test_get_validator_info_not_exists(self):
0
Source : tests.py
with Apache License 2.0
from hyperledger
with Apache License 2.0
from hyperledger
def test_has_validator_info(self):
"""Given a state view that contains a state entry for a given validator
info, verify that the validator registry returns a true when
has_validator_info is called with the validator's id."""
state_view = MockStateView({
to_address('my_id'): ValidatorInfo(
name='my_validator',
id='my_id',
signup_info=SignUpInfo(poet_public_key='my_public_key',
proof_data='beleive me',
anti_sybil_id='no sybil'),
transaction_id="signature"
).SerializeToString()
})
validator_registry_view = ValidatorRegistryView(state_view)
self.assertTrue(validator_registry_view.has_validator_info('my_id'))
def test_has_validator_info_not_exists(self):
0
Source : tests.py
with Apache License 2.0
from hyperledger
with Apache License 2.0
from hyperledger
def test_get_validators(self):
"""Given a state view with multiple validators, and the 'validator_map'
entry, verify that get_validators returns the list of just
ValidatorInfo instances.
"""
state_view = MockStateView({
to_address('validator_map'): b'this should be ignored',
to_address('my_id'): ValidatorInfo(
name='my_validator',
id='my_id',
signup_info=SignUpInfo(poet_public_key='my_public_key',
proof_data='beleive me',
anti_sybil_id='no sybil'),
transaction_id="signature"
).SerializeToString(),
to_address('another_id'): ValidatorInfo(
name='your_validator',
id='another_id',
signup_info=SignUpInfo(poet_public_key='your_public_key',
proof_data='you betcha',
anti_sybil_id='poor sybil'),
transaction_id="signature"
).SerializeToString()
})
validator_registry_view = ValidatorRegistryView(state_view)
infos = validator_registry_view.get_validators()
self.assertEqual(2, len(infos))
self.assertEqual('my_validator', infos['my_id'].name)
self.assertEqual('your_validator', infos['another_id'].name)