From 20961c612aecad2e4b00b8016e84422461041a98 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sun, 11 Nov 2018 13:15:39 -0600 Subject: [PATCH 01/10] pow chain store tests added --- lighthouse/db/Cargo.toml | 1 + lighthouse/db/src/stores/pow_chain_store.rs | 41 ++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lighthouse/db/Cargo.toml b/lighthouse/db/Cargo.toml index a2718889c..0d0bf4a2e 100644 --- a/lighthouse/db/Cargo.toml +++ b/lighthouse/db/Cargo.toml @@ -11,3 +11,4 @@ rocksdb = "0.10.1" ssz = { path = "../../beacon_chain/utils/ssz" } ssz_helpers = { path = "../../beacon_chain/utils/ssz_helpers" } types = { path = "../../beacon_chain/types" } +rand = "0.5.5" diff --git a/lighthouse/db/src/stores/pow_chain_store.rs b/lighthouse/db/src/stores/pow_chain_store.rs index f1f050a39..f2f0f5df6 100644 --- a/lighthouse/db/src/stores/pow_chain_store.rs +++ b/lighthouse/db/src/stores/pow_chain_store.rs @@ -4,6 +4,7 @@ use super::{ DBError, }; use super::POW_CHAIN_DB_COLUMN as DB_COLUMN; +extern crate rand; pub struct PoWChainStore where T: ClientDB @@ -31,4 +32,42 @@ impl PoWChainStore { } } -// TODO: add tests once a memory-db is implemented +#[cfg(test)] +mod tests { + use super::*; + use super::super::super::MemoryDB; + + #[test] + fn test_put_block_hash() { + let db = Arc::new(MemoryDB::open()); + let store = PoWChainStore::new(db.clone()); + + let hash: &[u8] = &[rand::random()]; + store.put_block_hash(hash); + + assert!(db.exists(DB_COLUMN, hash).unwrap()); + } + + #[test] + fn test_block_hash_exists() { + let db = Arc::new(MemoryDB::open()); + let store = PoWChainStore::new(db.clone()); + + let hash: &[u8] = &[rand::random()]; + db.put(DB_COLUMN, hash, &[0]); + + assert!(store.block_hash_exists(hash).unwrap()); + } + + #[test] + fn test_block_hash_does_not_exist() { + let db = Arc::new(MemoryDB::open()); + let store = PoWChainStore::new(db.clone()); + + let hash: &[u8] = &[rand::random()]; + let other_hash: &[u8] = &[rand::random()]; + db.put(DB_COLUMN, hash, &[0]); + + assert!(!store.block_hash_exists(other_hash).unwrap()); + } +} From 66ca29909282a3326bb6faeda4d5e706fd1f81b2 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sun, 11 Nov 2018 13:17:42 -0600 Subject: [PATCH 02/10] rand import moved --- lighthouse/db/src/stores/pow_chain_store.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lighthouse/db/src/stores/pow_chain_store.rs b/lighthouse/db/src/stores/pow_chain_store.rs index f2f0f5df6..fab197288 100644 --- a/lighthouse/db/src/stores/pow_chain_store.rs +++ b/lighthouse/db/src/stores/pow_chain_store.rs @@ -4,7 +4,6 @@ use super::{ DBError, }; use super::POW_CHAIN_DB_COLUMN as DB_COLUMN; -extern crate rand; pub struct PoWChainStore where T: ClientDB @@ -34,6 +33,8 @@ impl PoWChainStore { #[cfg(test)] mod tests { + extern crate rand; + use super::*; use super::super::super::MemoryDB; From bde0612e1d3a551d66cd37d6c2325e814d293018 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sat, 17 Nov 2018 19:06:24 -0600 Subject: [PATCH 03/10] validator store cleanup --- lighthouse/db/src/stores/validator_store.rs | 52 +++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/lighthouse/db/src/stores/validator_store.rs b/lighthouse/db/src/stores/validator_store.rs index 576fb67db..1970cf4fd 100644 --- a/lighthouse/db/src/stores/validator_store.rs +++ b/lighthouse/db/src/stores/validator_store.rs @@ -82,6 +82,58 @@ mod tests { use super::super::bls::Keypair; use super::*; + #[test] + fn test_put_public_key_by_index() { + let db = Arc::new(MemoryDB::open()); + let store = ValidatorStore::new(db.clone()); + + let index = 3; + let public_key = Keypair::random().pk; + + store.put_public_key_by_index(index, &public_key).unwrap(); + let public_key_at_index = db.get( + DB_COLUMN, + &store.get_db_key_for_index(&KeyPrefixes::PublicKey, index)[..] + ).unwrap().unwrap(); + + assert_eq!(public_key_at_index, public_key.as_bytes()); + } + + #[test] + fn test_get_public_key_by_index() { + let db = Arc::new(MemoryDB::open()); + let store = ValidatorStore::new(db.clone()); + + let index = 4; + let public_key = Keypair::random().pk; + + db.put( + DB_COLUMN, + &store.get_db_key_for_index(&KeyPrefixes::PublicKey, index)[..], + &public_key.as_bytes()[..] + ).unwrap(); + + let public_key_at_index = store.get_public_key_by_index(index).unwrap().unwrap(); + assert_eq!(public_key_at_index, public_key); + } + + #[test] + fn test_get_public_key_by_invalid_index() { + let db = Arc::new(MemoryDB::open()); + let store = ValidatorStore::new(db.clone()); + + let public_key = Keypair::random().pk; + + db.put( + DB_COLUMN, + &store.get_db_key_for_index(&KeyPrefixes::PublicKey, 3)[..], + &public_key.as_bytes()[..] + ).unwrap(); + + let public_key_at_index = store.get_public_key_by_index(4).unwrap(); + assert_eq!(public_key_at_index, None); + } + #[test] fn test_validator_store_put_get() { let db = Arc::new(MemoryDB::open()); From 005efc2e7a6411c6a60a763a18b669d16254bff4 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sun, 18 Nov 2018 11:00:05 -0600 Subject: [PATCH 04/10] beacon block tests --- .../db/src/stores/beacon_block_store.rs | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/lighthouse/db/src/stores/beacon_block_store.rs b/lighthouse/db/src/stores/beacon_block_store.rs index 4ea2882be..a60dc435e 100644 --- a/lighthouse/db/src/stores/beacon_block_store.rs +++ b/lighthouse/db/src/stores/beacon_block_store.rs @@ -96,6 +96,70 @@ mod tests { use std::sync::Arc; use std::thread; + #[test] + fn test_put_serialized_block() { + let db = Arc::new(MemoryDB::open()); + let store = BeaconBlockStore::new(db.clone()); + + let ssz = "some bytes".as_bytes(); + let hash = &Hash256::from("some hash".as_bytes()).to_vec(); + + store.put_serialized_block(hash, ssz); + assert_eq!(db.get(DB_COLUMN, hash).unwrap().unwrap(), ssz); + } + + #[test] + fn test_get_serialized_block() { + let db = Arc::new(MemoryDB::open()); + let store = BeaconBlockStore::new(db.clone()); + + let ssz = "some bytes".as_bytes(); + let hash = &Hash256::from("some hash".as_bytes()).to_vec(); + + db.put(DB_COLUMN, hash, ssz); + assert_eq!(store.get_serialized_block(hash).unwrap().unwrap(), ssz); + } + + #[test] + fn test_block_exists() { + let db = Arc::new(MemoryDB::open()); + let store = BeaconBlockStore::new(db.clone()); + + let ssz = "some bytes".as_bytes(); + let hash = &Hash256::from("some hash".as_bytes()).to_vec(); + + db.put(DB_COLUMN, hash, ssz); + assert!(store.block_exists(hash).unwrap()); + } + + #[test] + fn test_block_doesnt_exist() { + let db = Arc::new(MemoryDB::open()); + let store = BeaconBlockStore::new(db.clone()); + + let ssz = "some bytes".as_bytes(); + let hash = &Hash256::from("some hash".as_bytes()).to_vec(); + let other_hash = &Hash256::from("another hash".as_bytes()).to_vec(); + + db.put(DB_COLUMN, hash, ssz); + assert!(!store.block_exists(other_hash).unwrap()); + } + + #[test] + fn test_delete_block() { + let db = Arc::new(MemoryDB::open()); + let store = BeaconBlockStore::new(db.clone()); + + let ssz = "some bytes".as_bytes(); + let hash = &Hash256::from("some hash".as_bytes()).to_vec(); + + db.put(DB_COLUMN, hash, ssz); + assert!(db.exists(DB_COLUMN, hash).unwrap()); + + store.delete_block(hash); + assert!(!db.exists(DB_COLUMN, hash).unwrap()); + } + #[test] fn test_block_store_on_memory_db() { let db = Arc::new(MemoryDB::open()); From 9148c20630b136e4cc7a046cd527c815a1902e07 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sun, 18 Nov 2018 16:31:22 -0600 Subject: [PATCH 05/10] fixed warnings --- lighthouse/db/src/stores/beacon_block_store.rs | 12 ++++++------ lighthouse/db/src/stores/pow_chain_store.rs | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lighthouse/db/src/stores/beacon_block_store.rs b/lighthouse/db/src/stores/beacon_block_store.rs index a60dc435e..615c8fbe7 100644 --- a/lighthouse/db/src/stores/beacon_block_store.rs +++ b/lighthouse/db/src/stores/beacon_block_store.rs @@ -104,7 +104,7 @@ mod tests { let ssz = "some bytes".as_bytes(); let hash = &Hash256::from("some hash".as_bytes()).to_vec(); - store.put_serialized_block(hash, ssz); + store.put_serialized_block(hash, ssz).unwrap(); assert_eq!(db.get(DB_COLUMN, hash).unwrap().unwrap(), ssz); } @@ -116,7 +116,7 @@ mod tests { let ssz = "some bytes".as_bytes(); let hash = &Hash256::from("some hash".as_bytes()).to_vec(); - db.put(DB_COLUMN, hash, ssz); + db.put(DB_COLUMN, hash, ssz).unwrap(); assert_eq!(store.get_serialized_block(hash).unwrap().unwrap(), ssz); } @@ -128,7 +128,7 @@ mod tests { let ssz = "some bytes".as_bytes(); let hash = &Hash256::from("some hash".as_bytes()).to_vec(); - db.put(DB_COLUMN, hash, ssz); + db.put(DB_COLUMN, hash, ssz).unwrap(); assert!(store.block_exists(hash).unwrap()); } @@ -141,7 +141,7 @@ mod tests { let hash = &Hash256::from("some hash".as_bytes()).to_vec(); let other_hash = &Hash256::from("another hash".as_bytes()).to_vec(); - db.put(DB_COLUMN, hash, ssz); + db.put(DB_COLUMN, hash, ssz).unwrap(); assert!(!store.block_exists(other_hash).unwrap()); } @@ -153,10 +153,10 @@ mod tests { let ssz = "some bytes".as_bytes(); let hash = &Hash256::from("some hash".as_bytes()).to_vec(); - db.put(DB_COLUMN, hash, ssz); + db.put(DB_COLUMN, hash, ssz).unwrap(); assert!(db.exists(DB_COLUMN, hash).unwrap()); - store.delete_block(hash); + store.delete_block(hash).unwrap(); assert!(!db.exists(DB_COLUMN, hash).unwrap()); } diff --git a/lighthouse/db/src/stores/pow_chain_store.rs b/lighthouse/db/src/stores/pow_chain_store.rs index 382667ea0..493df47f8 100644 --- a/lighthouse/db/src/stores/pow_chain_store.rs +++ b/lighthouse/db/src/stores/pow_chain_store.rs @@ -26,7 +26,7 @@ impl PoWChainStore { #[cfg(test)] mod tests { extern crate rand; - + use super::*; use super::super::super::MemoryDB; @@ -36,7 +36,7 @@ mod tests { let store = PoWChainStore::new(db.clone()); let hash: &[u8] = &[rand::random()]; - store.put_block_hash(hash); + store.put_block_hash(hash).unwrap(); assert!(db.exists(DB_COLUMN, hash).unwrap()); } @@ -47,7 +47,7 @@ mod tests { let store = PoWChainStore::new(db.clone()); let hash: &[u8] = &[rand::random()]; - db.put(DB_COLUMN, hash, &[0]); + db.put(DB_COLUMN, hash, &[0]).unwrap(); assert!(store.block_hash_exists(hash).unwrap()); } @@ -59,7 +59,7 @@ mod tests { let hash: &[u8] = &[rand::random()]; let other_hash: &[u8] = &[rand::random()]; - db.put(DB_COLUMN, hash, &[0]); + db.put(DB_COLUMN, hash, &[0]).unwrap(); assert!(!store.block_hash_exists(other_hash).unwrap()); } From 325e1b3f0a3e878aa3dfcc0e20f31c134fe26709 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sun, 18 Nov 2018 16:38:15 -0600 Subject: [PATCH 06/10] different hashes in pow store --- lighthouse/db/src/stores/pow_chain_store.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lighthouse/db/src/stores/pow_chain_store.rs b/lighthouse/db/src/stores/pow_chain_store.rs index 493df47f8..aa2b267f7 100644 --- a/lighthouse/db/src/stores/pow_chain_store.rs +++ b/lighthouse/db/src/stores/pow_chain_store.rs @@ -25,17 +25,19 @@ impl PoWChainStore { #[cfg(test)] mod tests { - extern crate rand; - + extern crate types; + use super::*; use super::super::super::MemoryDB; + use self::types::Hash256; + #[test] fn test_put_block_hash() { let db = Arc::new(MemoryDB::open()); let store = PoWChainStore::new(db.clone()); - let hash: &[u8] = &[rand::random()]; + let hash = &Hash256::from("some hash".as_bytes()).to_vec(); store.put_block_hash(hash).unwrap(); assert!(db.exists(DB_COLUMN, hash).unwrap()); @@ -46,7 +48,7 @@ mod tests { let db = Arc::new(MemoryDB::open()); let store = PoWChainStore::new(db.clone()); - let hash: &[u8] = &[rand::random()]; + let hash = &Hash256::from("some hash".as_bytes()).to_vec(); db.put(DB_COLUMN, hash, &[0]).unwrap(); assert!(store.block_hash_exists(hash).unwrap()); @@ -57,8 +59,8 @@ mod tests { let db = Arc::new(MemoryDB::open()); let store = PoWChainStore::new(db.clone()); - let hash: &[u8] = &[rand::random()]; - let other_hash: &[u8] = &[rand::random()]; + let hash = &Hash256::from("some hash".as_bytes()).to_vec(); + let other_hash = &Hash256::from("another hash".as_bytes()).to_vec(); db.put(DB_COLUMN, hash, &[0]).unwrap(); assert!(!store.block_hash_exists(other_hash).unwrap()); From 74ad689c21b59da89e44a2eab199f5f8487b577e Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sun, 18 Nov 2018 16:39:55 -0600 Subject: [PATCH 07/10] removed cargo dep --- lighthouse/db/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/lighthouse/db/Cargo.toml b/lighthouse/db/Cargo.toml index 0d0bf4a2e..a2718889c 100644 --- a/lighthouse/db/Cargo.toml +++ b/lighthouse/db/Cargo.toml @@ -11,4 +11,3 @@ rocksdb = "0.10.1" ssz = { path = "../../beacon_chain/utils/ssz" } ssz_helpers = { path = "../../beacon_chain/utils/ssz_helpers" } types = { path = "../../beacon_chain/types" } -rand = "0.5.5" From 1c5d04d727919f7b8ea633360f8f10225dd801c6 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Tue, 20 Nov 2018 19:49:38 -0600 Subject: [PATCH 08/10] a few more tests --- .../db/src/stores/beacon_block_store.rs | 38 +++++++++++++++++++ lighthouse/db/src/stores/validator_store.rs | 30 +++++++-------- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/lighthouse/db/src/stores/beacon_block_store.rs b/lighthouse/db/src/stores/beacon_block_store.rs index 615c8fbe7..21cd2abc8 100644 --- a/lighthouse/db/src/stores/beacon_block_store.rs +++ b/lighthouse/db/src/stores/beacon_block_store.rs @@ -120,6 +120,19 @@ mod tests { assert_eq!(store.get_serialized_block(hash).unwrap().unwrap(), ssz); } + #[test] + fn test_get_none_serialized_block() { + let db = Arc::new(MemoryDB::open()); + let store = BeaconBlockStore::new(db.clone()); + + let ssz = "some bytes".as_bytes(); + let hash = &Hash256::from("some hash".as_bytes()).to_vec(); + let other_hash = &Hash256::from("another hash".as_bytes()).to_vec(); + + db.put(DB_COLUMN, other_hash, ssz).unwrap(); + assert_eq!(store.get_serialized_block(hash).unwrap(), None); + } + #[test] fn test_block_exists() { let db = Arc::new(MemoryDB::open()); @@ -160,6 +173,31 @@ mod tests { assert!(!db.exists(DB_COLUMN, hash).unwrap()); } + #[test] + fn test_invalid_block_at_slot() { + let db = Arc::new(MemoryDB::open()); + let store = BeaconBlockStore::new(db.clone()); + + let ssz = "definitly not a valid block".as_bytes(); + let hash = &Hash256::from("some hash".as_bytes()).to_vec(); + + db.put(DB_COLUMN, hash, ssz).unwrap(); + assert_eq!(store.block_at_slot(hash, 42), Err(BeaconBlockAtSlotError::InvalidBeaconBlock)); + } + + #[test] + fn test_unknown_block_at_slot() { + let db = Arc::new(MemoryDB::open()); + let store = BeaconBlockStore::new(db.clone()); + + let ssz = "some bytes".as_bytes(); + let hash = &Hash256::from("some hash".as_bytes()).to_vec(); + let other_hash = &Hash256::from("another hash".as_bytes()).to_vec(); + + db.put(DB_COLUMN, hash, ssz).unwrap(); + assert_eq!(store.block_at_slot(other_hash, 42), Err(BeaconBlockAtSlotError::UnknownBeaconBlock)); + } + #[test] fn test_block_store_on_memory_db() { let db = Arc::new(MemoryDB::open()); diff --git a/lighthouse/db/src/stores/validator_store.rs b/lighthouse/db/src/stores/validator_store.rs index 1970cf4fd..a802a0d0e 100644 --- a/lighthouse/db/src/stores/validator_store.rs +++ b/lighthouse/db/src/stores/validator_store.rs @@ -98,7 +98,7 @@ mod tests { assert_eq!(public_key_at_index, public_key.as_bytes()); } - + #[test] fn test_get_public_key_by_index() { let db = Arc::new(MemoryDB::open()); @@ -134,6 +134,20 @@ mod tests { assert_eq!(public_key_at_index, None); } + #[test] + fn test_get_invalid_public_key() { + let db = Arc::new(MemoryDB::open()); + let store = ValidatorStore::new(db.clone()); + + let key = store.get_db_key_for_index(&KeyPrefixes::PublicKey, 42); + db.put(DB_COLUMN, &key[..], "cats".as_bytes()).unwrap(); + + assert_eq!( + store.get_public_key_by_index(42), + Err(ValidatorStoreError::DecodeError) + ); + } + #[test] fn test_validator_store_put_get() { let db = Arc::new(MemoryDB::open()); @@ -169,18 +183,4 @@ mod tests { .is_none() ); } - - #[test] - fn test_validator_store_bad_key() { - let db = Arc::new(MemoryDB::open()); - let store = ValidatorStore::new(db.clone()); - - let key = store.get_db_key_for_index(&KeyPrefixes::PublicKey, 42); - db.put(DB_COLUMN, &key[..], "cats".as_bytes()).unwrap(); - - assert_eq!( - store.get_public_key_by_index(42), - Err(ValidatorStoreError::DecodeError) - ); - } } From 1bd60062d96b0bf97c48318a6c263585a1c7826e Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Tue, 20 Nov 2018 19:51:43 -0600 Subject: [PATCH 09/10] renamed a couple tests --- lighthouse/db/src/stores/beacon_block_store.rs | 4 ++-- lighthouse/db/src/stores/validator_store.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lighthouse/db/src/stores/beacon_block_store.rs b/lighthouse/db/src/stores/beacon_block_store.rs index 21cd2abc8..54c8b7f9c 100644 --- a/lighthouse/db/src/stores/beacon_block_store.rs +++ b/lighthouse/db/src/stores/beacon_block_store.rs @@ -121,7 +121,7 @@ mod tests { } #[test] - fn test_get_none_serialized_block() { + fn test_get_unknown_serialized_block() { let db = Arc::new(MemoryDB::open()); let store = BeaconBlockStore::new(db.clone()); @@ -146,7 +146,7 @@ mod tests { } #[test] - fn test_block_doesnt_exist() { + fn test_block_does_not_exist() { let db = Arc::new(MemoryDB::open()); let store = BeaconBlockStore::new(db.clone()); diff --git a/lighthouse/db/src/stores/validator_store.rs b/lighthouse/db/src/stores/validator_store.rs index a802a0d0e..6e5c960ba 100644 --- a/lighthouse/db/src/stores/validator_store.rs +++ b/lighthouse/db/src/stores/validator_store.rs @@ -98,7 +98,7 @@ mod tests { assert_eq!(public_key_at_index, public_key.as_bytes()); } - + #[test] fn test_get_public_key_by_index() { let db = Arc::new(MemoryDB::open()); @@ -118,7 +118,7 @@ mod tests { } #[test] - fn test_get_public_key_by_invalid_index() { + fn test_get_public_key_by_unknown_index() { let db = Arc::new(MemoryDB::open()); let store = ValidatorStore::new(db.clone()); From f64aa9e19253b7f22e56fd37fc0a7a0325cb3664 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sun, 2 Dec 2018 19:21:17 -0600 Subject: [PATCH 10/10] more validator tests --- .../db/src/stores/beacon_block_store.rs | 2 +- lighthouse/db/src/stores/validator_store.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lighthouse/db/src/stores/beacon_block_store.rs b/lighthouse/db/src/stores/beacon_block_store.rs index 54c8b7f9c..84cea2d0d 100644 --- a/lighthouse/db/src/stores/beacon_block_store.rs +++ b/lighthouse/db/src/stores/beacon_block_store.rs @@ -273,7 +273,7 @@ mod tests { let mut s = SszStream::new(); s.append(&block); let ssz = s.drain(); - bs.put_serialized_block(&hashes[i].to_vec(), &ssz).unwrap(); + db.put(DB_COLUMN, &hashes[i].to_vec(), &ssz).unwrap(); } let tuple = bs.block_at_slot(&hashes[4], 5).unwrap().unwrap(); diff --git a/lighthouse/db/src/stores/validator_store.rs b/lighthouse/db/src/stores/validator_store.rs index 6e5c960ba..518d92608 100644 --- a/lighthouse/db/src/stores/validator_store.rs +++ b/lighthouse/db/src/stores/validator_store.rs @@ -82,6 +82,25 @@ mod tests { use super::super::bls::Keypair; use super::*; + #[test] + fn test_prefix_bytes() { + let db = Arc::new(MemoryDB::open()); + let store = ValidatorStore::new(db.clone()); + + assert_eq!(store.prefix_bytes(&KeyPrefixes::PublicKey), b"pubkey".to_vec()); + } + + #[test] + fn test_get_db_key_for_index() { + let db = Arc::new(MemoryDB::open()); + let store = ValidatorStore::new(db.clone()); + + let mut buf = BytesMut::with_capacity(6 + 8); + buf.put(b"pubkey".to_vec()); + buf.put_u64_be(42); + assert_eq!(store.get_db_key_for_index(&KeyPrefixes::PublicKey, 42), buf.take().to_vec()) + } + #[test] fn test_put_public_key_by_index() { let db = Arc::new(MemoryDB::open());