mirror of
https://github.com/planetmint/planetmint.git
synced 2025-07-09 05:52:30 +00:00
furhter fixes
This commit is contained in:
parent
b9c96f4029
commit
fda40ded09
@ -58,7 +58,7 @@ class App(BaseApplication):
|
|||||||
transaction logic to Tendermint Core.
|
transaction logic to Tendermint Core.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, planetmint_node=None, events_queue=None,):
|
def __init__(self, planetmint_node=None, events_queue=None):
|
||||||
#super().__init__(abci)
|
#super().__init__(abci)
|
||||||
logger.debug('Checking values of types')
|
logger.debug('Checking values of types')
|
||||||
logger.debug(dir(types_pb2))
|
logger.debug(dir(types_pb2))
|
||||||
@ -71,6 +71,7 @@ class App(BaseApplication):
|
|||||||
self.new_height = None
|
self.new_height = None
|
||||||
self.chain = self.planetmint_node.get_latest_abci_chain()
|
self.chain = self.planetmint_node.get_latest_abci_chain()
|
||||||
|
|
||||||
|
|
||||||
def log_abci_migration_error(self, chain_id, validators):
|
def log_abci_migration_error(self, chain_id, validators):
|
||||||
logger.error('An ABCI chain migration is in process. '
|
logger.error('An ABCI chain migration is in process. '
|
||||||
'Download theself.planetmint_node.get_latest_abci_chain new ABCI client and configure it with '
|
'Download theself.planetmint_node.get_latest_abci_chain new ABCI client and configure it with '
|
||||||
@ -167,7 +168,7 @@ class App(BaseApplication):
|
|||||||
transaction = decode_transaction(raw_transaction)
|
transaction = decode_transaction(raw_transaction)
|
||||||
if self.planetmint_node.is_valid_transaction(transaction):
|
if self.planetmint_node.is_valid_transaction(transaction):
|
||||||
logger.debug('check_tx: VALID')
|
logger.debug('check_tx: VALID')
|
||||||
return ResponseCheckTx(code=CodeTypeOk)
|
return ResponseCheckTx(code=OkCode)
|
||||||
else:
|
else:
|
||||||
logger.debug('check_tx: INVALID')
|
logger.debug('check_tx: INVALID')
|
||||||
return ResponseCheckTx(code=CodeTypeError)
|
return ResponseCheckTx(code=CodeTypeError)
|
||||||
@ -209,7 +210,7 @@ class App(BaseApplication):
|
|||||||
logger.debug('storing tx')
|
logger.debug('storing tx')
|
||||||
self.block_txn_ids.append(transaction.id)
|
self.block_txn_ids.append(transaction.id)
|
||||||
self.block_transactions.append(transaction)
|
self.block_transactions.append(transaction)
|
||||||
return ResponseDeliverTx(code=CodeTypeOk)
|
return ResponseDeliverTx(code=OkCode)
|
||||||
|
|
||||||
def end_block(self, request_end_block):
|
def end_block(self, request_end_block):
|
||||||
"""Calculate block hash using transaction ids and previous block
|
"""Calculate block hash using transaction ids and previous block
|
||||||
@ -241,7 +242,7 @@ class App(BaseApplication):
|
|||||||
else:
|
else:
|
||||||
self.block_txn_hash = block['app_hash']
|
self.block_txn_hash = block['app_hash']
|
||||||
|
|
||||||
validator_update = Election.process_block(self.planetmint,
|
validator_update = Election.process_block(self.planetmint_node,
|
||||||
self.new_height,
|
self.new_height,
|
||||||
self.block_transactions)
|
self.block_transactions)
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class ValidationWorker:
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
asset_id = dict_transaction['id']
|
asset_id = dict_transaction['id']
|
||||||
|
|
||||||
transaction = self.planetmint_node.is_valid_transaction(
|
transaction = self.planetmint.is_valid_transaction(
|
||||||
dict_transaction,
|
dict_transaction,
|
||||||
self.validated_transactions[asset_id])
|
self.validated_transactions[asset_id])
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ def abci_server():
|
|||||||
from planetmint.core import App
|
from planetmint.core import App
|
||||||
from planetmint.utils import Process
|
from planetmint.utils import Process
|
||||||
|
|
||||||
app = ABCIServer(app=App(types_v0_34_11))
|
app = ABCIServer(app=App())
|
||||||
abci_proxy = Process(name='ABCI', target=app.run)
|
abci_proxy = Process(name='ABCI', target=app.run)
|
||||||
yield abci_proxy.start()
|
yield abci_proxy.start()
|
||||||
abci_proxy.terminate()
|
abci_proxy.terminate()
|
||||||
|
@ -247,7 +247,8 @@ def test_deliver_tx__valid_create_updates_db_and_emits_event(a, b, init_chain_re
|
|||||||
[([bob.public_key], 1)])\
|
[([bob.public_key], 1)])\
|
||||||
.sign([alice.private_key])
|
.sign([alice.private_key])
|
||||||
|
|
||||||
app = App(a, b, events)
|
# app = App(b, a, events)
|
||||||
|
app = App(b, events)
|
||||||
|
|
||||||
app.init_chain(init_chain_request)
|
app.init_chain(init_chain_request)
|
||||||
|
|
||||||
@ -376,7 +377,7 @@ def test_end_block_return_validator_updates(a, b, init_chain_request):
|
|||||||
resp = app.end_block(types.RequestEndBlock(height=2))
|
resp = app.end_block(types.RequestEndBlock(height=2))
|
||||||
assert resp.validator_updates[0].power == new_validator['election']['power']
|
assert resp.validator_updates[0].power == new_validator['election']['power']
|
||||||
expected = bytes.fromhex(new_validator['election']['public_key']['value'])
|
expected = bytes.fromhex(new_validator['election']['public_key']['value'])
|
||||||
assert expected == resp.validator_updates[0].pub_key.data
|
assert expected == resp.validator_updates[0].pub_key.ed25519
|
||||||
|
|
||||||
|
|
||||||
def test_store_pre_commit_state_in_end_block(a, b, alice, init_chain_request):
|
def test_store_pre_commit_state_in_end_block(a, b, alice, init_chain_request):
|
||||||
|
@ -42,7 +42,7 @@ def test_app(a, b, init_chain_request):
|
|||||||
assert block0['height'] == 0
|
assert block0['height'] == 0
|
||||||
assert block0['app_hash'] == ''
|
assert block0['app_hash'] == ''
|
||||||
|
|
||||||
pk = codecs.encode(init_chain_request.validators[0].pub_key.data, 'base64').decode().strip('\n')
|
pk = codecs.encode(init_chain_request.validators[0].pub_key.ed25519, 'base64').decode().strip('\n')
|
||||||
[validator] = b.get_validators(height=1)
|
[validator] = b.get_validators(height=1)
|
||||||
assert validator['public_key']['value'] == pk
|
assert validator['public_key']['value'] == pk
|
||||||
assert validator['voting_power'] == 10
|
assert validator['voting_power'] == 10
|
||||||
|
@ -214,7 +214,7 @@ def test_check_tx__signed_create_is_ok(a, b):
|
|||||||
|
|
||||||
app = App(b, a)
|
app = App(b, a)
|
||||||
result = app.check_tx(encode_tx_to_bytes(tx))
|
result = app.check_tx(encode_tx_to_bytes(tx))
|
||||||
assert result.code == CodeTypeOk
|
assert result.code == OkCode
|
||||||
|
|
||||||
|
|
||||||
def test_check_tx__unsigned_create_is_error(a, b):
|
def test_check_tx__unsigned_create_is_error(a, b):
|
||||||
@ -247,7 +247,7 @@ def test_deliver_tx__valid_create_updates_db_and_emits_event(a, b, init_chain_re
|
|||||||
[([bob.public_key], 1)])\
|
[([bob.public_key], 1)])\
|
||||||
.sign([alice.private_key])
|
.sign([alice.private_key])
|
||||||
|
|
||||||
app = App(a, b, events)
|
app = App( a, events)
|
||||||
|
|
||||||
app.init_chain(init_chain_request)
|
app.init_chain(init_chain_request)
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ def test_deliver_tx__valid_create_updates_db_and_emits_event(a, b, init_chain_re
|
|||||||
app.begin_block(begin_block)
|
app.begin_block(begin_block)
|
||||||
|
|
||||||
result = app.deliver_tx(encode_tx_to_bytes(tx))
|
result = app.deliver_tx(encode_tx_to_bytes(tx))
|
||||||
assert result.code == CodeTypeOk
|
assert result.code == OkCode
|
||||||
|
|
||||||
app.end_block(types.RequestEndBlock(height=99))
|
app.end_block(types.RequestEndBlock(height=99))
|
||||||
app.commit()
|
app.commit()
|
||||||
@ -290,7 +290,7 @@ def test_deliver_tx__double_spend_fails(a, b, init_chain_request):
|
|||||||
app.begin_block(begin_block)
|
app.begin_block(begin_block)
|
||||||
|
|
||||||
result = app.deliver_tx(encode_tx_to_bytes(tx))
|
result = app.deliver_tx(encode_tx_to_bytes(tx))
|
||||||
assert result.code == CodeTypeOk
|
assert result.code == OkCode
|
||||||
|
|
||||||
app.end_block(types.RequestEndBlock(height=99))
|
app.end_block(types.RequestEndBlock(height=99))
|
||||||
app.commit()
|
app.commit()
|
||||||
@ -325,7 +325,7 @@ def test_deliver_transfer_tx__double_spend_fails(a, b, init_chain_request):
|
|||||||
.sign([alice.private_key])
|
.sign([alice.private_key])
|
||||||
|
|
||||||
result = app.deliver_tx(encode_tx_to_bytes(tx))
|
result = app.deliver_tx(encode_tx_to_bytes(tx))
|
||||||
assert result.code == CodeTypeOk
|
assert result.code == OkCode
|
||||||
|
|
||||||
tx_transfer = Transaction.transfer(tx.to_inputs(),
|
tx_transfer = Transaction.transfer(tx.to_inputs(),
|
||||||
[([bob.public_key], 1)],
|
[([bob.public_key], 1)],
|
||||||
@ -333,7 +333,7 @@ def test_deliver_transfer_tx__double_spend_fails(a, b, init_chain_request):
|
|||||||
.sign([alice.private_key])
|
.sign([alice.private_key])
|
||||||
|
|
||||||
result = app.deliver_tx(encode_tx_to_bytes(tx_transfer))
|
result = app.deliver_tx(encode_tx_to_bytes(tx_transfer))
|
||||||
assert result.code == CodeTypeOk
|
assert result.code == OkCode
|
||||||
|
|
||||||
double_spend = Transaction.transfer(tx.to_inputs(),
|
double_spend = Transaction.transfer(tx.to_inputs(),
|
||||||
[([carly.public_key], 1)],
|
[([carly.public_key], 1)],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user