Skip to content

Commit

Permalink
feat: local tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
l-monninger committed Apr 29, 2024
1 parent a408182 commit c8f5043
Show file tree
Hide file tree
Showing 24 changed files with 307 additions and 74 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ target/
ledger_db/
state_merkle_db/
.etc
.movement
69 changes: 64 additions & 5 deletions Cargo.lock

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

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ hex = { version = "0.4.3", default-features = false, features = [
async-trait = "0.1.71"
borsh = { version = "0.10.3", features = ["rc", "bytes"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
tracing-log = "0.2.0"
env_logger = "0.11.0"
tokio = { version = "1.35.1", features = ["full"] }
tokio-stream = "0.1.15"
async-stream = "0.3.0"
Expand All @@ -94,6 +97,7 @@ async-channel = "2.2.1"
sha2 = "0.10.8"
once_cell = "1.8.0"
url = "2.2.2"
dirs = "3.0.2"

risc0-build = "0.20"

Expand Down Expand Up @@ -135,7 +139,9 @@ ethers-middleware = { version = "=2.0.10", default-features = false }
aptos-vm = { git = "https://github.com/movementlabsxyz/aptos-core", branch = "monza" }
aptos-sdk = { git = "https://github.com/movementlabsxyz/aptos-core", branch = "monza" }
aptos-consensus-types = { git = "https://github.com/movementlabsxyz/aptos-core", branch = "monza" }
aptos-crypto = { git = "https://github.com/movementlabsxyz/aptos-core", branch = "monza" }
aptos-crypto = { git = "https://github.com/movementlabsxyz/aptos-core", branch = "monza", features = [
"cloneable-private-keys",
] }
aptos-db = { git = "https://github.com/movementlabsxyz/aptos-core.git", branch = "monza" }
aptos-api-types = { git = "https://github.com/movementlabsxyz/aptos-core", branch = "monza" }
aptos-types = { git = "https://github.com/movementlabsxyz/aptos-core", branch = "monza" }
Expand Down
4 changes: 1 addition & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
};

installPhase = ''
ls -al && sleep 30
mkdir -p $out
cp -r ./* $out/
cp -r . $out
'';

meta = with pkgs.lib; {
Expand Down
1 change: 0 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ m1-da-light-node FEATURES *ARGS:
cargo build -p m1-da-light-node
scripts/movement/run m1-da-light-node {{ FEATURES }} {{ ARGS }}
monza-full-node FEATURES *ARGS:
cargo build -p monza-full-node
scripts/movement/run monza-full-node {{ FEATURES }} {{ ARGS }}
1 change: 1 addition & 0 deletions networks/monza/monza-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ once_cell = { workspace = true }
tokio = { workspace = true }
url = { workspace = true }
rand = { workspace = true }
monza-execution-util = { workspace = true }

[lints]
workspace = true
24 changes: 12 additions & 12 deletions networks/monza/monza-client/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ use once_cell::sync::Lazy;
use std::str::FromStr;
use url::Url;

static MONZA_CONFIG : Lazy<monza_execution_util::config::Config> = Lazy::new(|| {
monza_execution_util::config::Config::try_from_env().context("Failed to create the config").unwrap()
});

// :!:>section_1c
static NODE_URL: Lazy<Url> = Lazy::new(|| {

Url::from_str(
std::env::var("MONZA_FULL_NODE_URL")
.as_ref()
.map(|s| s.as_str())
.unwrap_or("http://localhost:3000"),
)
.unwrap()
format!("http://{}", MONZA_CONFIG.monza_config.aptos_rest_listen_url.as_str()).as_str()
).unwrap()

});

static FAUCET_URL: Lazy<Url> = Lazy::new(|| {

Url::from_str(
std::env::var("MONZA_FAUCET_URL")
.as_ref()
.map(|s| s.as_str())
.unwrap_or("http://localhost:8081"),
)
.unwrap()
format!("http://{}", MONZA_CONFIG.monza_config.aptos_faucet_listen_url.as_str()).as_str()
).unwrap()

});
// <:!:section_1c

Expand Down
2 changes: 1 addition & 1 deletion networks/monza/monza-config/src/bin/monza_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ async fn main() -> Result<(), anyhow::Error> {
// read any values from env, but populate the default values if they are not present
let config = Config::try_from_env()?;
// write the values to the env
config.write_to_env()?;
print!("{}", config.write_bash_export_string()?);
Ok(())
}
9 changes: 8 additions & 1 deletion networks/monza/monza-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ impl Config {
}

pub fn write_to_env(&self) -> Result<(), anyhow::Error>{
self.execution_config.write_to_env();
self.execution_config.write_to_env()?;
Ok(())
}

pub fn write_bash_export_string(&self) -> Result<String, anyhow::Error> {
Ok(format!(
"{}",
self.execution_config.write_bash_export_string()?
))
}

}
14 changes: 14 additions & 0 deletions networks/monza/monza-full-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,20 @@ sha2 = { workspace = true }
tonic = { workspace = true }
movement-types = { workspace = true }

env_logger = { workspace = true, optional = true }
tracing = { workspace = true, optional = true }
tracing-subscriber = { workspace = true, optional = true }

[features]
default = [
"logging"
]
logging = [
"env_logger",
"tracing",
"tracing-subscriber"
]


[lints]
workspace = true
20 changes: 18 additions & 2 deletions networks/monza/monza-full-node/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::Context;
use monza_full_node::{
MonzaFullNode,
partial::MonzaPartialFullNode,
Expand All @@ -6,9 +7,24 @@ use monza_full_node::{
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {

let executor = MonzaPartialFullNode::try_from_env().await?;
#[cfg(feature = "logging")]
{
use tracing_subscriber::EnvFilter;

executor.run().await?;
tracing_subscriber::fmt()
.with_env_filter(EnvFilter::try_from_default_env()
.unwrap_or_else(|_| EnvFilter::new("info")))
.init();

}

let executor = MonzaPartialFullNode::try_from_env().await.context(
"Failed to create the executor"
)?;

executor.run().await.context(
"Failed to run the executor"
)?;

Ok(())

Expand Down
5 changes: 4 additions & 1 deletion networks/monza/monza-full-node/src/partial.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{sync::Arc, time::Duration};

use anyhow::Context;
use monza_executor::{
MonzaExecutor,
ExecutableBlock,
Expand Down Expand Up @@ -221,7 +222,9 @@ impl MonzaPartialFullNode<MonzaExecutorV1> {
pub async fn try_from_env() -> Result<Self, anyhow::Error> {
let (tx, _) = async_channel::unbounded();
let light_node_client = LightNodeServiceClient::connect("http://[::1]:30730").await?;
let executor = MonzaExecutorV1::try_from_env(tx).await?;
let executor = MonzaExecutorV1::try_from_env(tx).await.context(
"Failed to get executor from environment"
)?;
Self::bound(executor, light_node_client).await
}

Expand Down
2 changes: 1 addition & 1 deletion process-compose/monza-full-node/process-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ processes:

monza-client-tests:
command: |
sleep 10
sleep 30
cargo test -p monza-client -- --test-threads=1
depends_on:
monza-full-node:
Expand Down
Loading

0 comments on commit c8f5043

Please sign in to comment.