furhter fixes

This commit is contained in:
Jürgen Eckel 2022-02-03 00:08:07 +01:00
parent b9c96f4029
commit fda40ded09
6 changed files with 18 additions and 16 deletions

View File

@ -58,7 +58,7 @@ class App(BaseApplication):
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)
logger.debug('Checking values of types')
logger.debug(dir(types_pb2))
@ -70,6 +70,7 @@ class App(BaseApplication):
self.validators = None
self.new_height = None
self.chain = self.planetmint_node.get_latest_abci_chain()
def log_abci_migration_error(self, chain_id, validators):
logger.error('An ABCI chain migration is in process. '
@ -167,7 +168,7 @@ class App(BaseApplication):
transaction = decode_transaction(raw_transaction)
if self.planetmint_node.is_valid_transaction(transaction):
logger.debug('check_tx: VALID')
return ResponseCheckTx(code=CodeTypeOk)
return ResponseCheckTx(code=OkCode)
else:
logger.debug('check_tx: INVALID')
return ResponseCheckTx(code=CodeTypeError)
@ -209,7 +210,7 @@ class App(BaseApplication):
logger.debug('storing tx')
self.block_txn_ids.append(transaction.id)
self.block_transactions.append(transaction)
return ResponseDeliverTx(code=CodeTypeOk)
return ResponseDeliverTx(code=OkCode)
def end_block(self, request_end_block):
"""Calculate block hash using transaction ids and previous block
@ -241,7 +242,7 @@ class App(BaseApplication):
else:
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.block_transactions)

View File

@ -128,7 +128,7 @@ class ValidationWorker:
except KeyError:
asset_id = dict_transaction['id']
transaction = self.planetmint_node.is_valid_transaction(
transaction = self.planetmint.is_valid_transaction(
dict_transaction,
self.validated_transactions[asset_id])

View File

@ -446,7 +446,7 @@ def abci_server():
from planetmint.core import App
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)
yield abci_proxy.start()
abci_proxy.terminate()

View File

@ -247,8 +247,9 @@ def test_deliver_tx__valid_create_updates_db_and_emits_event(a, b, init_chain_re
[([bob.public_key], 1)])\
.sign([alice.private_key])
app = App(a, b, events)
# app = App(b, a, events)
app = App(b, events)
app.init_chain(init_chain_request)
begin_block = types.RequestBeginBlock()
@ -376,7 +377,7 @@ def test_end_block_return_validator_updates(a, b, init_chain_request):
resp = app.end_block(types.RequestEndBlock(height=2))
assert resp.validator_updates[0].power == new_validator['election']['power']
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):

View File

@ -42,7 +42,7 @@ def test_app(a, b, init_chain_request):
assert block0['height'] == 0
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)
assert validator['public_key']['value'] == pk
assert validator['voting_power'] == 10

View File

@ -214,7 +214,7 @@ def test_check_tx__signed_create_is_ok(a, b):
app = App(b, a)
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):
@ -247,7 +247,7 @@ def test_deliver_tx__valid_create_updates_db_and_emits_event(a, b, init_chain_re
[([bob.public_key], 1)])\
.sign([alice.private_key])
app = App(a, b, events)
app = App( a, events)
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)
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.commit()
@ -290,7 +290,7 @@ def test_deliver_tx__double_spend_fails(a, b, init_chain_request):
app.begin_block(begin_block)
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.commit()
@ -325,7 +325,7 @@ def test_deliver_transfer_tx__double_spend_fails(a, b, init_chain_request):
.sign([alice.private_key])
result = app.deliver_tx(encode_tx_to_bytes(tx))
assert result.code == CodeTypeOk
assert result.code == OkCode
tx_transfer = Transaction.transfer(tx.to_inputs(),
[([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])
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(),
[([carly.public_key], 1)],