Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat : job handler tests #67

Merged
merged 52 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
726f1ed
feat : added tests for increasing coverage
ocdbytes Jul 23, 2024
b3a80b0
feat : added mongo db tests and fixtures and updated the ci for tests
ocdbytes Jul 24, 2024
5826d44
update : removed unwanted fixtures
ocdbytes Jul 24, 2024
0e70fff
update : removed unwanted fixtures
ocdbytes Jul 24, 2024
97f1f21
update : added mongo db runner in ci
ocdbytes Jul 24, 2024
a64613c
update : added mongo db runner in ci
ocdbytes Jul 24, 2024
db472d5
update : added mongo db runner in ci
ocdbytes Jul 24, 2024
15541ef
update : updated with new changes and ci
ocdbytes Jul 25, 2024
fc7d493
update : updated test cases for s3 client
ocdbytes Jul 26, 2024
9a101ba
update : added .env.test file in the commit
ocdbytes Jul 26, 2024
906a1eb
feat : added database necessary tests
ocdbytes Jul 26, 2024
65d66e6
feat : added database necessary tests
ocdbytes Jul 26, 2024
20d82c3
Revert "feat : added database necessary tests"
ocdbytes Jul 26, 2024
63bc846
Revert "feat : added database necessary tests"
ocdbytes Jul 26, 2024
f36b483
update: Replaced Build_Config Fixture with TestConfigBuilder
heemankv Jul 26, 2024
8b7e68f
update : config update
ocdbytes Jul 26, 2024
74fea52
update : test_put_and_get_data_s3 test
ocdbytes Jul 26, 2024
385974d
update: moved testconfigbuilder to tests/config.rs & added docs , dro…
heemankv Jul 29, 2024
eb43d49
feat : create job test case error returning
ocdbytes Jul 30, 2024
a79b633
mock job handler
apoorvsadana Jul 30, 2024
2209405
merge main
ocdbytes Jul 30, 2024
c01c990
Merge branch 'main' into feat/increasing-test-coverage
heemankv Jul 31, 2024
e026d8d
feat : added jobs test and modified worker tests
ocdbytes Jul 31, 2024
661adaf
feat : added queue checks to tests and revamped some tests
ocdbytes Aug 1, 2024
dc05623
Merge branch 'feat/increasing-test-coverage' into feat/job_tests_global
ocdbytes Aug 1, 2024
6ecef60
feat : updated tests and resolved comments
ocdbytes Aug 2, 2024
b31212c
feat : updated test config and added config type to aws s3 config
ocdbytes Aug 2, 2024
ad585f1
feat : updated tests and test names
ocdbytes Aug 2, 2024
57b21af
Merge branch 'feat/increasing-test-coverage' into feat/job_tests_global
ocdbytes Aug 2, 2024
b3de1a2
feat : lint fixes
ocdbytes Aug 3, 2024
cd5e9e8
Merge branch 'main' into feat/job_tests_global
ocdbytes Aug 3, 2024
763379e
feat : lint fixes
ocdbytes Aug 3, 2024
ec61d72
feat : lint fixes
ocdbytes Aug 3, 2024
ae2d4d9
chore: resolved pr comments
ocdbytes Aug 3, 2024
67141ba
Update crates/orchestrator/src/tests/database/mod.rs
ocdbytes Aug 3, 2024
6c9b68e
Merge branch 'main' into feat/increasing-test-coverage
ocdbytes Aug 3, 2024
26df776
chore : lint fixes
ocdbytes Aug 3, 2024
20a480e
feat : lint fix
ocdbytes Aug 3, 2024
7f01895
fix : coverage tests fix
ocdbytes Aug 5, 2024
44aecd7
fix : test fix
ocdbytes Aug 5, 2024
2de874d
fix : updated region in localstack .env.test
ocdbytes Aug 5, 2024
ea867ae
feat : updated region
ocdbytes Aug 5, 2024
0887de5
debug : added debug log to github ci
ocdbytes Aug 5, 2024
d6e31cb
feat : updated queue code for test fixes
ocdbytes Aug 5, 2024
a6d9255
fix : sqs region fix
ocdbytes Aug 5, 2024
fa91ccb
debug : added debug logs for ci debugging
ocdbytes Aug 5, 2024
2f6283e
feat : added override endpoint to queue url in producer and consumer
ocdbytes Aug 5, 2024
b1b9c9f
feat : added override endpoint to queue url in producer and consumer
ocdbytes Aug 5, 2024
4ab388f
fix : removed logs and refactored the code
ocdbytes Aug 5, 2024
c4aef5d
chore : refactor code
ocdbytes Aug 6, 2024
e27de07
Merge branch 'feat/increasing-test-coverage' into feat/job_tests_global
ocdbytes Aug 6, 2024
53e9213
Merge branch 'main' into feat/job_tests_global
ocdbytes Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
##### AWS config #####

