Skip to content

packages.valory.connections.abci.tests.helper

Helper functions for checking compliance to ABCI spec

is_enum

def is_enum(d_type: Any) -> bool

Check if a type is an Enum (not instance!).

my_repr

def my_repr(self: Any) -> str

Custom repr for Tendermint protobuf objects, which lack it.

is_typing_list

def is_typing_list(d_type: Any) -> bool

Check if field is repeated.

replace_keys

def replace_keys(node: Node, trans: Node) -> None

Replace keys in-place

set_repr

def set_repr(cls: Type) -> Type

Set custom repr

get_aea_classes

def get_aea_classes(module: ModuleType) -> Dict[str, Type]

Get AEA custom classes.

get_protocol_readme_spec

@functools.lru_cache()
def get_protocol_readme_spec() -> Tuple[Any, Any, Any]

Test specification used to generate protocol matches ABCI spec

create_aea_abci_type_tree

def create_aea_abci_type_tree(speech_acts: Dict[str, Dict[str, str]]) -> Dict[str, Node]

Create AEA-native ABCI type tree from the defined speech acts

init_type_tree_primitives

def init_type_tree_primitives(type_tree: Node) -> Node

Initialize the primitive types and size of repeated fields.

These are the only initialization parameters that can vary; after this the initialization of custom types is what remains

This structure allows: - Comparison of structure and these values with Tendermint translation - Visual inspection of fields to be sets, also on custom objects - Randomized testing strategies using e.g. hypothesis

Arguments:

  • type_tree: mapping from message / field name to type.

Returns:

mapping from message / field name to initialized primitive.

init_aea_abci_messages

def init_aea_abci_messages(type_tree: Node, init_tree: Node) -> Node

Create ABCI messages for AEA-native ABCI spec

We iterate the type_tree and init_tree to finalize the initialization of custom objects contained in it, and create an instance of all ABCI messages.

Arguments:

  • type_tree: mapping from message / field name to type.
  • init_tree: mapping from message / field name to initialized primitive.

Returns:

mapping from message name to ABCI Message instance

EncodingError Objects

class EncodingError(Exception)

EncodingError AEA- to Tendermint-native ABCI message

DecodingError Objects

class DecodingError(Exception)

DecodingError Tendermint- to AEA-native ABCI message

encode

def encode(message: AbciMessage) -> Response

Encode AEA-native ABCI protocol messages to Tendermint-native

decode

def decode(request: Request) -> AbciMessage

Decode Tendermint-native ABCI protocol messages to AEA-native

get_tendermint_content

def get_tendermint_content(envelope: Union[Request, Response]) -> Node

Get Tendermint-native ABCI message content.

For all Request / Response instances obtained after encoding, we retrieve the information present in the message they contain.

Arguments:

  • envelope: a Tendermint Request / Response object.

Returns:

mapping structure from message / field name to leaf values

compare_trees

def compare_trees(init_node: Node, tender_node: Node) -> None

Compare Initialization and Tendermint tree nodes

get_tender_type_tree

def get_tender_type_tree() -> Node

Tendermint type tree

init_tendermint_messages

def init_tendermint_messages(tender_type_tree: Node) -> List[Union[Request, Response]]

Initialize tendermint ABCI messages

Back to top