Skip to content

Commit

Permalink
test: update all to check postgres and sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
notmandatory committed Oct 5, 2024
1 parent bf3efc2 commit bfbd51f
Show file tree
Hide file tree
Showing 3 changed files with 302 additions and 375 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub enum BdkSqlxError {
}

/// Manages a pool of database connections.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct Store<DB: Database> {
pub(crate) pool: Pool<DB>,
wallet_name: String,
Expand Down
36 changes: 0 additions & 36 deletions src/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ impl Store<Postgres> {
.fetch_optional(&mut *tx)
.await?;

dbg!(&row);

if let Some(row) = row {
Self::changeset_from_row(&mut tx, &mut changeset, row).await?;
}
Expand Down Expand Up @@ -465,40 +463,6 @@ pub async fn local_chain_changeset_persist_to_postgres(
Ok(())
}

/// Drops all tables.
#[tracing::instrument]
pub async fn drop_all(db: Pool<Postgres>) -> Result<(), BdkSqlxError> {
info!("Dropping all tables");

let drop_statements = vec![
"DROP TABLE IF EXISTS _sqlx_migrations",
"DROP TABLE IF EXISTS vault_addresses",
"DROP TABLE IF EXISTS used_anchorwatch_keys",
"DROP TABLE IF EXISTS anchorwatch_keys",
"DROP TABLE IF EXISTS psbts",
"DROP TABLE IF EXISTS whitelist_update",
"DROP TABLE IF EXISTS vault_parameters",
"DROP TABLE IF EXISTS users",
"DROP TABLE IF EXISTS version",
"DROP TABLE IF EXISTS anchor_tx",
"DROP TABLE IF EXISTS txout",
"DROP TABLE IF EXISTS tx",
"DROP TABLE IF EXISTS block",
"DROP TABLE IF EXISTS keychain",
"DROP TABLE IF EXISTS network",
];

let mut tx = db.begin().await?;

for statement in drop_statements {
sqlx::query(statement).execute(&mut *tx).await?;
}

tx.commit().await?;

Ok(())
}

/// Collects information on all the wallets in the database and dumps it to stdout.
#[tracing::instrument]
pub async fn easy_backup(db: Pool<Postgres>) -> Result<(), BdkSqlxError> {
Expand Down
Loading

0 comments on commit bfbd51f

Please sign in to comment.