From 64e21c85602b4cef501f79e57c5e9cab371536c3 Mon Sep 17 00:00:00 2001 From: Grzegorz Prusak Date: Fri, 3 Nov 2023 19:41:06 +0100 Subject: [PATCH] fix for the conformance test --- node/Cargo.lock | 2 ++ node/libs/protobuf/Cargo.toml | 4 ++- ...test_failure_list.txt => failure_list.txt} | 0 .../protobuf/src/bin/conformance_test/main.rs | 34 +++++++++++++++---- 4 files changed, 33 insertions(+), 7 deletions(-) rename node/libs/protobuf/src/bin/conformance_test/{conformance_test_failure_list.txt => failure_list.txt} (100%) diff --git a/node/Cargo.lock b/node/Cargo.lock index 9fc74d80..286a4b6d 100644 --- a/node/Cargo.lock +++ b/node/Cargo.lock @@ -2391,6 +2391,8 @@ dependencies = [ "serde", "serde_json", "tokio", + "tracing", + "tracing-subscriber", "zksync_protobuf_build", ] diff --git a/node/libs/protobuf/Cargo.toml b/node/libs/protobuf/Cargo.toml index c2f3f4f0..fc4ff927 100644 --- a/node/libs/protobuf/Cargo.toml +++ b/node/libs/protobuf/Cargo.toml @@ -14,12 +14,14 @@ anyhow.workspace = true bit-vec.workspace = true serde.workspace = true quick-protobuf.workspace = true +once_cell.workspace = true prost.workspace = true prost-reflect.workspace = true rand.workspace = true serde_json.workspace = true tokio.workspace = true -once_cell.workspace = true +tracing.workspace = true +tracing-subscriber.workspace = true zksync_protobuf_build.workspace = true concurrency = { path = "../concurrency" } diff --git a/node/libs/protobuf/src/bin/conformance_test/conformance_test_failure_list.txt b/node/libs/protobuf/src/bin/conformance_test/failure_list.txt similarity index 100% rename from node/libs/protobuf/src/bin/conformance_test/conformance_test_failure_list.txt rename to node/libs/protobuf/src/bin/conformance_test/failure_list.txt diff --git a/node/libs/protobuf/src/bin/conformance_test/main.rs b/node/libs/protobuf/src/bin/conformance_test/main.rs index f1c3fce9..584c85da 100644 --- a/node/libs/protobuf/src/bin/conformance_test/main.rs +++ b/node/libs/protobuf/src/bin/conformance_test/main.rs @@ -1,19 +1,20 @@ //! Conformance test for our canonical encoding implemented according to //! https://github.com/protocolbuffers/zksync_protobuf/blob/main/conformance/conformance.proto //! Our implementation supports only a subset of proto functionality, so -//! `schema/proto/conformance/conformance.proto` and -//! `schema/proto/conformance/zksync_protobuf_test_messages.proto` contains only a +//! `proto/conformance.proto` and +//! `proto/protobuf_test_messages.proto` contains only a //! subset of original fields. Also we run only proto3 binary -> binary tests. -//! conformance_test_failure_list.txt contains tests which are expected to fail. +//! failure_list.txt contains tests which are expected to fail. use anyhow::Context as _; use concurrency::{ctx, io}; use prost::Message as _; use prost_reflect::ReflectMessage; +use std::sync::Mutex; mod proto; -#[tokio::main] -async fn main() -> anyhow::Result<()> { +/// Runs the test server. +async fn run() -> anyhow::Result<()> { let ctx = &ctx::root(); let stdin = &mut tokio::io::stdin(); let stdout = &mut tokio::io::stdout(); @@ -31,7 +32,7 @@ async fn main() -> anyhow::Result<()> { let req = proto::ConformanceRequest::decode(&msg[..])?; let res = async { let t = req.message_type.context("missing message_type")?; - if t != *"zksync_protobuf_test_messages.proto3.TestAllTypesProto3" { + if t != *"protobuf_test_messages.proto3.TestAllTypesProto3" { return Ok(R::Skipped("unsupported".to_string())); } @@ -87,3 +88,24 @@ async fn main() -> anyhow::Result<()> { io::flush(ctx, stdout).await??; } } + +#[tokio::main] +async fn main() { + let sub = tracing_subscriber::fmt() + .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()); + match std::env::var("LOG_FILE") { + Err(_) => sub.with_writer(std::io::stderr).init(), + Ok(path) => sub + .with_writer(Mutex::new( + std::fs::File::options() + .create(true) + .append(true) + .open(path) + .unwrap(), + )) + .init(), + }; + if let Err(err) = run().await { + tracing::error!("run(): {err:#}"); + } +}