Skip to content

Commit

Permalink
Merge branch 'main' into chore/rm-dead_code-attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcaron authored Jan 7, 2025
2 parents 753dfc3 + 1fda456 commit edfebfc
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 72 deletions.
7 changes: 0 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,3 @@ updates:
schedule:
interval: "weekly" # can be `daily` or `monthly` also
open-pull-requests-limit: 10
ignore:
# match all substrate dependencies
- dependency-name: "frame-*"
- dependency-name: "sp-*"
- dependency-name: "sc-*"
- dependency-name: "substrate-*"
- dependency-name: "pallet-*"
10 changes: 0 additions & 10 deletions .github/workflows/rust-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ jobs:
- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Launch Anvil
run: anvil --fork-url $ANVIL_FORK_URL --fork-block-number $ANVIL_BLOCK_NUMBER &
env:
ANVIL_FORK_URL: "https://eth.merkle.io"
ANVIL_BLOCK_NUMBER: 20395662
- name: Wait for Anvil to be ready
run: |
while ! nc -z localhost 8545; do
sleep 1
done

- name: Run unit tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Next release

- chore: remove redundant dead_code attribute
- fix(compilation): crate-level compilation
- chore: Move crates under a madara subdir
- chore(nix): resolve flake and direnv compatibility issues
- fix: Gateway path fix
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions crates/madara/client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub struct MadaraBackend {
trie_log_config: TrieLogConfig,
sender_block_info: tokio::sync::broadcast::Sender<mp_block::MadaraBlockInfo>,
write_opt_no_wal: WriteOptions,
#[cfg(feature = "testing")]
#[cfg(any(test, feature = "testing"))]
_temp_dir: Option<tempfile::TempDir>,
}

Expand Down Expand Up @@ -373,7 +373,7 @@ impl MadaraBackend {
&self.chain_config
}

#[cfg(feature = "testing")]
#[cfg(any(test, feature = "testing"))]
pub fn open_for_testing(chain_config: Arc<ChainConfig>) -> Arc<MadaraBackend> {
let temp_dir = tempfile::TempDir::with_prefix("madara-test").unwrap();
let db = open_rocksdb(temp_dir.as_ref()).unwrap();
Expand Down Expand Up @@ -446,7 +446,7 @@ impl MadaraBackend {
trie_log_config,
sender_block_info: tokio::sync::broadcast::channel(100).0,
write_opt_no_wal: make_write_opt_no_wal(),
#[cfg(feature = "testing")]
#[cfg(any(test, feature = "testing"))]
_temp_dir: None,
});
backend.check_configuration()?;
Expand Down
2 changes: 1 addition & 1 deletion crates/madara/client/db/src/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use mp_transactions::{
use starknet_api::felt;
use starknet_types_core::felt::Felt;

#[cfg(feature = "testing")]
#[cfg(any(test, feature = "testing"))]
pub mod temp_db {
use crate::DatabaseService;
use mp_chain_config::ChainConfig;
Expand Down
1 change: 1 addition & 0 deletions crates/madara/client/eth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,4 @@ tracing-test = "0.2.5"
serial_test.workspace = true
lazy_static.workspace = true
mp-utils = { workspace = true, features = ["testing"] }
mc-mempool = { workspace = true, features = ["testing"] }
1 change: 1 addition & 0 deletions crates/madara/primitives/oracle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ targets = ["x86_64-unknown-linux-gnu"]
# Other
anyhow.workspace = true
async-trait.workspace = true
mp-utils.workspace = true
reqwest.workspace = true
serde = { workspace = true, features = ["derive"] }
7 changes: 6 additions & 1 deletion crates/madara/primitives/oracle/src/pragma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::fmt;

use anyhow::{bail, Context};
use async_trait::async_trait;
use mp_utils::serde::{deserialize_url, serialize_url};
use reqwest::Url;
use serde::{Deserialize, Serialize};

Expand All @@ -11,7 +12,11 @@ pub const DEFAULT_API_URL: &str = "https://api.dev.pragma.build/node/v1/data/";

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PragmaOracle {
#[serde(default = "default_oracle_api_url")]
#[serde(
default = "default_oracle_api_url",
serialize_with = "serialize_url",
deserialize_with = "deserialize_url"
)]
pub api_url: Url,
#[serde(default)]
pub api_key: String,
Expand Down
18 changes: 17 additions & 1 deletion crates/madara/primitives/utils/src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ use std::time::Duration;

use serde::{Deserialize, Deserializer};
use starknet_types_core::felt::Felt;
use url::Url;

use crate::{crypto::ZeroingPrivateKey, parsers::parse_duration};
use crate::{crypto::ZeroingPrivateKey, parsers::parse_duration, parsers::parse_url};

pub fn deserialize_duration<'de, D>(deserializer: D) -> Result<Duration, D::Error>
where
Expand All @@ -23,6 +24,14 @@ where
parse_duration(&s).map_err(serde::de::Error::custom).map(Some)
}

