fix: version handling in protocol-testing
This commit is contained in:
15
protocol-testing/build.rs
Normal file
15
protocol-testing/build.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
use std::process::Command;
|
||||
|
||||
fn hash() {
|
||||
let output = Command::new("git")
|
||||
.args(["rev-parse", "HEAD"])
|
||||
.output()
|
||||
.unwrap();
|
||||
let git_hash = String::from_utf8(output.stdout).unwrap();
|
||||
println!("cargo:rustc-env=GIT_HASH={git_hash}");
|
||||
println!("cargo:rerun-if-changed=.git/HEAD");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
hash();
|
||||
}
|
||||
@@ -1,17 +1,34 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Check arguments
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo "Usage: $0 protocol1[=filter] [protocol2 ...] or \"$0 'protocol1[=filter] protocol2'\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$#" -eq 1 ] && [[ "$1" == *" "* ]]; then
|
||||
IFS=' ' read -r -a args <<< "$1"
|
||||
else
|
||||
args=("$@")
|
||||
fi
|
||||
|
||||
# Check required binaries
|
||||
errors=()
|
||||
for bin in tycho-indexer tycho-protocol-sdk substreams forge cast; do
|
||||
if command -v "$bin" >/dev/null 2>&1; then
|
||||
"$bin" --version || echo "$bin does not support --version"
|
||||
else
|
||||
errors+=("Binary '$bin' not found in PATH")
|
||||
fi
|
||||
done
|
||||
if [ "${#errors[@]}" -ne 0 ]; then
|
||||
for err in "${errors[@]}"; do
|
||||
echo "$err"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run tests
|
||||
for test in "${args[@]}"; do
|
||||
protocol="${test%%=*}"
|
||||
filter="${test#*=}"
|
||||
|
||||
@@ -7,7 +7,7 @@ mod tycho_rpc;
|
||||
mod tycho_runner;
|
||||
mod utils;
|
||||
|
||||
use std::{path::PathBuf, process::Command};
|
||||
use std::{fmt::Display, path::PathBuf};
|
||||
|
||||
use clap::Parser;
|
||||
use miette::{miette, IntoDiagnostic, WrapErr};
|
||||
@@ -82,7 +82,11 @@ fn main() -> miette::Result<()> {
|
||||
.init();
|
||||
|
||||
let version = Version::from_env()?;
|
||||
info!("version: {}, hash: {}", version.version, version.hash);
|
||||
if std::env::args().any(|arg| arg == "--version") {
|
||||
println!("{version}");
|
||||
return Ok(());
|
||||
}
|
||||
info!("{version}");
|
||||
|
||||
let args = Args::parse();
|
||||
|
||||
@@ -108,13 +112,16 @@ impl Version {
|
||||
let version = option_env!("CARGO_PKG_VERSION")
|
||||
.unwrap_or("unknown")
|
||||
.to_string();
|
||||
let hash = {
|
||||
let output = Command::new("git")
|
||||
.args(["rev-parse", "HEAD"])
|
||||
.output()
|
||||
.into_diagnostic()?;
|
||||
String::from_utf8(output.stdout).into_diagnostic()?
|
||||
};
|
||||
let hash = option_env!("GIT_HASH")
|
||||
.unwrap_or("unknown")
|
||||
.to_string();
|
||||
Ok(Self { version, hash })
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Version {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let bin_name = option_env!("CARGO_PKG_NAME").unwrap_or_default();
|
||||
write!(f, "{bin_name} version: {}, hash: {}", self.version, self.hash)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ fn validate_state(
|
||||
let mut decoder = TychoStreamDecoder::new();
|
||||
let decoder_context = DecoderContext::new()
|
||||
.vm_adapter_path(adapter_contract_path_str)
|
||||
.vm_trace(vm_traces);
|
||||
.vm_traces(vm_traces);
|
||||
decoder.register_decoder_with_context::<EVMPoolState<PreCachedDB>>(
|
||||
protocol_system,
|
||||
decoder_context,
|
||||
|
||||
Reference in New Issue
Block a user