Skip to content

Commit

Permalink
add scarb build
Browse files Browse the repository at this point in the history
  • Loading branch information
byteZorvin committed Sep 28, 2024
1 parent 1d590cf commit 4ebfb4e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 26 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/starknet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:

- name: Checkout first repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: madara-alliance/madara # Replace with your first repository
ref: main # Replace with your branch name
Expand All @@ -31,17 +31,28 @@ jobs:
toolchain: stable
override: true

- name: Build
- name: Build Madara
run: |
cd madara
cargo build --release
cargo build
- name: Checkout second repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: madara-alliance/madara-orchestrator # Replace with your second repository
path: orchestrator



- run:
cd crates/settlement-clients/starknet/src/tests/mock_contracts
- uses: asdf-vm/actions/install@v3
- run:
scarb fmt --check
scarb build
cd -


- name: Run Starknet tests
run: |
cd orchestrator
Expand Down
2 changes: 1 addition & 1 deletion crates/settlement-clients/starknet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl StarknetSettlementClient {
signer.clone(),
signer_address,
provider.chain_id().await.unwrap(),
ExecutionEncoding::New
ExecutionEncoding::New,
));

let starknet_core_contract_client: StarknetCoreContractClient =
Expand Down
13 changes: 2 additions & 11 deletions crates/settlement-clients/starknet/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
collections::HashMap,
future::Future,
path::{Path, PathBuf},
process::{Child, Command, Output},
process::{Child, Command, Output, Stdio},
str::FromStr,
time::Duration,
};
Expand Down Expand Up @@ -183,6 +183,7 @@ impl MadaraCmdBuilder {
"--rpc-port".into(),
format!("{}", self.port.0),
]))
.stdout(Stdio::piped())
.spawn()
.unwrap();

Expand Down Expand Up @@ -217,16 +218,6 @@ pub fn set_workdir() {
env::set_current_dir(&project_root).expect("Failed to set working directory");
}

#[rstest]
fn madara_help_shows(_set_workdir: ()) {
let _ = env_logger::builder().is_test(true).try_init();
let output = MadaraCmdBuilder::new().args(["--help"]).run().wait_with_output();
assert!(output.status.success());

let stdout = String::from_utf8(output.stdout).unwrap();
assert!(stdout.contains("Madara: High performance Starknet sequencer/full-node"), "stdout: {stdout}");
}

#[rstest]
#[tokio::test]
async fn madara_can_sync_a_few_blocks(_set_workdir: ()) {
Expand Down
28 changes: 18 additions & 10 deletions crates/settlement-clients/starknet/src/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use starknet::{
};
use std::env;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
use utils::settings::env::EnvSettingsProvider;
Expand Down Expand Up @@ -131,9 +130,8 @@ async fn setup() -> (SingleOwnerAccount<JsonRpcClient<HttpTransport>, LocalWalle
#[rstest]
#[tokio::test]
async fn test_deployment(#[future] setup: (SingleOwnerAccount<JsonRpcClient<HttpTransport>, LocalWallet>, MadaraCmd)) {
// async fn test_deployment(#[future] setup: SingleOwnerAccount<JsonRpcClient<HttpTransport>, LocalWallet>) {
let (account, _) = setup.await;
// let account = setup.await;
let (account, _madara_process) = setup.await;
let account = Arc::new(account);

let project_root = Path::new(env!("CARGO_MANIFEST_DIR")).ancestors().nth(3).unwrap();
let contract_path = project_root.join("crates/settlement-clients/starknet/src/tests/mock_contracts/target/dev");
Expand All @@ -151,14 +149,24 @@ async fn test_deployment(#[future] setup: (SingleOwnerAccount<JsonRpcClient<Http

let flattened_class = sierra_class.clone().flatten().unwrap();
let compiled_class_hash = compiled_class.class_hash().unwrap();
let class_hash = flattened_class.class_hash();
account.declare_v2(Arc::new(flattened_class), compiled_class_hash).send().await.unwrap();

// This done since madara currently does not increment nonce for pending transactions
tokio::time::sleep(tokio::time::Duration::from_secs(4)).await;
let DeclareTransactionResult { transaction_hash: declare_tx_hash, class_hash: _ } =
account.declare_v2(Arc::new(flattened_class.clone()), compiled_class_hash).send().await.unwrap();
println!("declare tx hash {:?}", declare_tx_hash);

let is_success = wait_for_tx_success(&account, declare_tx_hash, Duration::from_secs(2)).await;
assert!(is_success, "Declare trasactiion failed");

let contract_factory = ContractFactory::new(flattened_class.class_hash(), account.clone());
let deploy_v1 = contract_factory.deploy_v1(vec![], felt!("1122"), false);
let deployed_address = deploy_v1.deployed_address();

let contract_factory = ContractFactory::new(class_hash, account);
contract_factory.deploy_v1(vec![], felt!("1122"), false).send().await.expect("Unable to deploy contract");
env::set_var("STARKNET_CAIRO_CORE_CONTRACT_ADDRESS", deployed_address.to_hex_string());
let InvokeTransactionResult { transaction_hash: deploy_tx_hash } =
deploy_v1.send().await.expect("Unable to deploy contract");

let is_success = wait_for_tx_success(&account, deploy_tx_hash, Duration::from_secs(2)).await;
assert!(is_success, "Deploy trasaction failed");
}

#[rstest]
Expand Down

0 comments on commit 4ebfb4e

Please sign in to comment.