Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xxx transport test — trying to pass CORS
Browse files Browse the repository at this point in the history
Twey committed Mar 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9c83504 commit cca16ef
Showing 6 changed files with 72 additions and 5 deletions.
26 changes: 26 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -126,6 +126,7 @@ tower = "0.4.13"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", default-features = false, features = ["env-filter"] }
trait-variant = "0.1.1"
wasm-bindgen-test = "0.3.42"
wasm-encoder = "0.24.1"
wasmer = { version = "=3.1.1", features = ["singlepass"] }
wasmer-middlewares = "=3.1.1"
15 changes: 11 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -18,18 +18,25 @@
let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
nonRustDeps = with pkgs; [
# for building
clang
jq
kubernetes-helm
kind
kubectl
libclang.lib
libiconv
nodejs
openssl
protobuf
pkg-config
rocksdb

# for testing
jq
kubernetes-helm
kind
kubectl

# for Wasm testing
chromedriver
wasm-pack
];
rustBuildToolchain = (pkgs.rust-bin.fromRustupToolchainFile
./toolchains/build/rust-toolchain.toml);
3 changes: 3 additions & 0 deletions linera-rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -82,6 +82,9 @@ tonic = { workspace = true, features = ["prost", "codegen", "transport"] }
tonic = { workspace = true, features = ["codegen", "prost"] }
tonic-web-wasm-client.workspace = true

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test.workspace = true

[build-dependencies]
cfg_aliases.workspace = true
tonic-build = { workspace = true, features = ["prost"] }
1 change: 0 additions & 1 deletion linera-rpc/src/grpc/node_provider.rs
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ use super::GrpcClient;
use crate::{config::ValidatorPublicNetworkConfig, node_provider::NodeOptions};

use linera_core::node::{LocalValidatorNodeProvider, NodeError};

use std::str::FromStr as _;

#[derive(Copy, Clone)]
31 changes: 31 additions & 0 deletions linera-rpc/tests/transport.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

// 1. [✓] pass through data to testing environment
// 2. [ ] create test to connect to running server — should work on both Wasm and non-Wasm

wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);

#[cfg_attr(web, wasm_bindgen_test::wasm_bindgen_test)]
#[cfg_attr(not(web), tokio::test(flavor = "current_thread"))]
async fn client() {
use linera_rpc::config::*;
use std::time::Duration;
use linera_core::node::LocalValidatorNode as _;

let network_config = ValidatorPublicNetworkPreConfig {
protocol: NetworkProtocol::Grpc(TlsConfig::ClearText),
host: "127.0.0.1".into(),
port: 9000,
};

let node_options = linera_rpc::node_provider::NodeOptions {
send_timeout: Duration::from_millis(100),
recv_timeout: Duration::from_millis(100),
notification_retry_delay: Duration::from_millis(100),
notification_retries: 5,
};

let _ = linera_rpc::grpc::GrpcClient::new(network_config, node_options).unwrap()
.get_version_info().await.unwrap();
}

0 comments on commit cca16ef

Please sign in to comment.