pub struct TestCryptoPrimitives { /* private fields */ }
Expand description

A HasCryptoPrimitives implementation used for unit testing smart contracts.

You can test smart contracts that use the cryptographic primitives in two different ways:

  1. By setting up mock responses for the functions you need, for example with the setup_hash_sha_256_mock method.
  2. Or, by using the actual implementations. For this, you need to enable the “crypto-primitives” feature.

Implementations§

Create a new TestCryptoPrimitives, for which no mocks has been set up.

Set up a mock for verify_ed25519_signature.

This is not available if the “crypto-primitives” feature is enabled. For more information on why, see the documentation of TestCryptoPrimitives.

Set up a mock for verify_ecdsa_secp256k1_signature.

This is not available if the “crypto-primitives” feature is enabled. For more information on why, see the documentation of TestCryptoPrimitives.

Set up a mock for hash_sha2_256.

This is not available if the “crypto-primitives” feature is enabled. For more information on why, see the documentation of TestCryptoPrimitives.

Set up a mock for hash_sha3_256.

This is not available if the “crypto-primitives” feature is enabled. For more information on why, see the documentation of TestCryptoPrimitives.

Set up a mock for hash_keccak_256.

This is not available if the “crypto-primitives” feature is enabled. For more information on why, see the documentation of TestCryptoPrimitives.

Trait Implementations§

Create a new TestCryptoPrimitives, for which no mocks has been set up.

Returns the “default value” for a type. Read more
Verify an ed25519 signature.
Verify an ecdsa signature over secp256k1 with the bitcoin-core implementation. Read more
Hash the data using the SHA2-256 algorithm.
Hash the data using the SHA3-256 algorithm.
Hash the data using the Keccak-256 algorithm.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.