packages.valory.skills.abstract_round_abci.tests.test_handlers
Test the handlers.py module of the skill.
test_exception_to_info_msg
def test_exception_to_info_msg() -> None
Test 'exception_to_info_msg' helper function.
TestABCIRoundHandler Objects
class TestABCIRoundHandler()
Test 'ABCIRoundHandler'.
setup_method
def setup_method() -> None
Set up the tests.
test_info
def test_info() -> None
Test the 'info' handler method.
test_init_chain
@pytest.mark.parametrize("app_hash", (b"", b"test"))
def test_init_chain(app_hash: bytes) -> None
Test the 'init_chain' handler method.
test_begin_block
def test_begin_block() -> None
Test the 'begin_block' handler method.
test_check_tx
@mock.patch.object(handlers, "Transaction")
def test_check_tx(*_: Any) -> None
Test the 'check_tx' handler method.
test_check_tx_negative
@mock.patch.object(
Transaction,
"decode",
side_effect=SignatureNotValidError,
)
def test_check_tx_negative(*_: Any) -> None
Test the 'check_tx' handler method, negative case.
test_deliver_tx
@mock.patch.object(handlers, "Transaction")
def test_deliver_tx(*_: Any) -> None
Test the 'deliver_tx' handler method.
test_deliver_tx_negative
@mock.patch.object(
Transaction,
"decode",
side_effect=SignatureNotValidError,
)
def test_deliver_tx_negative(*_: Any) -> None
Test the 'deliver_tx' handler method, negative case.
test_deliver_bad_tx
@mock.patch.object(handlers, "Transaction")
def test_deliver_bad_tx(*_: Any) -> None
Test the 'deliver_tx' handler method, when the transaction is not ok.
test_end_block
@pytest.mark.parametrize("request_height", tuple(range(3)))
def test_end_block(request_height: int) -> None
Test the 'end_block' handler method.
test_commit
def test_commit() -> None
Test the 'commit' handler method.
test_commit_negative
def test_commit_negative() -> None
Test the 'commit' handler method, negative case.
ConcreteResponseHandler Objects
class ConcreteResponseHandler(AbstractResponseHandler)
A concrete response handler for testing purposes.
TestAbstractResponseHandler Objects
class TestAbstractResponseHandler()
Test 'AbstractResponseHandler'.
setup_method
def setup_method() -> None
Set up the tests.
test_handle
def test_handle() -> None
Test the 'handle' method.
test_handle_negative_cannot_recover_dialogues
@mock.patch.object(AbstractResponseHandler,
"_recover_protocol_dialogues",
return_value=None)
def test_handle_negative_cannot_recover_dialogues(*_: Any) -> None
Test the 'handle' method, negative case (cannot recover dialogues).
test_handle_negative_cannot_update_dialogues
@mock.patch.object(AbstractResponseHandler, "_recover_protocol_dialogues")
def test_handle_negative_cannot_update_dialogues(
mock_dialogues_fn: Any) -> None
Test the 'handle' method, negative case (cannot update dialogues).
test_handle_negative_performative_not_allowed
def test_handle_negative_performative_not_allowed() -> None
Test the 'handle' method, negative case (performative not allowed).
test_handle_negative_cannot_find_callback
def test_handle_negative_cannot_find_callback() -> None
Test the 'handle' method, negative case (cannot find callback).
test_handle_swallows_and_logs_callback_exception
def test_handle_swallows_and_logs_callback_exception() -> None
A callback raising must be caught and logged, not propagated.
Drives the defensive except Exception branch added to
AbstractResponseHandler.handle: without it, a faulty callback
would tear the round behaviour down for the rest of the FSM.
TestTendermintHandler Objects
class TestTendermintHandler()
Test Tendermint Handler
setup_method
def setup_method() -> None
Set up the tests.
dummy_validator_config
@property
def dummy_validator_config() -> Dict[str, Dict[str, str]]
Dummy validator config
make_error_message
@staticmethod
def make_error_message() -> TendermintMessage
Make dummy error message
test_handle_unidentified_tendermint_dialogue
def test_handle_unidentified_tendermint_dialogue(
caplog: LogCaptureFixture) -> None
Test unidentified tendermint dialogue
test_handle_no_addresses_retrieved_yet
def test_handle_no_addresses_retrieved_yet(caplog: LogCaptureFixture) -> None
Test handle request no registered addresses
test_handle_not_in_registered_addresses
def test_handle_not_in_registered_addresses(caplog: LogCaptureFixture) -> None
Test handle response sender not in registered addresses
test_handle_replies_when_acn_container_raises_value_error
def test_handle_replies_when_acn_container_raises_value_error(
caplog: LogCaptureFixture) -> None
acn_container raises ValueError before FSM setup completes.
SharedState.round_sequence raises ValueError("round sequence not
available") when the FSM hasn't started yet, and that propagates out
of acn_container. The handler must catch it and reply with the
canonical "FSM not yet initialised" Tendermint error instead of
letting the exception escape the FSM loop.
test_handle_get_genesis_info
def test_handle_get_genesis_info(caplog: LogCaptureFixture) -> None
Test handle request for genesis info
test_handle_response_invalid_addresses
def test_handle_response_invalid_addresses(caplog: LogCaptureFixture) -> None
Test handle response for genesis info with invalid address.
test_handle_genesis_info
def test_handle_genesis_info(caplog: LogCaptureFixture) -> None
Test handle response for genesis info with valid address
test_recovery_params
@pytest.mark.parametrize("registered", (True, False))
@pytest.mark.parametrize(
"performative",
(
TendermintMessage.Performative.RECOVERY_PARAMS,
TendermintMessage.Performative.GET_RECOVERY_PARAMS,
),
)
def test_recovery_params(registered: bool,
performative: TendermintMessage.Performative,
caplog: LogCaptureFixture) -> None
Test handle response for recovery parameters.
test_recovery_params_error
@pytest.mark.parametrize(
"side_effect, expected_exception",
(
(
json.decoder.JSONDecodeError("", "", 0),
": line 1 column 1 (char 0)",
),
(
{"not a dict"},
"argument after ** must be a mapping, not str",
),
),
)
def test_recovery_params_error(side_effect: Any, expected_exception: str,
caplog: LogCaptureFixture) -> None
Test handle response for recovery parameters.
test_handle_error
def test_handle_error(caplog: LogCaptureFixture) -> None
Test handle error
test_handle_error_no_target_message_retrieved
def test_handle_error_no_target_message_retrieved(
caplog: LogCaptureFixture) -> None
Test handle error no target message retrieved
test_handle_performative_not_recognized
def test_handle_performative_not_recognized(caplog: LogCaptureFixture) -> None
Test performative no recognized
test_sender_not_in_registered_addresses
def test_sender_not_in_registered_addresses(caplog: LogCaptureFixture) -> None
Test sender not in registered addresses.