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