@@ -58,14 +58,11 @@ struct ClientBehaviour {
5858 dispatch : request_response:: cbor:: Behaviour < TaskDispatchRequest , TaskDispatchResponse > ,
5959}
6060
61- fn build_dispatch_behaviour ( ) -> request_response:: cbor:: Behaviour < TaskDispatchRequest , TaskDispatchResponse > {
61+ fn build_dispatch_behaviour (
62+ ) -> request_response:: cbor:: Behaviour < TaskDispatchRequest , TaskDispatchResponse > {
6263 request_response:: cbor:: Behaviour :: new (
63- std:: iter:: once ( (
64- StreamProtocol :: new ( PROTOCOL_TASK_DISPATCH ) ,
65- ProtocolSupport :: Full ,
66- ) ) ,
67- request_response:: Config :: default ( )
68- . with_request_timeout ( Duration :: from_secs ( 60 ) ) ,
64+ std:: iter:: once ( ( StreamProtocol :: new ( PROTOCOL_TASK_DISPATCH ) , ProtocolSupport :: Full ) ) ,
65+ request_response:: Config :: default ( ) . with_request_timeout ( Duration :: from_secs ( 60 ) ) ,
6966 )
7067}
7168
@@ -151,11 +148,7 @@ fn make_test_manifest(workload_cid: cid::Cid) -> JobManifest {
151148fn execute_wasm_task ( req : & TaskDispatchRequest ) -> TaskDispatchResponse {
152149 use std:: time:: Instant ;
153150 let start = Instant :: now ( ) ;
154- let wasm = req
155- . inline_inputs
156- . iter ( )
157- . find ( |( n, _) | n == "workload" )
158- . map ( |( _, b) | b. clone ( ) ) ;
151+ let wasm = req. inline_inputs . iter ( ) . find ( |( n, _) | n == "workload" ) . map ( |( _, b) | b. clone ( ) ) ;
159152 let Some ( bytes) = wasm else {
160153 return TaskDispatchResponse {
161154 task_id : req. task_id . clone ( ) ,
@@ -170,8 +163,7 @@ fn execute_wasm_task(req: &TaskDispatchRequest) -> TaskDispatchResponse {
170163 config. consume_fuel ( true ) ;
171164 let engine = wasmtime:: Engine :: new ( & config) . expect ( "engine" ) ;
172165 match worldcompute:: sandbox:: wasm:: compile_module ( & engine, & bytes) {
173- Ok ( module) => match worldcompute:: sandbox:: wasm:: run_module ( & engine, & module, 10_000_000 )
174- {
166+ Ok ( module) => match worldcompute:: sandbox:: wasm:: run_module ( & engine, & module, 10_000_000 ) {
175167 Ok ( output) => TaskDispatchResponse {
176168 task_id : req. task_id . clone ( ) ,
177169 status : TaskStatus :: Succeeded ,
@@ -214,9 +206,7 @@ async fn three_node_relay_circuit_wasm_dispatch() {
214206 let r_kp = identity:: Keypair :: generate_ed25519 ( ) ;
215207 let r_peer = PeerId :: from ( r_kp. public ( ) ) ;
216208 let mut r_swarm = build_relay_swarm ( r_kp) ;
217- r_swarm
218- . listen_on ( "/ip4/127.0.0.1/tcp/0" . parse ( ) . unwrap ( ) )
219- . expect ( "relay listen" ) ;
209+ r_swarm. listen_on ( "/ip4/127.0.0.1/tcp/0" . parse ( ) . unwrap ( ) ) . expect ( "relay listen" ) ;
220210
221211 // Wait for relay to obtain a concrete listen address.
222212 let r_addr: Multiaddr = timeout ( Duration :: from_secs ( 10 ) , async {
@@ -238,16 +228,12 @@ async fn three_node_relay_circuit_wasm_dispatch() {
238228 let a_kp = identity:: Keypair :: generate_ed25519 ( ) ;
239229 let a_peer = PeerId :: from ( a_kp. public ( ) ) ;
240230 let mut a_swarm = build_client_swarm ( a_kp) ;
241- a_swarm
242- . listen_on ( "/ip4/127.0.0.1/tcp/0" . parse ( ) . unwrap ( ) )
243- . expect ( "A listen" ) ;
231+ a_swarm. listen_on ( "/ip4/127.0.0.1/tcp/0" . parse ( ) . unwrap ( ) ) . expect ( "A listen" ) ;
244232
245233 // ─── Spawn client B — will dial A through R ──────────────────────────
246234 let b_kp = identity:: Keypair :: generate_ed25519 ( ) ;
247235 let mut b_swarm = build_client_swarm ( b_kp) ;
248- b_swarm
249- . listen_on ( "/ip4/127.0.0.1/tcp/0" . parse ( ) . unwrap ( ) )
250- . expect ( "B listen" ) ;
236+ b_swarm. listen_on ( "/ip4/127.0.0.1/tcp/0" . parse ( ) . unwrap ( ) ) . expect ( "B listen" ) ;
251237
252238 // A dials R and requests a relay reservation.
253239 a_swarm. dial ( r_addr_with_peer. clone ( ) ) . expect ( "A->R dial" ) ;
@@ -266,8 +252,7 @@ async fn three_node_relay_circuit_wasm_dispatch() {
266252 0x00 , 0x61 , 0x73 , 0x6d , // magic
267253 0x01 , 0x00 , 0x00 , 0x00 , // version 1
268254 ] ;
269- let workload_cid =
270- worldcompute:: data_plane:: cid_store:: compute_cid ( & wasm_bytes) . expect ( "cid" ) ;
255+ let workload_cid = worldcompute:: data_plane:: cid_store:: compute_cid ( & wasm_bytes) . expect ( "cid" ) ;
271256 let dispatch_request = TaskDispatchRequest {
272257 task_id : "nat-test-001" . into ( ) ,
273258 manifest : make_test_manifest ( workload_cid) ,
@@ -429,8 +414,5 @@ async fn three_node_relay_circuit_wasm_dispatch() {
429414 "Dispatch via relay should succeed: {:?}" ,
430415 response. error
431416 ) ;
432- println ! (
433- "✓ Cross-NAT dispatch succeeded: {}ms via relay circuit" ,
434- response. duration_ms
435- ) ;
417+ println ! ( "✓ Cross-NAT dispatch succeeded: {}ms via relay circuit" , response. duration_ms) ;
436418}
0 commit comments