pub fn deserialize_url<'de, D>(deserializer: D) -> Result<Url, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
parse_url(&s).map_err(serde::de::Error::custom)
}

pub fn serialize_optional_duration<S>(duration: &Option<Duration>, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
Expand All @@ -45,6 +54,13 @@ where
}
}

pub fn serialize_url<S>(url: &Url, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(url.as_str())
}

pub fn deserialize_private_key<'de, D>(deserializer: D) -> Result<ZeroingPrivateKey, D::Error>
where
D: Deserializer<'de>,
Expand Down
40 changes: 15 additions & 25 deletions scripts/e2e-coverage.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
#!/bin/bash
set -e

anvil --fork-url https://eth.merkle.io --fork-block-number 20395662 &
# Configuration
export PROPTEST_CASES=5
export ETH_FORK_URL=https://eth.merkle.io

subshell() {
set -e
rm -f target/madara-* lcov.info
# Clean up previous coverage data
rm -f target/madara-* lcov.info

source <(cargo llvm-cov show-env --export-prefix)
# Set up LLVM coverage environment
source <(cargo llvm-cov show-env --export-prefix)

cargo build --bin madara --profile dev
# Build the binary with coverage instrumentation
cargo build --bin madara --profile dev
export COVERAGE_BIN=$(realpath target/debug/madara)

export COVERAGE_BIN=$(realpath target/debug/madara)
export ETH_FORK_URL=https://eth.merkle.io
# Run tests with coverage collection
cargo test --profile dev "${@:-"--workspace"}"

# wait for anvil
while ! nc -z localhost 8545; do
sleep 1
done


ARGS=$@
export PROPTEST_CASES=5
cargo test --profile dev ${ARGS:=--workspace}

cargo llvm-cov report --lcov --output-path lcov.info
cargo llvm-cov report
}

(subshell $@ && r=$?) || r=$?
pkill -P $$
exit $r
# Generate coverage reports
cargo llvm-cov report --lcov --output-path lcov.info # Generate LCOV report
cargo llvm-cov report # Display coverage summary in terminal
30 changes: 7 additions & 23 deletions scripts/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,13 @@
# Usage: ``./scripts/e2e-tests.sh <name of the tests to run>`
set -e

# will also launch anvil and automatically close it down on error or success

# Configuration
export PROPTEST_CASES=10
export ETH_FORK_URL=https://eth.merkle.io

anvil --fork-url https://eth.merkle.io --fork-block-number 20395662 &

subshell() {
set -e
cargo build --bin madara --profile dev

export COVERAGE_BIN=$(realpath target/debug/madara)
export ETH_FORK_URL=https://eth.merkle.io

# wait for anvil
while ! nc -z localhost 8545; do
sleep 1
done

ARGS=$@
export PROPTEST_CASES=5
cargo test --profile dev ${ARGS:=--workspace}
}
# Build the binary
cargo build --bin madara --profile dev
export BINARY_PATH=$(realpath target/debug/madara)

(subshell $@ && r=$?) || r=$?
pkill -P $$
exit $r
# Run the tests
cargo test --profile dev "${@:-"--workspace"}"

0 comments on commit edfebfc

Please sign in to comment.