referrerpolicy=no-referrer-when-downgrade
substrate_test_runtime

Trait TestAPI

Source
pub trait TestAPI<Block: BlockT>: Core<Block> {
Show 21 methods // Provided methods fn balance_of( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, id: AccountId, ) -> Result<u64, ApiError> { ... } fn benchmark_add_one( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, val: &u64, ) -> Result<u64, ApiError> { ... } fn benchmark_vector_add_one( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, vec: &Vec<u64>, ) -> Result<Vec<u64>, ApiError> { ... } fn function_signature_changed_before_version_2( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<Vec<u64>, ApiError> { ... } fn function_signature_changed( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<u64, ApiError> { ... } fn use_trie( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<u64, ApiError> { ... } fn benchmark_indirect_call( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<u64, ApiError> { ... } fn benchmark_direct_call( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<u64, ApiError> { ... } fn vec_with_capacity( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, size: u32, ) -> Result<Vec<u8>, ApiError> { ... } fn get_block_number( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<u64, ApiError> { ... } fn test_ed25519_crypto( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(AppSignature, AppPublic, Ed25519Pop), ApiError> { ... } fn test_sr25519_crypto( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(AppSignature, AppPublic, Sr25519Pop), ApiError> { ... } fn test_ecdsa_crypto( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(AppSignature, AppPublic, EcdsaPop), ApiError> { ... } fn test_bls381_crypto( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(Bls381Pop, Bls381Public), ApiError> { ... } fn test_ecdsa_bls381_crypto( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(EcdsaBls381Pop, EcdsaBls381Public), ApiError> { ... } fn test_storage( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(), ApiError> { ... } fn test_witness( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, proof: StorageProof, root: Hash, ) -> Result<(), ApiError> { ... } fn test_multiple_arguments( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, data: Vec<u8>, other: Vec<u8>, num: u32, ) -> Result<(), ApiError> { ... } fn do_trace_log( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(), ApiError> { ... } fn verify_ed25519( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, sig: Signature, public: Public, message: Vec<u8>, ) -> Result<bool, ApiError> { ... } fn write_key_value( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, key: Vec<u8>, value: Vec<u8>, panic: bool, ) -> Result<(), ApiError> { ... }
}

Provided Methods§

Source

fn balance_of( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, id: AccountId, ) -> Result<u64, ApiError>

Return the balance of the given account id.

Source

fn benchmark_add_one( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, val: &u64, ) -> Result<u64, ApiError>

A benchmark function that adds one to the given value and returns the result.

Source

fn benchmark_vector_add_one( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, vec: &Vec<u64>, ) -> Result<Vec<u64>, ApiError>

A benchmark function that adds one to each value in the given vector and returns the result.

Source

fn function_signature_changed_before_version_2( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<Vec<u64>, ApiError>

👎Deprecated

A function for that the signature changed in version 2.

Source

fn function_signature_changed( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<u64, ApiError>

The new signature.

Source

fn use_trie( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<u64, ApiError>

trie no_std testing

Source

fn benchmark_indirect_call( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<u64, ApiError>

Calls function in the loop using never-inlined function pointer

Source

fn benchmark_direct_call( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<u64, ApiError>

Calls function in the loop

Source

fn vec_with_capacity( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, size: u32, ) -> Result<Vec<u8>, ApiError>

Allocates vector with given capacity.

Source

fn get_block_number( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<u64, ApiError>

Returns the initialized block number.

Source

fn test_ed25519_crypto( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(AppSignature, AppPublic, Ed25519Pop), ApiError>

Test that ed25519 crypto works in the runtime.

Returns the signature generated for the message ed25519 both the public key and proof of possession.

Source

fn test_sr25519_crypto( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(AppSignature, AppPublic, Sr25519Pop), ApiError>

Test that sr25519 crypto works in the runtime.

Returns the signature generated for the message sr25519 both the public key and proof of possession.

Source

fn test_ecdsa_crypto( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(AppSignature, AppPublic, EcdsaPop), ApiError>

Test that ecdsa crypto works in the runtime.

Returns the signature generated for the message ecdsa both the public key and proof of possession.

Source

fn test_bls381_crypto( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(Bls381Pop, Bls381Public), ApiError>

Test that bls381 crypto works in the runtime

Returns both the proof of possession and public key.

Source

fn test_ecdsa_bls381_crypto( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(EcdsaBls381Pop, EcdsaBls381Public), ApiError>

Test that ecdsa_bls381_crypto works in the runtime

Returns both the proof of possession and public key.

Source

fn test_storage( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(), ApiError>

Run various tests against storage.

Source

fn test_witness( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, proof: StorageProof, root: Hash, ) -> Result<(), ApiError>

Check a witness.

Source

fn test_multiple_arguments( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, data: Vec<u8>, other: Vec<u8>, num: u32, ) -> Result<(), ApiError>

Test that ensures that we can call a function that takes multiple arguments.

Source

fn do_trace_log( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, ) -> Result<(), ApiError>

Traces log “Hey I’m runtime.”

Source

fn verify_ed25519( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, sig: Signature, public: Public, message: Vec<u8>, ) -> Result<bool, ApiError>

Verify the given signature, public & message bundle.

Source

fn write_key_value( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, key: Vec<u8>, value: Vec<u8>, panic: bool, ) -> Result<(), ApiError>

Write the given value under the given key into the storage and then optional panic.

Trait Implementations§

Source§

impl<Block: BlockT> RuntimeApiInfo for dyn TestAPI<Block>

Source§

const ID: [u8; 8] = _

The identifier of the runtime api.
Source§

const VERSION: u32 = 2u32

The version of the runtime api.

Implementors§

Source§

impl<__SrApiBlock__: BlockT, RuntimeApiImplCall: CallApiAt<__SrApiBlock__> + 'static> TestAPI<__SrApiBlock__> for RuntimeApiImpl<__SrApiBlock__, RuntimeApiImplCall>
where RuntimeApiImplCall::StateBackend: StateBackend<HashingFor<__SrApiBlock__>>, &'static RuntimeApiImplCall: Send,