Skip to content

Commit 776452f

Browse files
authored
Merge pull request #17 from wacker-dev/bump-wasmtime
Test on wasmtime 23.0.1
2 parents 009b742 + b4d2bd1 commit 776452f

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

waki/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ multipart = ["dep:mime", "dep:mime_guess", "dep:rand", "dep:memchr", "dep:bytes"
3838
[dev-dependencies]
3939
test-programs-artifacts = { path = "../test-programs/artifacts" }
4040

41-
wasmtime = "22.0.0"
42-
wasmtime-wasi = "22.0.0"
43-
wasmtime-wasi-http = "22.0.0"
41+
wasmtime = "23.0.1"
42+
wasmtime-wasi = "23.0.1"
43+
wasmtime-wasi-http = "23.0.1"
4444
hyper = "1.3.1"
4545
http-body-util = "0.1.1"
4646
tokio = { version = "1.38.0", features = ["macros"] }

waki/tests/all/main.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ mod client;
22
mod server;
33

44
use anyhow::{Context, Result};
5-
use http_body_util::Collected;
5+
use http_body_util::{combinators::BoxBody, Collected};
66
use hyper::body::Bytes;
77
use wasmtime::{
88
component::{Component, Linker, ResourceTable},
99
Config, Engine, Store,
1010
};
1111
use wasmtime_wasi::{bindings::Command, DirPerms, FilePerms, WasiCtx, WasiCtxBuilder, WasiView};
1212
use wasmtime_wasi_http::{
13-
bindings::http::types::ErrorCode, body::HyperIncomingBody, proxy::Proxy, WasiHttpCtx,
14-
WasiHttpView,
13+
bindings::{
14+
http::types::{ErrorCode, Scheme},
15+
Proxy,
16+
},
17+
WasiHttpCtx, WasiHttpView,
1518
};
1619

1720
struct Ctx {
@@ -60,20 +63,20 @@ fn new_component(component_filename: &str) -> Result<(Store<Ctx>, Component, Lin
6063
let store = Store::new(&engine, ctx);
6164
let mut linker = Linker::new(&engine);
6265
wasmtime_wasi::add_to_linker_async(&mut linker)?;
63-
wasmtime_wasi_http::proxy::add_only_http_to_linker(&mut linker)?;
66+
wasmtime_wasi_http::add_only_http_to_linker_async(&mut linker)?;
6467
Ok((store, component, linker))
6568
}
6669

6770
// ref: https://github.com/bytecodealliance/wasmtime/blob/af59c4d568d487b7efbb49d7d31a861e7c3933a6/crates/wasi-http/tests/all/main.rs#L129
6871
pub async fn run_wasi_http(
6972
component_filename: &str,
70-
req: hyper::Request<HyperIncomingBody>,
73+
req: hyper::Request<BoxBody<Bytes, hyper::Error>>,
7174
) -> Result<Result<hyper::Response<Collected<Bytes>>, ErrorCode>> {
7275
let (mut store, component, linker) = new_component(component_filename)?;
7376

74-
let (proxy, _) = Proxy::instantiate_async(&mut store, &component, &linker).await?;
77+
let proxy = Proxy::instantiate_async(&mut store, &component, &linker).await?;
7578

76-
let req = store.data_mut().new_incoming_request(req)?;
79+
let req = store.data_mut().new_incoming_request(Scheme::Http, req)?;
7780

7881
let (sender, receiver) = tokio::sync::oneshot::channel();
7982
let out = store.data_mut().new_response_outparam(sender)?;
@@ -111,7 +114,7 @@ pub async fn run_wasi_http(
111114
pub async fn run_wasi(component_filename: &str) -> Result<()> {
112115
let (mut store, component, linker) = new_component(component_filename)?;
113116

114-
let (command, _) = Command::instantiate_async(&mut store, &component, &linker).await?;
117+
let command = Command::instantiate_async(&mut store, &component, &linker).await?;
115118
command
116119
.wasi_cli_run()
117120
.call_run(&mut store)

waki/tests/all/server.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,14 @@ async fn status_code() -> Result<()> {
7676
}
7777

7878
mod body {
79-
use http_body_util::{BodyExt, Full};
80-
use hyper::body::Bytes;
81-
use wasmtime_wasi_http::body::HyperIncomingBody;
79+
use http_body_util::{combinators::BoxBody, BodyExt, Empty, Full};
80+
use hyper::{body::Bytes, Error};
8281

83-
pub fn full(bytes: &'static str) -> HyperIncomingBody {
84-
HyperIncomingBody::new(Full::new(Bytes::from(bytes)).map_err(|_| unreachable!()))
82+
pub fn full(bytes: &'static str) -> BoxBody<Bytes, Error> {
83+
BoxBody::new(Full::new(bytes.into()).map_err(|_| unreachable!()))
8584
}
8685

87-
pub fn empty() -> HyperIncomingBody {
88-
HyperIncomingBody::default()
86+
pub fn empty() -> BoxBody<Bytes, Error> {
87+
BoxBody::new(Empty::new().map_err(|_| unreachable!()))
8988
}
9089
}

0 commit comments

Comments
 (0)