Skip to content

Commit

Permalink
update: more tests fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
heemankv committed Nov 7, 2024
1 parent 60f8495 commit 011d96c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 25 deletions.
10 changes: 5 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ DATABASE_NAME=
PROVER_SERVICE=
MADARA_ORCHESTRATOR_SHARP_CUSTOMER_ID=
MADARA_ORCHESTRATOR_SHARP_URL=
SHARP_USER_CRT=
SHARP_USER_KEY=
SHARP_SERVER_CRT=
SHARP_PROOF_LAYOUT=
MADARA_ORCHESTRATOR_SHARP_USER_CRT=
MADARA_ORCHESTRATOR_SHARP_USER_KEY=
MADARA_ORCHESTRATOR_SHARP_SERVER_CRT=
MADARA_ORCHESTRATOR_SHARP_PROOF_LAYOUT=

##### ON CHAIN CONFIG #####

DA_LAYER=
SETTLEMENT_LAYER=
SETTLEMENT_RPC_URL=
MADARA_ORCHESTRATOR_MADARA_RPC_URL=
GPS_VERIFIER_CONTRACT_ADDRESS=
MADARA_ORCHESTRATOR_GPS_VERIFIER_CONTRACT_ADDRESS=
PRIVATE_KEY=
ETHEREUM_PRIVATE_KEY=
L1_CORE_CONTRACT_ADDRESS=
Expand Down
2 changes: 1 addition & 1 deletion crates/orchestrator/src/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn custom_job_item(default_job_item: JobItem, #[default(String::from("0"))]

pub async fn create_sns_arn(provider_config: Arc<ProviderConfig>) -> Result<(), SdkError<CreateTopicError>> {
let sns_client = get_sns_client(provider_config.get_aws_client_or_panic()).await;
sns_client.create_topic().name(get_env_var_or_panic("AWS_SNS_ARN_NAME")).send().await?;
sns_client.create_topic().name(get_env_var_or_panic("MADARA_ORCHESTRATOR_AWS_SNS_ARN")).send().await?;
Ok(())
}

Expand Down
1 change: 0 additions & 1 deletion crates/orchestrator/src/tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::net::SocketAddr;
use std::sync::Arc;

use axum::Router;
use clap::Parser;
use da_client_interface::{DaClient, MockDaClient};
use ethereum_da_client::config::EthereumDaParams;
use ethereum_settlement_client::config::EthereumSettlementParams;
Expand Down
8 changes: 4 additions & 4 deletions crates/prover-services/sharp-service/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub struct SharpClient {
impl SharpClient {
/// We need to set up the client with the provided certificates.
/// We need to have three secrets :
/// - base64(SHARP_USER_CRT)
/// - base64(SHARP_USER_KEY)
/// - base64(SHARP_SERVER_CRT)
/// - base64(MADARA_ORCHESTRATOR_SHARP_USER_CRT)
/// - base64(MADARA_ORCHESTRATOR_SHARP_USER_KEY)
/// - base64(MADARA_ORCHESTRATOR_SHARP_SERVER_CRT)
///
/// You can run this command in terminal to convert a file output into base64
/// and then copy it and paste it into .env file :
Expand Down Expand Up @@ -69,7 +69,7 @@ impl SharpClient {

let cairo_key = Uuid::new_v4();
let cairo_key_string = cairo_key.to_string();
let proof_layout = get_env_var_or_panic("SHARP_PROOF_LAYOUT");
let proof_layout = get_env_var_or_panic("MADARA_ORCHESTRATOR_SHARP_PROOF_LAYOUT");

// Params for sending the PIE file to the prover
// for temporary reference you can check this doc :
Expand Down
10 changes: 5 additions & 5 deletions crates/prover-services/sharp-service/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ async fn prover_client_get_task_status_works(#[case] cairo_job_status: CairoJobS
sharp_customer_id: get_env_var_or_panic("MADARA_ORCHESTRATOR_SHARP_CUSTOMER_ID"),
sharp_url: Url::parse(&get_env_var_or_panic("MADARA_ORCHESTRATOR_SHARP_URL")).unwrap(),
sharp_user_crt: get_env_var_or_panic("SHARP_USER_CRT"),
sharp_user_key: get_env_var_or_panic("SHARP_USER_KEY"),
sharp_rpc_node_url: Url::parse(&get_env_var_or_panic("SHARP_RPC_NODE_URL")).unwrap(),
sharp_server_crt: get_env_var_or_panic("SHARP_SERVER_CRT"),
sharp_proof_layout: get_env_var_or_panic("SHARP_PROOF_LAYOUT"),
gps_verifier_contract_address: get_env_var_or_panic("GPS_VERIFIER_CONTRACT_ADDRESS"),
sharp_user_key: get_env_var_or_panic("MADARA_ORCHESTRATOR_SHARP_USER_KEY"),
sharp_rpc_node_url: Url::parse(&get_env_var_or_panic("MADARA_ORCHESTRATOR_SHARP_RPC_NODE_URL")).unwrap(),
sharp_server_crt: get_env_var_or_panic("MADARA_ORCHESTRATOR_SHARP_SERVER_CRT"),
sharp_proof_layout: get_env_var_or_panic("MADARA_ORCHESTRATOR_SHARP_PROOF_LAYOUT"),
gps_verifier_contract_address: get_env_var_or_panic("MADARA_ORCHESTRATOR_GPS_VERIFIER_CONTRACT_ADDRESS"),
};

let server = MockServer::start();
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ services:
- SQS_WORKER_TRIGGER_QUEUE_URL=${SQS_WORKER_TRIGGER_QUEUE_URL}
- ALERTS=${ALERTS:-sns}
- AWS_SNS_ARN=${AWS_SNS_ARN}
- AWS_SNS_ARN_NAME=${AWS_SNS_ARN_NAME}
- MADARA_ORCHESTRATOR_AWS_SNS_ARN=${MADARA_ORCHESTRATOR_AWS_SNS_ARN}
- DATABASE=${DATABASE:-mongodb}
- MONGODB_CONNECTION_STRING=${MONGODB_CONNECTION_STRING}
- PROVER_SERVICE=${PROVER_SERVICE:-sharp}
- MADARA_ORCHESTRATOR_SHARP_CUSTOMER_ID=${MADARA_ORCHESTRATOR_SHARP_CUSTOMER_ID}
- MADARA_ORCHESTRATOR_SHARP_URL=${MADARA_ORCHESTRATOR_SHARP_URL}
- SHARP_USER_CRT=${SHARP_USER_CRT}
- SHARP_USER_KEY=${SHARP_USER_KEY}
- SHARP_SERVER_CRT=${SHARP_SERVER_CRT}
- SHARP_PROOF_LAYOUT=${SHARP_PROOF_LAYOUT:-small}
- MADARA_ORCHESTRATOR_SHARP_USER_CRT=${MADARA_ORCHESTRATOR_SHARP_USER_CRT}
- MADARA_ORCHESTRATOR_SHARP_USER_KEY=${MADARA_ORCHESTRATOR_SHARP_USER_KEY}
- MADARA_ORCHESTRATOR_SHARP_SERVER_CRT=${MADARA_ORCHESTRATOR_SHARP_SERVER_CRT}
- MADARA_ORCHESTRATOR_SHARP_PROOF_LAYOUT=${MADARA_ORCHESTRATOR_SHARP_PROOF_LAYOUT:-small}
- DA_LAYER=${DA_LAYER:-ethereum}
- SETTLEMENT_LAYER=${SETTLEMENT_LAYER:-ethereum}
- SETTLEMENT_RPC_URL=${SETTLEMENT_RPC_URL}
Expand Down
18 changes: 14 additions & 4 deletions e2e-tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use orchestrator::data_storage::DataStorage;
use orchestrator::database::mongodb::config::MongoDBParams;
use orchestrator::jobs::constants::{JOB_METADATA_SNOS_BLOCK, JOB_METADATA_STATE_UPDATE_BLOCKS_TO_SETTLE_KEY};
use orchestrator::jobs::types::{ExternalId, JobItem, JobStatus, JobType};
use orchestrator::queue::job_queue::{JobQueueMessage, WorkerTriggerType};
use orchestrator::queue::job_queue::{JobQueueMessage, QueueType, WorkerTriggerType};
use orchestrator::queue::sqs::AWSSQSParams;
use rstest::rstest;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -164,14 +164,20 @@ async fn test_orchestrator_workflow(#[case] l2_block_number: String) {
// setting up of the test and during orchestrator run too.
dotenvy::from_filename(".env.test").expect("Failed to load the .env file");

let queue_params = AWSSQSParams {
queue_base_url: get_env_var_or_panic("MADARA_ORCHESTRATOR_SQS_BASE_QUEUE_URL"),
sqs_prefix: get_env_var_or_panic("MADARA_ORCHESTRATOR_SQS_PREFIX"),
sqs_suffix: get_env_var_or_panic("MADARA_ORCHESTRATOR_SQS_SUFFIX"),
};

let mut setup_config = Setup::new(l2_block_number.clone()).await;
// Setup S3
setup_s3(setup_config.localstack().s3_client()).await.unwrap();

// Step 1 : SNOS job runs =========================================
// Updates the job in the db
let job_id = put_job_data_in_db_snos(setup_config.mongo_db_instance(), l2_block_number.clone()).await;
put_snos_job_in_processing_queue(setup_config.localstack(), job_id).await.unwrap();
put_snos_job_in_processing_queue(setup_config.localstack(), job_id, queue_params).await.unwrap();

// Step 2: Proving Job ============================================
// Mocking the endpoint
Expand Down Expand Up @@ -316,9 +322,13 @@ pub async fn put_job_data_in_db_snos(mongo_db: &MongoDbServer, l2_block_number:

/// Adding SNOS job in JOB_PROCESSING_QUEUE so that the job is triggered
/// as soon as it is picked up by orchestrator
pub async fn put_snos_job_in_processing_queue(local_stack: &LocalStack, id: Uuid) -> color_eyre::Result<()> {
pub async fn put_snos_job_in_processing_queue(
local_stack: &LocalStack,
id: Uuid,
queue_params: AWSSQSParams,
) -> color_eyre::Result<()> {
let message = JobQueueMessage { id };
local_stack.put_message_in_queue(message, get_env_var_or_panic("SQS_SNOS_JOB_PROCESSING_QUEUE_URL")).await?;
local_stack.put_message_in_queue(message, queue_params.get_queue_url(QueueType::SnosJobProcessing)).await?;
Ok(())
}

Expand Down

0 comments on commit 011d96c

Please sign in to comment.