Skip to content

Commit

Permalink
refactor(verifier-alliance-database): bump blockscout-service-launche…
Browse files Browse the repository at this point in the history
…r to v0.15.0; make use of its version of 'database' initialization macros
  • Loading branch information
rimrakhimov committed Dec 12, 2024
1 parent ef48d51 commit 14e479f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 37 deletions.
6 changes: 3 additions & 3 deletions eth-bytecode-db/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion eth-bytecode-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ anyhow = { version = "1" }
async-std = { version = "^1" }
async-trait = { version = "0.1" }
blockscout-display-bytes = { version = "1.1.0" }
blockscout-service-launcher = { version = "0.14.0", features = ["database-1_0"] }
blockscout-service-launcher = { version = "0.15.0", default-features = false, features = ["database-1_0"] }
bytes = { version = "1.2" }
ethabi = { version = "18.0" }
ethers = { version = "2.0.0" }
Expand Down
2 changes: 1 addition & 1 deletion eth-bytecode-db/eth-bytecode-db-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ amplify = { workspace = true }
anyhow = { workspace = true }
async-trait = { workspace = true }
blockscout-display-bytes = { workspace = true }
blockscout-service-launcher = { workspace = true }
blockscout-service-launcher = { workspace = true, features = ["launcher", "tracing"] }
eth-bytecode-db = { workspace = true }
eth-bytecode-db-proto = { workspace = true }
ethers = { workspace = true, features = ["solc"] }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::database;
use blockscout_display_bytes::decode_hex;
use blockscout_service_launcher::test_database::database;
use pretty_assertions::assert_eq;
use verifier_alliance_database::{InsertContractDeployment, RetrieveContractDeployment};
use verifier_alliance_migration_v1::Migrator;

#[tokio::test]
async fn insert_regular_deployment_works_and_can_be_retrieved() {
let db_guard = database!();
let db_guard = database!(Migrator);

let chain_id = 10;
let address = decode_hex("0x8FbB39A5a79aeCE03c8f13ccEE0b96C128ec1a67").unwrap();
Expand Down Expand Up @@ -51,7 +52,7 @@ async fn insert_regular_deployment_works_and_can_be_retrieved() {

#[tokio::test]
async fn insert_genesis_deployment_works_and_can_be_retrieved() {
let db_guard = database!();
let db_guard = database!(Migrator);

let chain_id = 10;
let address = decode_hex("0x4200000000000000000000000000000000000008").unwrap();
Expand Down Expand Up @@ -91,7 +92,7 @@ async fn insert_genesis_deployment_works_and_can_be_retrieved() {

#[tokio::test]
async fn non_existed_deployment_retrieval_returns_none() {
let db_guard = database!();
let db_guard = database!(Migrator);

let retrieve_contract_deployment =
RetrieveContractDeployment::regular(10, vec![0x1], vec![0x1]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::database;
use blockscout_service_launcher::test_database::database;
use serde_json::json;
use std::collections::BTreeMap;
use verification_common_v1::verifier_alliance::{
Expand All @@ -7,10 +7,11 @@ use verification_common_v1::verifier_alliance::{
use verifier_alliance_database::{
internal, CompiledContract, CompiledContractCompiler, CompiledContractLanguage,
};
use verifier_alliance_migration_v1::Migrator;

#[tokio::test]
async fn insert_compiled_contract_works() {
let db_guard = database!();
let db_guard = database!(Migrator);

let compiled_contract = CompiledContract {
compiler: CompiledContractCompiler::Solc,
Expand Down Expand Up @@ -53,7 +54,7 @@ async fn insert_compiled_contract_works() {

#[tokio::test]
async fn insert_compiled_contract_with_empty_artifact_values() {
let db_guard = database!();
let db_guard = database!(Migrator);

let compiled_contract = CompiledContract {
compiler: CompiledContractCompiler::Solc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,3 @@ mod internal_compiled_contracts;
mod transformations;
mod transformations_types;
mod verified_contracts;

macro_rules! database {
() => {{
let database_name = format!("{}_{}_{}", file!(), line!(), column!());
blockscout_service_launcher::test_database::TestDbGuard::new::<
verifier_alliance_migration_v1::Migrator,
>(&database_name)
.await
}};
($custom_suffix:expr) => {{
let database_name = format!("{}_{}_{}_{}", file!(), line!(), column!(), $custom_suffix);
blockscout_service_launcher::test_database::TestDbGuard::new::<
verifier_alliance_migration_v1::Migrator,
>(&database_name)
.await
}};
}
pub(crate) use database;
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::{database, transformations_types::TestCase};
use crate::transformations_types::TestCase;
use blockscout_service_launcher::test_database::database;
use verifier_alliance_database::{insert_contract_deployment, insert_verified_contract};
use verifier_alliance_migration_v1::Migrator;

macro_rules! build_test {
($test_name:ident) => {
Expand All @@ -11,7 +13,7 @@ macro_rules! build_test {
".json"
));

let database_guard = database!();
let database_guard = database!(Migrator);
let database_connection = database_guard.client();

let test_case = TestCase::from_content(TEST_CASE_CONTENT);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::database;
use blockscout_display_bytes::decode_hex;
use blockscout_service_launcher::test_database::database;
use sea_orm::{prelude::Uuid, DatabaseConnection};
use serde_json::json;
use std::collections::BTreeMap;
Expand All @@ -11,10 +11,11 @@ use verifier_alliance_database::{
CompiledContract, CompiledContractCompiler, CompiledContractLanguage, InsertContractDeployment,
VerifiedContract, VerifiedContractMatches,
};
use verifier_alliance_migration_v1::Migrator;

#[tokio::test]
async fn insert_verified_contract_with_complete_matches_work() {
let db_guard = database!();
let db_guard = database!(Migrator);

let contract_deployment_id = insert_contract_deployment(db_guard.client().as_ref()).await;
let compiled_contract = complete_compiled_contract();
Expand Down Expand Up @@ -45,7 +46,7 @@ async fn insert_verified_contract_with_complete_matches_work() {

#[tokio::test]
async fn insert_verified_contract_with_runtime_only_matches_work() {
let db_guard = database!();
let db_guard = database!(Migrator);

let contract_deployment_id = insert_contract_deployment(db_guard.client().as_ref()).await;
let compiled_contract = complete_compiled_contract();
Expand All @@ -71,7 +72,7 @@ async fn insert_verified_contract_with_runtime_only_matches_work() {

#[tokio::test]
async fn insert_verified_contract_with_creation_only_matches_work() {
let db_guard = database!();
let db_guard = database!(Migrator);

let contract_deployment_id = insert_contract_deployment(db_guard.client().as_ref()).await;
let compiled_contract = complete_compiled_contract();
Expand All @@ -97,7 +98,7 @@ async fn insert_verified_contract_with_creation_only_matches_work() {

#[tokio::test]
async fn insert_verified_contract_with_filled_matches() {
let db_guard = database!();
let db_guard = database!(Migrator);

let contract_deployment_id = insert_contract_deployment(db_guard.client().as_ref()).await;
let compiled_contract = complete_compiled_contract();
Expand Down

0 comments on commit 14e479f

Please sign in to comment.