test: check that all the existing substreams integration test files can be parsed
This commit is contained in:
77
protocol-testing/Cargo.lock
generated
77
protocol-testing/Cargo.lock
generated
@@ -1389,6 +1389,15 @@ dependencies = [
|
|||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "backtrace-ext"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50"
|
||||||
|
dependencies = [
|
||||||
|
"backtrace",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base16ct"
|
name = "base16ct"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@@ -4125,6 +4134,12 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "is_ci"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "is_terminal_polyfill"
|
name = "is_terminal_polyfill"
|
||||||
version = "1.70.1"
|
version = "1.70.1"
|
||||||
@@ -4499,8 +4514,16 @@ version = "7.6.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7"
|
checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"backtrace",
|
||||||
|
"backtrace-ext",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"miette-derive",
|
"miette-derive",
|
||||||
|
"owo-colors",
|
||||||
|
"supports-color",
|
||||||
|
"supports-hyperlinks",
|
||||||
|
"supports-unicode",
|
||||||
|
"terminal_size",
|
||||||
|
"textwrap",
|
||||||
"unicode-width 0.1.14",
|
"unicode-width 0.1.14",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -4879,6 +4902,12 @@ version = "0.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "owo-colors"
|
||||||
|
version = "4.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "48dd4f4a2c8405440fd0462561f0e5806bd0f77e86f51c761481bdd4018b545e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "p256"
|
name = "p256"
|
||||||
version = "0.13.2"
|
version = "0.13.2"
|
||||||
@@ -5397,6 +5426,7 @@ dependencies = [
|
|||||||
"colored",
|
"colored",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"figment",
|
"figment",
|
||||||
|
"glob",
|
||||||
"hex",
|
"hex",
|
||||||
"miette",
|
"miette",
|
||||||
"postgres",
|
"postgres",
|
||||||
@@ -6937,6 +6967,27 @@ version = "2.6.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "supports-color"
|
||||||
|
version = "3.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6"
|
||||||
|
dependencies = [
|
||||||
|
"is_ci",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "supports-hyperlinks"
|
||||||
|
version = "3.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "804f44ed3c63152de6a9f90acbea1a110441de43006ea51bcce8f436196a288b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "supports-unicode"
|
||||||
|
version = "3.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sval"
|
name = "sval"
|
||||||
version = "2.14.1"
|
version = "2.14.1"
|
||||||
@@ -7158,6 +7209,16 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "textwrap"
|
||||||
|
version = "0.16.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-linebreak",
|
||||||
|
"unicode-width 0.2.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.69"
|
version = "1.0.69"
|
||||||
@@ -7697,9 +7758,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tycho-client"
|
name = "tycho-client"
|
||||||
version = "0.82.0"
|
version = "0.83.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "19a7ed885ea7e01efc3c98135b1be5c0472e81ada6455517f61ca67313271587"
|
checksum = "68faa54caad8f18d764acc300564b3d468e32eb63c67219cea7429a21b71cac9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -7724,9 +7785,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tycho-common"
|
name = "tycho-common"
|
||||||
version = "0.82.0"
|
version = "0.83.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "096c87ebe011785fcd7ed59ec501ac12b465a64fbd2914b8c0c57125c253682b"
|
checksum = "e031808e0cc6fe9d6402a46277464dc224c174aee40eb07122ed38bbbe2a3c65"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -7749,7 +7810,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tycho-simulation"
|
name = "tycho-simulation"
|
||||||
version = "0.155.2"
|
version = "0.155.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy",
|
"alloy",
|
||||||
"async-stream",
|
"async-stream",
|
||||||
@@ -7893,6 +7954,12 @@ version = "1.0.18"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-linebreak"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-normalization"
|
name = "unicode-normalization"
|
||||||
version = "0.1.24"
|
version = "0.1.24"
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
miette = "7.6.0"
|
glob = "0.3.0"
|
||||||
|
miette = { version = "7.6.0", features = ["fancy"] }
|
||||||
# Logging & Tracing
|
# Logging & Tracing
|
||||||
tracing = "0.1.37"
|
tracing = "0.1.37"
|
||||||
# Tycho dependencies
|
# Tycho dependencies
|
||||||
tycho-common = "0.82.0"
|
tycho-common = "0.83.0"
|
||||||
tycho-client = "0.82.0"
|
tycho-client = "0.83.0"
|
||||||
# TODO make this less hacky. We should probably try to build this in a similar way that the indexer is built
|
# TODO make this less hacky. We should probably try to build this in a similar way that the indexer is built
|
||||||
tycho-simulation = { path = "../../tycho-simulation", features = ["evm"] }
|
tycho-simulation = { path = "../../tycho-simulation", features = ["evm"] }
|
||||||
# EVM dependencies
|
# EVM dependencies
|
||||||
|
|||||||
@@ -54,12 +54,7 @@ impl TestRunner {
|
|||||||
.substreams_path
|
.substreams_path
|
||||||
.join("integration_test.tycho.yaml");
|
.join("integration_test.tycho.yaml");
|
||||||
|
|
||||||
let figment = Figment::new().merge(Yaml::file(&config_yaml_path));
|
let config = Self::parse_config(&config_yaml_path)?;
|
||||||
|
|
||||||
let config = figment
|
|
||||||
.extract::<IntegrationTestsConfig>()
|
|
||||||
.into_diagnostic()
|
|
||||||
.wrap_err("Failed to load test configuration:")?;
|
|
||||||
|
|
||||||
info!("Running {} tests ...\n", config.tests.len());
|
info!("Running {} tests ...\n", config.tests.len());
|
||||||
info!("--------------------------------\n");
|
info!("--------------------------------\n");
|
||||||
@@ -100,6 +95,17 @@ impl TestRunner {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_config(config_yaml_path: &PathBuf) -> miette::Result<IntegrationTestsConfig> {
|
||||||
|
info!("Config YAML: {}", config_yaml_path.display());
|
||||||
|
let yaml = Yaml::file(&config_yaml_path);
|
||||||
|
let figment = Figment::new().merge(yaml);
|
||||||
|
let config = figment
|
||||||
|
.extract::<IntegrationTestsConfig>()
|
||||||
|
.into_diagnostic()
|
||||||
|
.wrap_err("Failed to load test configuration:")?;
|
||||||
|
Ok(config)
|
||||||
|
}
|
||||||
|
|
||||||
fn run_test(
|
fn run_test(
|
||||||
&self,
|
&self,
|
||||||
test: &IntegrationTest,
|
test: &IntegrationTest,
|
||||||
@@ -402,3 +408,56 @@ fn validate_state(
|
|||||||
info!("\n✅ Simulation validation passed.\n");
|
info!("\n✅ Simulation validation passed.\n");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use glob::glob;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_all_configs() {
|
||||||
|
let manifest_dir = env!("CARGO_MANIFEST_DIR");
|
||||||
|
let curr_dir = PathBuf::from(manifest_dir);
|
||||||
|
let parent_dir = curr_dir.parent().unwrap();
|
||||||
|
env::set_current_dir(parent_dir).expect("Failed to set working directory");
|
||||||
|
|
||||||
|
let pattern = "./substreams/*/integration_test.tycho.yaml";
|
||||||
|
let mut results = Vec::new();
|
||||||
|
|
||||||
|
if glob(pattern).unwrap().count() == 0 {
|
||||||
|
panic!("No integration_test.tycho.yaml files found in substreams/*/");
|
||||||
|
}
|
||||||
|
for entry in glob(pattern).unwrap() {
|
||||||
|
match entry {
|
||||||
|
Ok(path) => {
|
||||||
|
if !path.is_file() {
|
||||||
|
results.push(Err(format!("Path is not a file: {}", path.display())));
|
||||||
|
} else {
|
||||||
|
let result = TestRunner::parse_config(&path);
|
||||||
|
if let Err(e) = &result {
|
||||||
|
results.push(Err(format!(
|
||||||
|
"Failed to parse config at {}: {e:?}",
|
||||||
|
path.display(),
|
||||||
|
)));
|
||||||
|
} else {
|
||||||
|
results.push(Ok(()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => results.push(Err(format!("Glob error: {e:?}"))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let errors: Vec<_> = results
|
||||||
|
.iter()
|
||||||
|
.filter_map(|r| r.as_ref().err())
|
||||||
|
.collect();
|
||||||
|
if !errors.is_empty() {
|
||||||
|
for error in errors {
|
||||||
|
println!("{error}");
|
||||||
|
}
|
||||||
|
panic!("One or more config files failed to parse.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
use miette::{miette, IntoDiagnostic, WrapErr};
|
use miette::{IntoDiagnostic, WrapErr};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use crate::config::ProtocolComponentWithTestConfig;
|
use crate::config::ProtocolComponentWithTestConfig;
|
||||||
@@ -83,7 +83,7 @@ impl TychoRunner {
|
|||||||
.wait()
|
.wait()
|
||||||
.into_diagnostic()
|
.into_diagnostic()
|
||||||
.wrap_err("Failed to wait on Tycho indexer process")?;
|
.wrap_err("Failed to wait on Tycho indexer process")?;
|
||||||
|
|
||||||
// Note: tycho-indexer may exit with non-zero status when stream ends normally
|
// Note: tycho-indexer may exit with non-zero status when stream ends normally
|
||||||
// This is expected behavior and should not be treated as an error
|
// This is expected behavior and should not be treated as an error
|
||||||
if !status.success() {
|
if !status.success() {
|
||||||
|
|||||||
@@ -45,9 +45,7 @@ tests:
|
|||||||
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
||||||
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
||||||
- "0x6b175474e89094c44da98b954eedeac495271d0f"
|
- "0x6b175474e89094c44da98b954eedeac495271d0f"
|
||||||
static_attributes:
|
static_attributes: {}
|
||||||
attr_1: "value"
|
|
||||||
attr_2: "value"
|
|
||||||
creation_tx: "0x20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6"
|
creation_tx: "0x20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6"
|
||||||
# Whether or not the script should skip trying to simulate a swap on this component.
|
# Whether or not the script should skip trying to simulate a swap on this component.
|
||||||
# If set to `true` please always add a reason why it's skipped.
|
# If set to `true` please always add a reason why it's skipped.
|
||||||
@@ -60,6 +58,6 @@ tests:
|
|||||||
tokens:
|
tokens:
|
||||||
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
|
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
|
||||||
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
|
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
|
||||||
static_attributes: null
|
static_attributes: {}
|
||||||
creation_tx: "0xfac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa"
|
creation_tx: "0xfac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa"
|
||||||
skip_simulation: true # If true, always add a reason
|
skip_simulation: true # If true, always add a reason
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ tests:
|
|||||||
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
|
||||||
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
|
||||||
- "0x6b175474e89094c44da98b954eedeac495271d0f"
|
- "0x6b175474e89094c44da98b954eedeac495271d0f"
|
||||||
static_attributes:
|
static_attributes: {}
|
||||||
attr_1: "value"
|
|
||||||
attr_2: "value"
|
|
||||||
creation_tx: "0x20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6"
|
creation_tx: "0x20793bbf260912aae189d5d261ff003c9b9166da8191d8f9d63ff1c7722f3ac6"
|
||||||
# Whether or not the script should skip trying to simulate a swap on this component.
|
# Whether or not the script should skip trying to simulate a swap on this component.
|
||||||
# If set to `true` please always add a reason why it's skipped.
|
# If set to `true` please always add a reason why it's skipped.
|
||||||
@@ -52,6 +50,6 @@ tests:
|
|||||||
tokens:
|
tokens:
|
||||||
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
|
- "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
|
||||||
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
|
- "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84"
|
||||||
static_attributes: null
|
static_attributes: {}
|
||||||
creation_tx: "0xfac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa"
|
creation_tx: "0xfac67ecbd423a5b915deff06045ec9343568edaec34ae95c43d35f2c018afdaa"
|
||||||
skip_simulation: true # If true, always add a reason
|
skip_simulation: true # If true, always add a reason
|
||||||
|
|||||||
Reference in New Issue
Block a user