Api
MultiTest
provides three implementations of the Api trait:
Additionally, MockApi
, MockApiBech32
and
MockApiBech32m
implement addr_make
method, allowing for
convenient creation of user addresses in tests. You can find multiple examples of addr_make
method usage in the Addresses chapter. Depending on your needs, you
can use any implementation of the Api trait in your tests by utilizing the
AppBuilder::with_api
method to create a chain simulator.
Api
trait
The table below summarizes all methods of the Api trait with short descriptions:
Methods of Api trait | Description |
---|---|
addr_canonicalize | Converts a human-readable address into its canonical binary representation. |
addr_humanize | Converts a canonical address into human-readable address. |
addr_validate | Checks if the human-readable address is valid. |
secp256k1_verify | Verifies a message hash against a signature, with the public key of the signer, using the secp256k1 elliptic curve digital signature algorithm. |
secp256k1_recover_pubkey | Recovers a public key from a message hash and a signature in compressed form, which can be used in secp256k1_verify directly. |
secp256r1_verify | Verifies a message hash against a signature, with the public key of the signer, using the secp256r1 elliptic curve digital signature algorithm. |
secp256r1_recover_pubkey | Recovers a public key from a message hash and a signature in compressed form, which can be used in secp256r1_verify directly. |
ed25519_verify | Verifies message against a signature, with the public key of the signer, using the ed25519 elliptic curve digital signature algorithm. |
ed25519_batch_verify | Performs batch ed25519 signature verification. |
bls12_381_aggregate_g1 | Adds up points (48 bytes each) of the G1 subgroup on the BLS12-381 curve. |
bls12_381_aggregate_g2 | Adds up points (96 bytes each) of the G2 subgroup on the BLS12-381 curve. |
bls12_381_pairing_equality | Checks the pairing equality of the BLS12-381 curve. |
bls12_381_hash_to_g1 | Takes some arbitrary data and hashes it to a point (48 bytes long) on the G1 subgroup of the BLS12-381 curve. |
bls12_381_hash_to_g2 | Takes some arbitrary data and hashes it to a point (96 bytes long) on the G2 subgroup of the BLS12-381 curve. |
debug | Emits a debugging message. |
Api
trait implementations
A concise comparison of different Api trait implementations is shown in the table below:
MockApi | MockApiBech32 | MockApiBech32m | |
---|---|---|---|
Implements Api trait | Yes | Yes | Yes |
Implements addr_make function | Yes | Yes | Yes |
Address format | Bech32 | Bech32 | Bech32m |
Default prefix (HRP) | cosmwasm | No | No |
Supports custom prefixes | Yes | Yes | Yes |