planetmint/tests/migrations/test_migration_election.py
Jürgen Eckel 5c4923dbd6
373 integration of the dataaccessor singleton (#389)
* initial singleton usage

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>

* passing all tests

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>

* blackified

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>

* aggretated code into helper functions

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>

---------

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-04-21 10:48:40 +02:00

29 lines
996 B
Python

import pytest
from transactions.types.elections.chain_migration_election import ChainMigrationElection
@pytest.mark.bdb
def test_valid_migration_election(monkeypatch, b, node_key, network_validators):
def mock_get_validators(self, height):
validators = []
for public_key, power in network_validators.items():
validators.append(
{
"public_key": {"type": "ed25519-base64", "value": public_key},
"voting_power": power,
}
)
return validators
with monkeypatch.context() as m:
from planetmint.model.dataaccessor import DataAccessor
m.setattr(DataAccessor, "get_validators", mock_get_validators)
voters = b.get_recipients_list()
election = ChainMigrationElection.generate([node_key.public_key], voters, [{"data": {}}], None).sign(
[node_key.private_key]
)
assert b.validate_election(election)
m.undo()