From 14e479f02211b2d0808995b261681ad6e6649824 Mon Sep 17 00:00:00 2001 From: Rim Rakhimov Date: Thu, 12 Dec 2024 20:10:46 +0400 Subject: [PATCH] refactor(verifier-alliance-database): bump blockscout-service-launcher to v0.15.0; make use of its version of 'database' initialization macros --- eth-bytecode-db/Cargo.lock | 6 +++--- eth-bytecode-db/Cargo.toml | 2 +- .../eth-bytecode-db-server/Cargo.toml | 2 +- .../tests/integration/contract_deployments.rs | 9 +++++---- .../integration/internal_compiled_contracts.rs | 7 ++++--- .../tests/integration/main.rs | 18 ------------------ .../tests/integration/transformations.rs | 6 ++++-- .../tests/integration/verified_contracts.rs | 11 ++++++----- 8 files changed, 24 insertions(+), 37 deletions(-) diff --git a/eth-bytecode-db/Cargo.lock b/eth-bytecode-db/Cargo.lock index 3ae66638a..58dbb2724 100644 --- a/eth-bytecode-db/Cargo.lock +++ b/eth-bytecode-db/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "Inflector" @@ -1187,9 +1187,9 @@ dependencies = [ [[package]] name = "blockscout-service-launcher" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a63d6b6e01527cefc2c82f2ef1b874817d4d6cb51f9bacffd116a94917387dc6" +checksum = "98faf66096af3a77362da42c2861e59427187b8f1687f482cb4d04465176d3d0" dependencies = [ "actix-cors", "actix-web", diff --git a/eth-bytecode-db/Cargo.toml b/eth-bytecode-db/Cargo.toml index 8986093e1..72a63f7ff 100644 --- a/eth-bytecode-db/Cargo.toml +++ b/eth-bytecode-db/Cargo.toml @@ -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" } diff --git a/eth-bytecode-db/eth-bytecode-db-server/Cargo.toml b/eth-bytecode-db/eth-bytecode-db-server/Cargo.toml index 22113fa30..774a39ccc 100644 --- a/eth-bytecode-db/eth-bytecode-db-server/Cargo.toml +++ b/eth-bytecode-db/eth-bytecode-db-server/Cargo.toml @@ -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"] } diff --git a/eth-bytecode-db/verifier-alliance-database/tests/integration/contract_deployments.rs b/eth-bytecode-db/verifier-alliance-database/tests/integration/contract_deployments.rs index b64c02b29..bee3ccc2c 100644 --- a/eth-bytecode-db/verifier-alliance-database/tests/integration/contract_deployments.rs +++ b/eth-bytecode-db/verifier-alliance-database/tests/integration/contract_deployments.rs @@ -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(); @@ -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(); @@ -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]); diff --git a/eth-bytecode-db/verifier-alliance-database/tests/integration/internal_compiled_contracts.rs b/eth-bytecode-db/verifier-alliance-database/tests/integration/internal_compiled_contracts.rs index 4d2745a6c..30ca667a7 100644 --- a/eth-bytecode-db/verifier-alliance-database/tests/integration/internal_compiled_contracts.rs +++ b/eth-bytecode-db/verifier-alliance-database/tests/integration/internal_compiled_contracts.rs @@ -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::{ @@ -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, @@ -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, diff --git a/eth-bytecode-db/verifier-alliance-database/tests/integration/main.rs b/eth-bytecode-db/verifier-alliance-database/tests/integration/main.rs index 7af8ca08a..a6b7e2b14 100644 --- a/eth-bytecode-db/verifier-alliance-database/tests/integration/main.rs +++ b/eth-bytecode-db/verifier-alliance-database/tests/integration/main.rs @@ -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; diff --git a/eth-bytecode-db/verifier-alliance-database/tests/integration/transformations.rs b/eth-bytecode-db/verifier-alliance-database/tests/integration/transformations.rs index a19c11bb6..4bfdbfd1f 100644 --- a/eth-bytecode-db/verifier-alliance-database/tests/integration/transformations.rs +++ b/eth-bytecode-db/verifier-alliance-database/tests/integration/transformations.rs @@ -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) => { @@ -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); diff --git a/eth-bytecode-db/verifier-alliance-database/tests/integration/verified_contracts.rs b/eth-bytecode-db/verifier-alliance-database/tests/integration/verified_contracts.rs index e3cd63807..82f537edb 100644 --- a/eth-bytecode-db/verifier-alliance-database/tests/integration/verified_contracts.rs +++ b/eth-bytecode-db/verifier-alliance-database/tests/integration/verified_contracts.rs @@ -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; @@ -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(); @@ -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(); @@ -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(); @@ -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();