mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Panic when receive inconsistent data in InitChain.
This commit is contained in:
parent
7730719b3c
commit
b5fe2b15ce
@ -6,6 +6,7 @@
|
||||
with Tendermint.
|
||||
"""
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from abci.application import BaseApplication
|
||||
from abci.types_pb2 import (
|
||||
@ -63,14 +64,14 @@ class App(BaseApplication):
|
||||
'the chain {chain_id} is already synced.'
|
||||
|
||||
logger.error(msg)
|
||||
return ResponseInitChain()
|
||||
sys.exit(1)
|
||||
|
||||
if chain_id != genesis.chain_id:
|
||||
msg = f'Got mismatching chain ID in the InitChain ' + \
|
||||
'ABCI request - you need to migrate the ABCI client ' + \
|
||||
'and set new chain ID: {chain_id}.'
|
||||
logger.error(msg)
|
||||
return ResponseInitChain()
|
||||
sys.exit(1)
|
||||
|
||||
# set migration values for app hash and height
|
||||
block = self.bigchaindb.get_latest_block()
|
||||
@ -86,7 +87,7 @@ class App(BaseApplication):
|
||||
'ABCI request - you need to migrate the ABCI client ' + \
|
||||
'and set new validator set: {known_validators}.'
|
||||
logger.error(msg)
|
||||
return ResponseInitChain()
|
||||
sys.exit(1)
|
||||
|
||||
block = Block(app_hash=app_hash, height=height, transactions=[])
|
||||
self.bigchaindb.store_block(block._asdict())
|
||||
|
||||
@ -81,8 +81,8 @@ def test_init_chain_ignores_invalid_init_chain_requests(b):
|
||||
generate_init_chain_request('chain-ABC', validators),
|
||||
]
|
||||
for r in invalid_requests:
|
||||
res = App(b).init_chain(r)
|
||||
assert res == ResponseInitChain()
|
||||
with pytest.raises(SystemExit):
|
||||
App(b).init_chain(r)
|
||||
# assert nothing changed - neither validator set, nor chain ID
|
||||
new_validator_set = query.get_validator_set(b.connection)
|
||||
assert new_validator_set == validator_set
|
||||
@ -116,8 +116,8 @@ def test_init_chain_recognizes_new_chain_after_migration(b):
|
||||
generate_init_chain_request('chain-XYZ-migrated-at-height-1'),
|
||||
]
|
||||
for r in invalid_requests:
|
||||
res = App(b).init_chain(r)
|
||||
assert res == ResponseInitChain()
|
||||
with pytest.raises(SystemExit):
|
||||
App(b).init_chain(r)
|
||||
assert query.get_latest_abci_chain(b.connection) == {
|
||||
'chain_id': 'chain-XYZ-migrated-at-height-1',
|
||||
'is_synced': False,
|
||||
@ -150,8 +150,8 @@ def test_init_chain_recognizes_new_chain_after_migration(b):
|
||||
generate_init_chain_request('chain-XYZ-migrated-at-height-1'),
|
||||
]
|
||||
for r in invalid_requests:
|
||||
res = App(b).init_chain(r)
|
||||
assert res == ResponseInitChain()
|
||||
with pytest.raises(SystemExit):
|
||||
App(b).init_chain(r)
|
||||
assert query.get_latest_abci_chain(b.connection) == {
|
||||
'chain_id': 'chain-XYZ-migrated-at-height-1',
|
||||
'is_synced': True,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user