Documentation ¶
Overview ¶
Package testonly contains code and data that should only be used by tests. Production code MUST NOT depend on anything in this package. This will be enforced by tools where possible.
As an example PEM encoded test certificates and helper functions to decode them are suitable candidates for being placed in testonly. However, nothing specific to a particular application should be added at this level. Do not add CT specific test data for example.
Index ¶
- Constants
- func CompactMerkleTreeLeafTestNodeHashes() [][][]byte
- func EmptyMerkleTreeRootHash() []byte
- func EnsureErrorContains(t *testing.T, err error, s string)
- func HashKey(key string) []byte
- func MerkleTreeLeafTestInputs() [][]byte
- func MerkleTreeLeafTestRootHashes() [][]byte
- func MustDecodeBase64(b64 string) []byte
- func MustHexDecode(b string) []byte
- func MustMarshalAny(t *testing.T, in proto.Message) *any.Any
- func MustMarshalAnyNoT(in proto.Message) *any.Any
- func NewSignerWithErr(pubKey crypto.PublicKey, err error) crypto.Signer
- func NewSignerWithFixedSig(pubKey crypto.PublicKey, sig []byte) crypto.Signer
- func RelativeToPackage(p string) string
- func TransparentHash(key string) []byte
Constants ¶
const DemoPrivateKey string = `` /* 294-byte string literal not displayed */
DemoPrivateKey is the private key itself; must only be used for testing purposes
const DemoPrivateKeyPass string = "towel"
DemoPrivateKeyPass is the password for DemoPrivateKey
const DemoPublicKey string = `` /* 178-byte string literal not displayed */
DemoPublicKey is the public key that corresponds to DemoPrivateKey.
Variables ¶
This section is empty.
Functions ¶
func CompactMerkleTreeLeafTestNodeHashes ¶
func CompactMerkleTreeLeafTestNodeHashes() [][][]byte
CompactMerkleTreeLeafTestNodeHashes returns the CompactMerkleTree.node state that must result after each of the leaf additions returned by MerkleTreeLeafTestInputs(), as described above.
func EmptyMerkleTreeRootHash ¶
func EmptyMerkleTreeRootHash() []byte
EmptyMerkleTreeRootHash returns the expected root hash for an empty Merkle Tree that uses SHA256 hashing.
func EnsureErrorContains ¶
EnsureErrorContains checks that an error contains a specific substring and fails a test with a fatal if it does not or the error was nil.
func HashKey ¶
HashKey converts a map key into a map index using SHA256. This preserves tests that precomputed indexes based on SHA256.
func MerkleTreeLeafTestInputs ¶
func MerkleTreeLeafTestInputs() [][]byte
MerkleTreeLeafTestInputs returns a slice of leaf inputs that may be used in compact Merkle tree test cases. They are intended to be added successively, so that after each addition the corresponding root from MerkleTreeLeafTestRoots gives the expected Merkle tree root hash.
func MerkleTreeLeafTestRootHashes ¶
func MerkleTreeLeafTestRootHashes() [][]byte
MerkleTreeLeafTestRootHashes returns a slice of Merkle tree root hashes that correspond to the expected tree state for the leaf additions returned by MerkleTreeLeafTestInputs(), as described above.
func MustDecodeBase64 ¶
MustDecodeBase64 expects a base 64 encoded string input and panics if it cannot be decoded
func MustHexDecode ¶
MustHexDecode decodes its input string from hex and panics if this fails
func MustMarshalAny ¶ added in v1.0.2
MustMarshalAny is used in tests to Marshal proto messages into the protobuf.ptypes.any.Any used in the Trillian API and in storage. Failure to marshal will fail the test but the suite will continue.
func MustMarshalAnyNoT ¶ added in v1.0.2
MustMarshalAnyNoT is used to Marshal proto messages into the protobuf.ptypes.any.Any used throughout the Trillian API and in storage. Use if testing.T not available. Failure to marshal will fail the test suite.
func NewSignerWithErr ¶
NewSignerWithErr creates a signer that always returns err when Sign() is called.
func NewSignerWithFixedSig ¶
NewSignerWithFixedSig creates a signer that always return sig when Sign() is called.
func RelativeToPackage ¶
RelativeToPackage returns the input path p as an absolute path, resolved relative to the caller's package. The working directory for Go tests is the dir of the test file. Using "plain" relative paths in test utilities is, therefore, brittle, as the directory structure may change depending on where the tests are placed.
func TransparentHash ¶
TransparentHash returns a key that can be visually inspected. This supports testing where it was nice to see what the key was.
Types ¶
This section is empty.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
maphammer
maphammer is a stress/load test for a Trillian Map.
|
maphammer is a stress/load test for a Trillian Map. |
Package integration provides test-only code for performing integrated tests of Trillian functionality.
|
Package integration provides test-only code for performing integrated tests of Trillian functionality. |
Package matchers contains additional gomock matchers.
|
Package matchers contains additional gomock matchers. |