mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-23 22:15:44 +00:00
392 abci rpc is not defined for election proposals (#397)
* fixed missing abci_rpc initialization * bumped versions and added changelog * sq fixes Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
b2bca169ec
commit
4c55f576b9
@ -25,6 +25,11 @@ For reference, the possible headings are:
|
|||||||
* **Known Issues**
|
* **Known Issues**
|
||||||
* **Notes**
|
* **Notes**
|
||||||
|
|
||||||
|
## [2.4.6] - 2023-2-05
|
||||||
|
* **Fixed** Missing ABCI_RPC object initiailization for CLI voting commands.
|
||||||
|
* **Fixed** TypeError in EndBlock procedure that occured rarely within the network.
|
||||||
|
* **Security** moved to a more secure requests version
|
||||||
|
|
||||||
## [2.4.5] - 2023-21-04
|
## [2.4.5] - 2023-21-04
|
||||||
* **Fixed** Integration of DataAccessor Singleton class to reduce potentially multiple DB driver initializations.
|
* **Fixed** Integration of DataAccessor Singleton class to reduce potentially multiple DB driver initializations.
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
|||||||
@ -120,11 +120,8 @@ def test_env_config(monkeypatch):
|
|||||||
assert result == expected
|
assert result == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
@pytest.mark.skip(reason="Disabled until we create a better config format")
|
||||||
def test_autoconfigure_read_both_from_file_and_env(
|
def test_autoconfigure_read_both_from_file_and_env(monkeypatch, request):
|
||||||
monkeypatch, request
|
|
||||||
): # TODO Disabled until we create a better config format
|
|
||||||
return
|
|
||||||
# constants
|
# constants
|
||||||
DATABASE_HOST = "test-host"
|
DATABASE_HOST = "test-host"
|
||||||
DATABASE_NAME = "test-dbname"
|
DATABASE_NAME = "test-dbname"
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
@ -35,6 +36,3 @@ services:
|
|||||||
- ./integration/scripts:/scripts
|
- ./integration/scripts:/scripts
|
||||||
- ./integration/cli:/tests
|
- ./integration/cli:/tests
|
||||||
- shared:/shared
|
- shared:/shared
|
||||||
|
|
||||||
volumes:
|
|
||||||
shared:
|
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
|||||||
@ -189,7 +189,6 @@ def main():
|
|||||||
ctx["public_keys_transfer"] = tx_transfer.outputs[0].public_keys[0]
|
ctx["public_keys_transfer"] = tx_transfer.outputs[0].public_keys[0]
|
||||||
ctx["tx_transfer_id"] = tx_transfer.id
|
ctx["tx_transfer_id"] = tx_transfer.id
|
||||||
|
|
||||||
# privkey_transfer_last = 'sG3jWDtdTXUidBJK53ucSTrosktG616U3tQHBk81eQe'
|
|
||||||
pubkey_transfer_last = "3Af3fhhjU6d9WecEM9Uw5hfom9kNEwE7YuDWdqAUssqm"
|
pubkey_transfer_last = "3Af3fhhjU6d9WecEM9Uw5hfom9kNEwE7YuDWdqAUssqm"
|
||||||
|
|
||||||
cid = 0
|
cid = 0
|
||||||
|
|||||||
@ -198,7 +198,6 @@ todo_include_todos = False
|
|||||||
# a list of builtin themes.
|
# a list of builtin themes.
|
||||||
#
|
#
|
||||||
html_theme = "press"
|
html_theme = "press"
|
||||||
# html_theme = 'sphinx_documatt_theme'
|
|
||||||
|
|
||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
# Theme options are theme-specific and customize the look and feel of a theme
|
||||||
# further. For a list of options available for each theme, see the
|
# further. For a list of options available for each theme, see the
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
---
|
||||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||||
# Planetmint and IPDB software contributors.
|
# Planetmint and IPDB software contributors.
|
||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
|
|||||||
@ -81,9 +81,7 @@ class ApplicationLogic(BaseApplication):
|
|||||||
chain_id = known_chain["chain_id"]
|
chain_id = known_chain["chain_id"]
|
||||||
|
|
||||||
if known_chain["is_synced"]:
|
if known_chain["is_synced"]:
|
||||||
msg = (
|
msg = f"Got invalid InitChain ABCI request ({genesis}) - the chain {chain_id} is already synced."
|
||||||
f"Got invalid InitChain ABCI request ({genesis}) - " f"the chain {chain_id} is already synced."
|
|
||||||
)
|
|
||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if chain_id != genesis.chain_id:
|
if chain_id != genesis.chain_id:
|
||||||
@ -238,7 +236,7 @@ class ApplicationLogic(BaseApplication):
|
|||||||
block_txn_hash = calculate_hash(self.block_txn_ids)
|
block_txn_hash = calculate_hash(self.block_txn_ids)
|
||||||
block = self.validator.models.get_latest_block()
|
block = self.validator.models.get_latest_block()
|
||||||
|
|
||||||
logger.debug("BLOCK: ", block)
|
logger.debug(f"BLOCK: {block}")
|
||||||
if self.block_txn_ids:
|
if self.block_txn_ids:
|
||||||
self.block_txn_hash = calculate_hash([block["app_hash"], block_txn_hash])
|
self.block_txn_hash = calculate_hash([block["app_hash"], block_txn_hash])
|
||||||
else:
|
else:
|
||||||
@ -279,7 +277,7 @@ class ApplicationLogic(BaseApplication):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Commit-ing new block with hash: apphash=%s ," "height=%s, txn ids=%s",
|
"Commit-ing new block with hash: apphash=%s, height=%s, txn ids=%s",
|
||||||
data,
|
data,
|
||||||
self.new_height,
|
self.new_height,
|
||||||
self.block_txn_ids,
|
self.block_txn_ids,
|
||||||
|
|||||||
@ -79,7 +79,6 @@ def new_validator_set(validators, updates):
|
|||||||
|
|
||||||
def get_public_key_decoder(pk):
|
def get_public_key_decoder(pk):
|
||||||
encoding = pk["type"]
|
encoding = pk["type"]
|
||||||
decoder = base64.b64decode
|
|
||||||
|
|
||||||
if encoding == "ed25519-base16":
|
if encoding == "ed25519-base16":
|
||||||
decoder = base64.b16decode
|
decoder = base64.b16decode
|
||||||
|
|||||||
@ -61,9 +61,7 @@ class Validator:
|
|||||||
if tx.operation != Transaction.COMPOSE:
|
if tx.operation != Transaction.COMPOSE:
|
||||||
asset_id = tx.get_asset_id(input_txs)
|
asset_id = tx.get_asset_id(input_txs)
|
||||||
if asset_id != Transaction.read_out_asset_id(tx):
|
if asset_id != Transaction.read_out_asset_id(tx):
|
||||||
raise AssetIdMismatch(
|
raise AssetIdMismatch(("The asset id of the input does not match the asset id of the transaction"))
|
||||||
("The asset id of the input does not" " match the asset id of the" " transaction")
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
asset_ids = Transaction.get_asset_ids(input_txs)
|
asset_ids = Transaction.get_asset_ids(input_txs)
|
||||||
if Transaction.read_out_asset_id(tx) in asset_ids:
|
if Transaction.read_out_asset_id(tx) in asset_ids:
|
||||||
@ -105,9 +103,9 @@ class Validator:
|
|||||||
|
|
||||||
if output_amount != input_amount:
|
if output_amount != input_amount:
|
||||||
raise AmountError(
|
raise AmountError(
|
||||||
(
|
"The amount used in the inputs `{}` needs to be same as the amount used in the outputs `{}`".format(
|
||||||
"The amount used in the inputs `{}`" " needs to be same as the amount used" " in the outputs `{}`"
|
input_amount, output_amount
|
||||||
).format(input_amount, output_amount)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -202,7 +200,7 @@ class Validator:
|
|||||||
raise InvalidProposer("Public key is not a part of the validator set")
|
raise InvalidProposer("Public key is not a part of the validator set")
|
||||||
|
|
||||||
# NOTE: Check if all validators have been assigned votes equal to their voting power
|
# NOTE: Check if all validators have been assigned votes equal to their voting power
|
||||||
if not self.is_same_topology(current_validators, transaction.outputs):
|
if not Validator.is_same_topology(current_validators, transaction.outputs):
|
||||||
raise UnequalValidatorSet("Validator set much be exactly same to the outputs of election")
|
raise UnequalValidatorSet("Validator set much be exactly same to the outputs of election")
|
||||||
|
|
||||||
if transaction.operation == VALIDATOR_ELECTION:
|
if transaction.operation == VALIDATOR_ELECTION:
|
||||||
@ -210,7 +208,8 @@ class Validator:
|
|||||||
|
|
||||||
return transaction
|
return transaction
|
||||||
|
|
||||||
def is_same_topology(cls, current_topology, election_topology):
|
@staticmethod
|
||||||
|
def is_same_topology(current_topology, election_topology):
|
||||||
voters = {}
|
voters = {}
|
||||||
for voter in election_topology:
|
for voter in election_topology:
|
||||||
if len(voter.public_keys) > 1:
|
if len(voter.public_keys) > 1:
|
||||||
|
|||||||
@ -73,7 +73,7 @@ class LocalMongoDBConnection(DBConnection):
|
|||||||
try:
|
try:
|
||||||
return query.run(self.connect())
|
return query.run(self.connect())
|
||||||
except pymongo.errors.AutoReconnect:
|
except pymongo.errors.AutoReconnect:
|
||||||
logger.warning("Lost connection to the database, " "retrying query.")
|
logger.warning("Lost connection to the database, retrying query.")
|
||||||
return query.run(self.connect())
|
return query.run(self.connect())
|
||||||
except pymongo.errors.AutoReconnect as exc:
|
except pymongo.errors.AutoReconnect as exc:
|
||||||
raise ConnectionError from exc
|
raise ConnectionError from exc
|
||||||
|
|||||||
@ -68,12 +68,14 @@ class Output:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def outputs_dict(output: dict, transaction_id: str = "") -> Output:
|
def outputs_dict(output: dict, transaction_id: str = "") -> Output:
|
||||||
out_dict: Output
|
return Output(
|
||||||
if output["condition"]["details"].get("subconditions") is None:
|
transaction_id=transaction_id,
|
||||||
out_dict = Output.output_with_public_key(output, transaction_id)
|
public_keys=output["public_keys"],
|
||||||
else:
|
amount=output["amount"],
|
||||||
out_dict = Output.output_with_sub_conditions(output, transaction_id)
|
condition=Condition(
|
||||||
return out_dict
|
uri=output["condition"]["uri"], details=ConditionDetails.from_dict(output["condition"]["details"])
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_tuple(output: tuple) -> Output:
|
def from_tuple(output: tuple) -> Output:
|
||||||
@ -110,25 +112,3 @@ class Output:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def list_to_dict(output_list: list[Output]) -> list[dict]:
|
def list_to_dict(output_list: list[Output]) -> list[dict]:
|
||||||
return [output.to_dict() for output in output_list or []]
|
return [output.to_dict() for output in output_list or []]
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def output_with_public_key(output, transaction_id) -> Output:
|
|
||||||
return Output(
|
|
||||||
transaction_id=transaction_id,
|
|
||||||
public_keys=output["public_keys"],
|
|
||||||
amount=output["amount"],
|
|
||||||
condition=Condition(
|
|
||||||
uri=output["condition"]["uri"], details=ConditionDetails.from_dict(output["condition"]["details"])
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def output_with_sub_conditions(output, transaction_id) -> Output:
|
|
||||||
return Output(
|
|
||||||
transaction_id=transaction_id,
|
|
||||||
public_keys=output["public_keys"],
|
|
||||||
amount=output["amount"],
|
|
||||||
condition=Condition(
|
|
||||||
uri=output["condition"]["uri"], details=ConditionDetails.from_dict(output["condition"]["details"])
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ from planetmint.backend import schema
|
|||||||
from planetmint.commands import utils
|
from planetmint.commands import utils
|
||||||
from planetmint.commands.utils import configure_planetmint, input_on_stderr
|
from planetmint.commands.utils import configure_planetmint, input_on_stderr
|
||||||
from planetmint.config_utils import setup_logging
|
from planetmint.config_utils import setup_logging
|
||||||
from planetmint.abci.rpc import MODE_COMMIT, MODE_LIST
|
from planetmint.abci.rpc import ABCI_RPC, MODE_COMMIT, MODE_LIST
|
||||||
from planetmint.abci.utils import load_node_key, public_key_from_base64
|
from planetmint.abci.utils import load_node_key, public_key_from_base64
|
||||||
from planetmint.commands.election_types import elections
|
from planetmint.commands.election_types import elections
|
||||||
from planetmint.version import __tm_supported_versions__
|
from planetmint.version import __tm_supported_versions__
|
||||||
@ -111,14 +111,18 @@ def run_election(args):
|
|||||||
"""Initiate and manage elections"""
|
"""Initiate and manage elections"""
|
||||||
|
|
||||||
b = Validator()
|
b = Validator()
|
||||||
|
abci_rpc = ABCI_RPC()
|
||||||
|
|
||||||
|
if args.action == "show":
|
||||||
|
run_election_show(args, b)
|
||||||
|
else:
|
||||||
# Call the function specified by args.action, as defined above
|
# Call the function specified by args.action, as defined above
|
||||||
globals()[f"run_election_{args.action}"](args, b)
|
globals()[f"run_election_{args.action}"](args, b, abci_rpc)
|
||||||
|
|
||||||
|
|
||||||
def run_election_new(args, planet):
|
def run_election_new(args, planet, abci_rpc):
|
||||||
election_type = args.election_type.replace("-", "_")
|
election_type = args.election_type.replace("-", "_")
|
||||||
globals()[f"run_election_new_{election_type}"](args, planet)
|
globals()[f"run_election_new_{election_type}"](args, planet, abci_rpc)
|
||||||
|
|
||||||
|
|
||||||
def create_new_election(sk, planet, election_class, data, abci_rpc):
|
def create_new_election(sk, planet, election_class, data, abci_rpc):
|
||||||
@ -186,7 +190,7 @@ def run_election_new_chain_migration(args, planet, abci_rpc):
|
|||||||
return create_new_election(args.sk, planet, ChainMigrationElection, [{"data": {}}], abci_rpc)
|
return create_new_election(args.sk, planet, ChainMigrationElection, [{"data": {}}], abci_rpc)
|
||||||
|
|
||||||
|
|
||||||
def run_election_approve(args, validator: Validator, abci_rpc):
|
def run_election_approve(args, validator: Validator, abci_rpc: ABCI_RPC):
|
||||||
"""Approve an election
|
"""Approve an election
|
||||||
|
|
||||||
:param args: dict
|
:param args: dict
|
||||||
|
|||||||
@ -117,8 +117,8 @@ class Config(metaclass=Singleton):
|
|||||||
def set(self, config):
|
def set(self, config):
|
||||||
self._private_real_config = config
|
self._private_real_config = config
|
||||||
|
|
||||||
def get_db_key_map(sefl, db):
|
def get_db_key_map(self, db):
|
||||||
return sefl.__private_database_keys_map[db]
|
return self.__private_database_keys_map[db]
|
||||||
|
|
||||||
def get_db_map(sefl, db):
|
def get_db_map(sefl, db):
|
||||||
return sefl.__private_database_map[db]
|
return sefl.__private_database_map[db]
|
||||||
@ -131,16 +131,12 @@ DEFAULT_LOGGING_CONFIG = {
|
|||||||
"formatters": {
|
"formatters": {
|
||||||
"console": {
|
"console": {
|
||||||
"class": "logging.Formatter",
|
"class": "logging.Formatter",
|
||||||
"format": (
|
"format": ("[%(asctime)s] [%(levelname)s] (%(name)s) %(message)s (%(processName)-10s - pid: %(process)d)"),
|
||||||
"[%(asctime)s] [%(levelname)s] (%(name)s) " "%(message)s (%(processName)-10s - pid: %(process)d)"
|
|
||||||
),
|
|
||||||
"datefmt": "%Y-%m-%d %H:%M:%S",
|
"datefmt": "%Y-%m-%d %H:%M:%S",
|
||||||
},
|
},
|
||||||
"file": {
|
"file": {
|
||||||
"class": "logging.Formatter",
|
"class": "logging.Formatter",
|
||||||
"format": (
|
"format": ("[%(asctime)s] [%(levelname)s] (%(name)s) %(message)s (%(processName)-10s - pid: %(process)d)"),
|
||||||
"[%(asctime)s] [%(levelname)s] (%(name)s) " "%(message)s (%(processName)-10s - pid: %(process)d)"
|
|
||||||
),
|
|
||||||
"datefmt": "%Y-%m-%d %H:%M:%S",
|
"datefmt": "%Y-%m-%d %H:%M:%S",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -337,7 +337,6 @@ class DataAccessor(metaclass=Singleton):
|
|||||||
str: Merkle root in hexadecimal form.
|
str: Merkle root in hexadecimal form.
|
||||||
"""
|
"""
|
||||||
utxoset = backend.query.get_unspent_outputs(self.connection)
|
utxoset = backend.query.get_unspent_outputs(self.connection)
|
||||||
# TODO Once ready, use the already pre-computed utxo_hash field.
|
|
||||||
# See common/transactions.py for details.
|
# See common/transactions.py for details.
|
||||||
|
|
||||||
hashes = [
|
hashes = [
|
||||||
@ -346,5 +345,4 @@ class DataAccessor(metaclass=Singleton):
|
|||||||
|
|
||||||
print(sorted(hashes))
|
print(sorted(hashes))
|
||||||
|
|
||||||
# TODO Notice the sorted call!
|
|
||||||
return merkleroot(sorted(hashes))
|
return merkleroot(sorted(hashes))
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||||
|
|
||||||
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import setproctitle
|
import setproctitle
|
||||||
|
|
||||||
@ -94,4 +95,4 @@ def start(args):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
start()
|
start(sys.argv)
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||||
|
|
||||||
__version__ = "2.4.5"
|
__version__ = "2.4.6"
|
||||||
__short_version__ = "2.4"
|
__short_version__ = "2.4"
|
||||||
|
|
||||||
# Supported Tendermint versions
|
# Supported Tendermint versions
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "planetmint"
|
name = "planetmint"
|
||||||
version = "2.4.5"
|
version = "2.4.6"
|
||||||
description = "Planetmint: The Blockchain Database"
|
description = "Planetmint: The Blockchain Database"
|
||||||
authors = ["Planetmint contributors"]
|
authors = ["Planetmint contributors"]
|
||||||
license = "AGPLv3"
|
license = "AGPLv3"
|
||||||
|
|||||||
@ -26,6 +26,9 @@ from planetmint.backend.connection import Connection
|
|||||||
from tests.utils import generate_election, generate_validators
|
from tests.utils import generate_election, generate_validators
|
||||||
|
|
||||||
|
|
||||||
|
rpc_write_transaction_string = "planetmint.abci.rpc.ABCI_RPC.write_transaction"
|
||||||
|
|
||||||
|
|
||||||
def mock_get_validators(self, height):
|
def mock_get_validators(self, height):
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -57,7 +60,7 @@ def test_chain_migration_election_show_shows_inconclusive(b_flushed, test_abci_r
|
|||||||
b = b_flushed
|
b = b_flushed
|
||||||
|
|
||||||
validators = generate_validators([1] * 4)
|
validators = generate_validators([1] * 4)
|
||||||
output = b.models.store_validator_set(1, [v["storage"] for v in validators])
|
_ = b.models.store_validator_set(1, [v["storage"] for v in validators])
|
||||||
|
|
||||||
public_key = validators[0]["public_key"]
|
public_key = validators[0]["public_key"]
|
||||||
private_key = validators[0]["private_key"]
|
private_key = validators[0]["private_key"]
|
||||||
@ -465,7 +468,7 @@ def test_election_new_upsert_validator_without_tendermint(
|
|||||||
from planetmint.model.dataaccessor import DataAccessor
|
from planetmint.model.dataaccessor import DataAccessor
|
||||||
|
|
||||||
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
||||||
m.setattr("planetmint.abci.rpc.ABCI_RPC.write_transaction", mock_write)
|
m.setattr(rpc_write_transaction_string, mock_write)
|
||||||
|
|
||||||
args = Namespace(
|
args = Namespace(
|
||||||
action="new",
|
action="new",
|
||||||
@ -505,7 +508,7 @@ def test_election_new_chain_migration_without_tendermint(
|
|||||||
from planetmint.model.dataaccessor import DataAccessor
|
from planetmint.model.dataaccessor import DataAccessor
|
||||||
|
|
||||||
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
||||||
m.setattr("planetmint.abci.rpc.ABCI_RPC.write_transaction", mock_write)
|
m.setattr(rpc_write_transaction_string, mock_write)
|
||||||
|
|
||||||
args = Namespace(action="new", election_type="migration", sk=priv_validator_path, config={})
|
args = Namespace(action="new", election_type="migration", sk=priv_validator_path, config={})
|
||||||
|
|
||||||
@ -546,7 +549,7 @@ def test_election_new_upsert_validator_invalid_power(
|
|||||||
from planetmint.model.dataaccessor import DataAccessor
|
from planetmint.model.dataaccessor import DataAccessor
|
||||||
|
|
||||||
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
||||||
m.setattr("planetmint.abci.rpc.ABCI_RPC.write_transaction", mock_write)
|
m.setattr(rpc_write_transaction_string, mock_write)
|
||||||
|
|
||||||
args = Namespace(
|
args = Namespace(
|
||||||
action="new",
|
action="new",
|
||||||
@ -600,7 +603,7 @@ def test_election_approve_without_tendermint(
|
|||||||
from planetmint.model.dataaccessor import DataAccessor
|
from planetmint.model.dataaccessor import DataAccessor
|
||||||
|
|
||||||
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
||||||
m.setattr("planetmint.abci.rpc.ABCI_RPC.write_transaction", mock_write)
|
m.setattr(rpc_write_transaction_string, mock_write)
|
||||||
|
|
||||||
b, election_id = call_election_internal(b, new_validator, node_key)
|
b, election_id = call_election_internal(b, new_validator, node_key)
|
||||||
|
|
||||||
@ -674,7 +677,7 @@ def call_election(monkeypatch, b, new_validator, node_key, abci_rpc):
|
|||||||
from planetmint.model.dataaccessor import DataAccessor
|
from planetmint.model.dataaccessor import DataAccessor
|
||||||
|
|
||||||
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
m.setattr(DataAccessor, "get_validators", mock_get_validators)
|
||||||
m.setattr("planetmint.abci.rpc.ABCI_RPC.write_transaction", mock_write)
|
m.setattr(rpc_write_transaction_string, mock_write)
|
||||||
b, election_id = call_election_internal(b, new_validator, node_key)
|
b, election_id = call_election_internal(b, new_validator, node_key)
|
||||||
m.undo()
|
m.undo()
|
||||||
return b, election_id
|
return b, election_id
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user