AWS_ACCESS_KEY_ID="AWS_ACCESS_KEY_ID"
AWS_SECRET_ACCESS_KEY="AWS_SECRET_ACCESS_KEY"
AWS_S3_BUCKET_NAME="madara-orchestrator-test-bucket"
AWS_S3_BUCKET_REGION="us-east-1"
AWS_ENDPOINT_URL="http://localhost.localstack.cloud:4566"

##### On chain config #####

MADARA_RPC_URL="http://localhost:3000"
ETHEREUM_RPC_URL="http://localhost:3001"
MEMORY_PAGES_CONTRACT_ADDRESS="0x000000000000000000000000000000000001dead"
PRIVATE_KEY="0xdead"
ETHEREUM_PRIVATE_KEY="0x000000000000000000000000000000000000000000000000000000000000beef"
STARKNET_SOLIDITY_CORE_CONTRACT_ADDRESS="0x000000000000000000000000000000000002dead"

##### Config URLs #####

DA_LAYER="ethereum"
PROVER_SERVICE="sharp"
SETTLEMENT_LAYER="ethereum"
DATA_STORAGE="s3"
MONGODB_CONNECTION_STRING="mongodb://localhost:27017"
15 changes: 15 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ jobs:
# sadly, for now we have to "rebuild" for the coverage
runs-on: ubuntu-latest

services:
localstack:
image: localstack/localstack
env:
SERVICES: s3, sqs
DEFAULT_REGION: us-east-1
AWS_ACCESS_KEY_ID: "AWS_ACCESS_KEY_ID"
AWS_SECRET_ACCESS_KEY: "AWS_SECRET_ACCESS_KEY"
ports:
- 4566:4566
mongodb:
image: mongo:latest
ports:
- 27017:27017

steps:
- uses: actions/checkout@v3

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- Function to calculate the kzg proof of x_0.
- Tests for updating the state.
- Function to update the state and publish blob on ethereum in state update job.
- Tests for job handlers in orchestrator/src/jobs/mod.rs.
- Fixtures for testing.
- Added basic rust-toolchain support.

## Changed

- GitHub's coverage CI yml file for localstack and db testing.
- Orchestrator :Moved TestConfigBuilder to `config.rs` in tests folder.

## Removed

- `fetch_from_test` argument
Expand Down
84 changes: 62 additions & 22 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ utils = { path = "crates/utils" }
prover-client-interface = { path = "crates/prover-services/prover-client-interface" }
gps-fact-checker = { path = "crates/prover-services/gps-fact-checker" }
sharp-service = { path = "crates/prover-services/sharp-service" }
orchestrator = { path = "crates/orchestrator" }
orchestrator = { path = "crates/orchestrator" }
4 changes: 3 additions & 1 deletion crates/da-clients/ethereum/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::str::FromStr;

