Skip to content

Commit

Permalink
fix for the conformance test
Browse files Browse the repository at this point in the history
  • Loading branch information
pompon0 committed Nov 3, 2023
1 parent e37f4f4 commit 64e21c8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
2 changes: 2 additions & 0 deletions node/Cargo.lock

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

4 changes: 3 additions & 1 deletion node/libs/protobuf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
34 changes: 28 additions & 6 deletions node/libs/protobuf/src/bin/conformance_test/main.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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()));
}

Expand Down Expand Up @@ -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:#}");
}
}

0 comments on commit 64e21c8

Please sign in to comment.