Skip to content

Commit

Permalink
Merge #857: Check results in the DB tests
Browse files Browse the repository at this point in the history
a1a70a5 Check results in the DB tests (Silvestrs Timofejevs)

Pull request description:

  ### Description

  Checksum test was giving a false positive due to ignoring the return value.

  Other tests were giving assertion fail later in the test, rather than an error on failed method call, thus making it more challenging to debug the issue.

  These have been discovered, when implementing PostgreSQL backend in a downstream fork.

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing
  * [x] I ran all `sqlite` and `key-value-db` tests successfully

ACKs for top commit:
  danielabrozzoni:
    ACK a1a70a5

Tree-SHA512: d3542cdd9f5f76f8318910261dbeb9cdcc9d4f26e9852e7aad7419c4abdf269d030b72bb21ee34a9dd314d2fa8433f1a6a9f1338a62699e5d8b6764c03067904
  • Loading branch information
danielabrozzoni committed Feb 24, 2023
2 parents 843807b + a1a70a5 commit ced2d05
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/database/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ pub mod test {

assert!(res.is_none());

let _res = db.set_script_pubkey(&script, keychain, path);
db.set_script_pubkey(&script, keychain, path).unwrap();
let (chain, child) = db.del_path_from_script_pubkey(&script).unwrap().unwrap();

assert_eq!(chain, keychain);
Expand Down Expand Up @@ -620,13 +620,13 @@ pub mod test {
pub fn test_del_last_index<D: Database>(mut db: D) {
let keychain = KeychainKind::External;

let _res = db.increment_last_index(keychain);
db.increment_last_index(keychain).unwrap();

let res = db.get_last_index(keychain).unwrap().unwrap();

assert_eq!(res, 0);

let _res = db.increment_last_index(keychain);
db.increment_last_index(keychain).unwrap();

let res = db.del_last_index(keychain).unwrap().unwrap();

Expand All @@ -640,7 +640,7 @@ pub mod test {
// insert checksum associated to keychain
let checksum = "1cead456".as_bytes();
let keychain = KeychainKind::External;
let _res = db.check_descriptor_checksum(keychain, checksum);
db.check_descriptor_checksum(keychain, checksum).unwrap();

// check if `check_descriptor_checksum` throws
// `Error::ChecksumMismatch` error if the
Expand Down

0 comments on commit ced2d05

Please sign in to comment.