use alloy::{network::Ethereum, providers::ProviderBuilder, rpc::client::RpcClient};
use alloy::network::Ethereum;
use alloy::providers::ProviderBuilder;
use alloy::rpc::client::RpcClient;
apoorvsadana marked this conversation as resolved.
Show resolved Hide resolved
use async_trait::async_trait;
use da_client_interface::DaConfig;
use url::Url;
Expand Down
4 changes: 2 additions & 2 deletions crates/da-clients/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub struct EthereumDaClient {
#[async_trait]
impl DaClient for EthereumDaClient {
async fn publish_state_diff(&self, _state_diff: Vec<Vec<u8>>, _to: &[u8; 32]) -> Result<String> {
// Here in case of ethereum we are not publishing the state diff because we are doing it all together in update_state job.
// So we don't need to send the blob here.
// Here in case of ethereum we are not publishing the state diff because we are doing it all
// together in update_state job. So we don't need to send the blob here.
Ok("NA".to_string())
}

Expand Down
4 changes: 3 additions & 1 deletion crates/orchestrator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ arc-swap = { workspace = true }
async-std = "1.12.0"
async-trait = { workspace = true }
aws-config = { version = "1.1.7", features = ["behavior-version-latest"] }
aws-sdk-sqs = "1.36.0"
aws-sdk-s3 = { version = "1.38.0", features = ["behavior-version-latest"] }
axum = { workspace = true, features = ["macros"] }
axum-macros = { workspace = true }
Expand All @@ -35,7 +36,8 @@ lazy_static = { workspace = true }
log = "0.4.21"
majin-blob-core = { git = "https://github.com/AbdelStark/majin-blob", branch = "main" }
majin-blob-types = { git = "https://github.com/AbdelStark/majin-blob", branch = "main" }
mockall = "0.12.1"
mockall = { version = "0.13.0" }
mockall_double = "0.3.1"
mongodb = { workspace = true, features = ["bson-uuid-1"], optional = true }
num = { workspace = true }
num-bigint = { workspace = true }
Expand Down
16 changes: 9 additions & 7 deletions crates/orchestrator/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use std::sync::Arc;

use crate::data_storage::aws_s3::config::AWSS3Config;
use crate::data_storage::aws_s3::AWSS3;
use crate::data_storage::{DataStorage, DataStorageConfig};
use arc_swap::{ArcSwap, Guard};
use da_client_interface::{DaClient, DaConfig};
use dotenvy::dotenv;
Expand All @@ -19,6 +16,9 @@ use utils::env_utils::get_env_var_or_panic;
use utils::settings::default::DefaultSettingsProvider;
use utils::settings::SettingsProvider;

use crate::data_storage::aws_s3::config::AWSS3Config;
use crate::data_storage::aws_s3::AWSS3;
use crate::data_storage::{DataStorage, DataStorageConfig};
use crate::database::mongodb::config::MongoDbConfig;
use crate::database::mongodb::MongoDb;
use crate::database::{Database, DatabaseConfig};
Expand Down Expand Up @@ -148,7 +148,7 @@ pub async fn config_force_init(config: Config) {
}

/// Builds the DA client based on the environment variable DA_LAYER
async fn build_da_client() -> Box<dyn DaClient + Send + Sync> {
pub async fn build_da_client() -> Box<dyn DaClient + Send + Sync> {
match get_env_var_or_panic("DA_LAYER").as_str() {
"ethereum" => {
let config = EthereumDaConfig::new_from_env();
Expand All @@ -159,23 +159,25 @@ async fn build_da_client() -> Box<dyn DaClient + Send + Sync> {
}

/// Builds the prover service based on the environment variable PROVER_SERVICE
fn build_prover_service(settings_provider: &impl SettingsProvider) -> Box<dyn ProverClient> {
pub fn build_prover_service(settings_provider: &impl SettingsProvider) -> Box<dyn ProverClient> {
match get_env_var_or_panic("PROVER_SERVICE").as_str() {
"sharp" => Box::new(SharpProverService::with_settings(settings_provider)),
_ => panic!("Unsupported prover service"),
}
}

/// Builds the settlement client depending on the env variable SETTLEMENT_LAYER
async fn build_settlement_client(settings_provider: &impl SettingsProvider) -> Box<dyn SettlementClient + Send + Sync> {
pub async fn build_settlement_client(
settings_provider: &impl SettingsProvider,
) -> Box<dyn SettlementClient + Send + Sync> {
match get_env_var_or_panic("SETTLEMENT_LAYER").as_str() {
"ethereum" => Box::new(EthereumSettlementClient::with_settings(settings_provider)),
"starknet" => Box::new(StarknetSettlementClient::with_settings(settings_provider).await),
_ => panic!("Unsupported Settlement layer"),
}
}

async fn build_storage_client() -> Box<dyn DataStorage + Send + Sync> {
pub async fn build_storage_client() -> Box<dyn DataStorage + Send + Sync> {
match get_env_var_or_panic("DATA_STORAGE").as_str() {
"s3" => Box::new(AWSS3::new(AWSS3Config::new_from_env()).await),
_ => panic!("Unsupported Storage Client"),
Expand Down
Loading