mirror of
https://github.com/planetmint/planetmint.git
synced 2025-10-14 00:59:17 +00:00
Merge pull request #14 from planetmint/eckelj/define_chardet
defined explicit chardet version
This commit is contained in:
commit
3960b42936
@ -205,7 +205,7 @@ def _fulfillment_from_details(data, _depth=0):
|
|||||||
if data['type'] == 'threshold-sha-256':
|
if data['type'] == 'threshold-sha-256':
|
||||||
threshold = ThresholdSha256(data['threshold'])
|
threshold = ThresholdSha256(data['threshold'])
|
||||||
for cond in data['subconditions']:
|
for cond in data['subconditions']:
|
||||||
cond = _fulfillment_from_details(cond, _depth+1)
|
cond = _fulfillment_from_details(cond, _depth + 1)
|
||||||
threshold.add_subfulfillment(cond)
|
threshold.add_subfulfillment(cond)
|
||||||
return threshold
|
return threshold
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ def map_leafs(func, mapping):
|
|||||||
if isinstance(val, collections.abc.Mapping):
|
if isinstance(val, collections.abc.Mapping):
|
||||||
_inner(val, path + [key])
|
_inner(val, path + [key])
|
||||||
else:
|
else:
|
||||||
mapping[key] = func(val, path=path+[key])
|
mapping[key] = func(val, path=path + [key])
|
||||||
|
|
||||||
return mapping
|
return mapping
|
||||||
|
|
||||||
|
@ -209,8 +209,8 @@ class Election(Transaction):
|
|||||||
votes_current = self.count_votes(election_pk, current_votes)
|
votes_current = self.count_votes(election_pk, current_votes)
|
||||||
|
|
||||||
total_votes = sum(output.amount for output in self.outputs)
|
total_votes = sum(output.amount for output in self.outputs)
|
||||||
if (votes_committed < (2/3) * total_votes) and \
|
if (votes_committed < (2 / 3) * total_votes) and \
|
||||||
(votes_committed + votes_current >= (2/3)*total_votes):
|
(votes_committed + votes_current >= (2 / 3) * total_votes):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -40,7 +40,7 @@ DEFAULT_LOGGING_CONFIG = {
|
|||||||
'class': 'logging.handlers.RotatingFileHandler',
|
'class': 'logging.handlers.RotatingFileHandler',
|
||||||
'filename': os.path.join(DEFAULT_LOG_DIR, 'planetmint.log'),
|
'filename': os.path.join(DEFAULT_LOG_DIR, 'planetmint.log'),
|
||||||
'mode': 'w',
|
'mode': 'w',
|
||||||
'maxBytes': 209715200,
|
'maxBytes': 209715200,
|
||||||
'backupCount': 5,
|
'backupCount': 5,
|
||||||
'formatter': 'file',
|
'formatter': 'file',
|
||||||
'level': logging.INFO,
|
'level': logging.INFO,
|
||||||
@ -49,7 +49,7 @@ DEFAULT_LOGGING_CONFIG = {
|
|||||||
'class': 'logging.handlers.RotatingFileHandler',
|
'class': 'logging.handlers.RotatingFileHandler',
|
||||||
'filename': os.path.join(DEFAULT_LOG_DIR, 'planetmint-errors.log'),
|
'filename': os.path.join(DEFAULT_LOG_DIR, 'planetmint-errors.log'),
|
||||||
'mode': 'w',
|
'mode': 'w',
|
||||||
'maxBytes': 209715200,
|
'maxBytes': 209715200,
|
||||||
'backupCount': 5,
|
'backupCount': 5,
|
||||||
'formatter': 'file',
|
'formatter': 'file',
|
||||||
'level': logging.ERROR,
|
'level': logging.ERROR,
|
||||||
|
@ -66,8 +66,8 @@ def merkleroot(hashes):
|
|||||||
if len(hashes) % 2 == 1:
|
if len(hashes) % 2 == 1:
|
||||||
hashes.append(hashes[-1])
|
hashes.append(hashes[-1])
|
||||||
parent_hashes = [
|
parent_hashes = [
|
||||||
sha3_256(hashes[i] + hashes[i+1]).digest()
|
sha3_256(hashes[i] + hashes[i + 1]).digest()
|
||||||
for i in range(0, len(hashes)-1, 2)
|
for i in range(0, len(hashes) - 1, 2)
|
||||||
]
|
]
|
||||||
return merkleroot(parent_hashes)
|
return merkleroot(parent_hashes)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class ValidatorElection(Election):
|
|||||||
super(ValidatorElection, self).validate(planet, current_transactions=current_transactions)
|
super(ValidatorElection, self).validate(planet, current_transactions=current_transactions)
|
||||||
|
|
||||||
# NOTE: change more than 1/3 of the current power is not allowed
|
# NOTE: change more than 1/3 of the current power is not allowed
|
||||||
if self.asset['data']['power'] >= (1/3)*sum(current_validators.values()):
|
if self.asset['data']['power'] >= (1 / 3) * sum(current_validators.values()):
|
||||||
raise InvalidPowerChange('`power` change must be less than 1/3 of total power')
|
raise InvalidPowerChange('`power` change must be less than 1/3 of total power')
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
1
setup.py
1
setup.py
@ -71,6 +71,7 @@ tests_require = [
|
|||||||
] + docs_require
|
] + docs_require
|
||||||
|
|
||||||
install_requires = [
|
install_requires = [
|
||||||
|
'chardet==3.0.4',
|
||||||
'aiohttp==3.7.4',
|
'aiohttp==3.7.4',
|
||||||
'bigchaindb-abci==1.0.7',
|
'bigchaindb-abci==1.0.7',
|
||||||
'cryptoconditions==0.8.1',
|
'cryptoconditions==0.8.1',
|
||||||
|
@ -321,7 +321,7 @@ def inputs(user_pk, b, alice):
|
|||||||
for _ in range(10)
|
for _ in range(10)
|
||||||
]
|
]
|
||||||
tx_ids = [tx.id for tx in transactions]
|
tx_ids = [tx.id for tx in transactions]
|
||||||
block = Block(app_hash='hash'+str(height), height=height, transactions=tx_ids)
|
block = Block(app_hash='hash' + str(height), height=height, transactions=tx_ids)
|
||||||
b.store_block(block._asdict())
|
b.store_block(block._asdict())
|
||||||
b.store_bulk_transactions(transactions)
|
b.store_bulk_transactions(transactions)
|
||||||
|
|
||||||
|
@ -497,7 +497,7 @@ def test_new_validator_set(b):
|
|||||||
for u in updates:
|
for u in updates:
|
||||||
updated_validators.append({'public_key': {'type': 'ed25519-base64',
|
updated_validators.append({'public_key': {'type': 'ed25519-base64',
|
||||||
'value': public_key_to_base64(u['public_key']['value'])},
|
'value': public_key_to_base64(u['public_key']['value'])},
|
||||||
'voting_power': u['power']})
|
'voting_power': u['power']})
|
||||||
|
|
||||||
assert updated_validator_set == updated_validators
|
assert updated_validator_set == updated_validators
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ def test_upsert_validator_delegate_election_vote(b_mock, valid_upsert_validator_
|
|||||||
key0 = ed25519_node_keys[public_key0]
|
key0 = ed25519_node_keys[public_key0]
|
||||||
|
|
||||||
delegate_vote = Vote.generate([input0],
|
delegate_vote = Vote.generate([input0],
|
||||||
[([alice.public_key], 3), ([key0.public_key], votes-3)],
|
[([alice.public_key], 3), ([key0.public_key], votes - 3)],
|
||||||
election_id=valid_upsert_validator_election.id)\
|
election_id=valid_upsert_validator_election.id)\
|
||||||
.sign([key0.private_key])
|
.sign([key0.private_key])
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ def test_upsert_validator_delegate_election_vote(b_mock, valid_upsert_validator_
|
|||||||
|
|
||||||
key0_votes = delegate_vote.to_inputs()[1]
|
key0_votes = delegate_vote.to_inputs()[1]
|
||||||
key0_casted_vote = Vote.generate([key0_votes],
|
key0_casted_vote = Vote.generate([key0_votes],
|
||||||
[([election_pub_key], votes-3)],
|
[([election_pub_key], votes - 3)],
|
||||||
election_id=valid_upsert_validator_election.id)\
|
election_id=valid_upsert_validator_election.id)\
|
||||||
.sign([key0.private_key])
|
.sign([key0.private_key])
|
||||||
assert key0_casted_vote.validate(b_mock)
|
assert key0_casted_vote.validate(b_mock)
|
||||||
@ -104,7 +104,7 @@ def test_upsert_validator_invalid_election_vote(b_mock, valid_upsert_validator_e
|
|||||||
election_pub_key = ValidatorElection.to_public_key(valid_upsert_validator_election.id)
|
election_pub_key = ValidatorElection.to_public_key(valid_upsert_validator_election.id)
|
||||||
|
|
||||||
vote = Vote.generate([input0],
|
vote = Vote.generate([input0],
|
||||||
[([election_pub_key], votes+1)],
|
[([election_pub_key], votes + 1)],
|
||||||
election_id=valid_upsert_validator_election.id)\
|
election_id=valid_upsert_validator_election.id)\
|
||||||
.sign([key0.private_key])
|
.sign([key0.private_key])
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ def test_valid_election_votes_received(b_mock, valid_upsert_validator_election,
|
|||||||
|
|
||||||
# delegate some votes to alice
|
# delegate some votes to alice
|
||||||
delegate_vote = Vote.generate([input0],
|
delegate_vote = Vote.generate([input0],
|
||||||
[([alice.public_key], 4), ([key0.public_key], votes-4)],
|
[([alice.public_key], 4), ([key0.public_key], votes - 4)],
|
||||||
election_id=valid_upsert_validator_election.id)\
|
election_id=valid_upsert_validator_election.id)\
|
||||||
.sign([key0.private_key])
|
.sign([key0.private_key])
|
||||||
b_mock.store_bulk_transactions([delegate_vote])
|
b_mock.store_bulk_transactions([delegate_vote])
|
||||||
@ -147,7 +147,7 @@ def test_valid_election_votes_received(b_mock, valid_upsert_validator_election,
|
|||||||
assert valid_upsert_validator_election.get_commited_votes(b_mock) == 2
|
assert valid_upsert_validator_election.get_commited_votes(b_mock) == 2
|
||||||
|
|
||||||
key0_casted_vote = Vote.generate([key0_votes],
|
key0_casted_vote = Vote.generate([key0_votes],
|
||||||
[([election_public_key], votes-4)],
|
[([election_public_key], votes - 4)],
|
||||||
election_id=valid_upsert_validator_election.id)\
|
election_id=valid_upsert_validator_election.id)\
|
||||||
.sign([key0.private_key])
|
.sign([key0.private_key])
|
||||||
|
|
||||||
|
@ -38,11 +38,13 @@ def test_eventify_block_works_with_any_transaction():
|
|||||||
block = {'height': 1,
|
block = {'height': 1,
|
||||||
'transactions': [tx, tx_transfer]}
|
'transactions': [tx, tx_transfer]}
|
||||||
|
|
||||||
expected_events = [{
|
expected_events = [
|
||||||
|
{
|
||||||
'height': 1,
|
'height': 1,
|
||||||
'asset_id': tx.id,
|
'asset_id': tx.id,
|
||||||
'transaction_id': tx.id
|
'transaction_id': tx.id
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
'height': 1,
|
'height': 1,
|
||||||
'asset_id': tx_transfer.asset['id'],
|
'asset_id': tx_transfer.asset['id'],
|
||||||
'transaction_id': tx_transfer.id
|
'transaction_id': tx_transfer.id
|
||||||
|
3
tox.ini
3
tox.ini
@ -24,6 +24,9 @@ skip_install = True
|
|||||||
extras = None
|
extras = None
|
||||||
commands = flake8 planetmint tests
|
commands = flake8 planetmint tests
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
ignore = E126 E127 W504 E302 E126 E305
|
||||||
|
|
||||||
[testenv:docsroot]
|
[testenv:docsroot]
|
||||||
basepython = {[base]basepython}
|
basepython = {[base]basepython}
|
||||||
changedir = docs/root/source
|
changedir = docs/root/source
|
||||||
|
Loading…
x
Reference in New Issue
Block a user