fedimint_testing_core

Module db

Source

Constants§

BYTE_8
BYTE_20
BYTE_32
BYTE_33
STRING_64
TEST_MODULE_INSTANCE_ID

Functions§

copy_directory
Helper function that recursively copies all contents from src to dst.
create_snapshot 🔒
Creates a backup database in the snapshot_dir according to the FM_PREPARE_DB_MIGRATION_SNAPSHOTS, since we do not want to re-create a backup database every time we run the tests.
get_project_root
Get the project root (relative to closest Cargo.lock file)
get_temp_database 🔒
Retrieves a temporary database from the database backup directory. The first folder that starts with db_prefix will return as a temporary database.
open_snapshot_db 🔒
Opens the backup database in the snapshot_dir. If the is_isolated flag is set, the database will be opened as an isolated database with TEST_MODULE_INSTANCE_ID as the prefix.
open_temp_db_and_copy 🔒
Open a temporary database located at temp_path and copy the contents from the folder src_dir to the temporary database’s path.
snapshot_db_migrations
Creates the database backup directory for a server module by appending the snapshot_name to db/migrations. Then this function will execute the provided prepare_fn which is expected to populate the database with the appropriate data for testing a migration.
snapshot_db_migrations_client
Create the database backup directory for a client module. Two prepare functions are taken as parameters. data_prepare is expected to create any data that the client module uses and is stored in the isolated namespace. state_machine_prepare creates client state machine data that can be used for testing state machine migrations. This is created in the global namespace.
snapshot_db_migrations_with_decoders
Creates the database backup for snapshot_name to db/migrations. Then this function will execute the provided prepare_fn which is expected to populate the database with the appropriate data for testing a migration. If the snapshot directory already exists, this function will do nothing.
validate_migrations_client
Validates the database migrations for a client module. First applies all database migrations to the module, including the state machine migrations. Then calls the validate function, including the new active_states and inactive_states, and is expected to confirm the database migrations were successful.
validate_migrations_core_client
Validates the database migrations for the core client. First applies all database migrations to the core client. Then calls the validate function, including the new active_states and inactive_states, and is expected to confirm the database migrations were successful.
validate_migrations_global
Validates the database migrations. decoders need to be passed in as an argument since this is module agnostic. First applies all defined migrations to the database then executes the `validate`` function which should confirm the database migrations were successful.
validate_migrations_server
Validates the database migrations for a server module. First applies all database migrations to the module, then calls the validate which should confirm the database migrations were successful.