1818//! log. The reject fixtures are structurally invalid step logs and the guest
1919//! must abort on every one, each for its own reason.
2020//!
21- //! The abort reason only surfaces on the process stderr, so the reject
22- //! assertions run the CLI as a subprocess and match the reason there.
21+ //! The reason arrives through the public-values stream (surfaced in
22+ //! try_execute's error), the one channel every executor backend carries —
23+ //! stderr forwarding is interpreter-only.
2324//!
2425//! Generate the fixtures with `make -C sp1 fixtures` (needs a built emulator).
2526
26- use std:: { fs, path:: PathBuf , process :: Command } ;
27+ use std:: { fs, path:: PathBuf } ;
2728
2829use cartesi_sp1:: try_execute;
2930use sp1_sdk:: { Elf , ProverClient } ;
@@ -69,8 +70,8 @@ fn guest_elf() -> Elf {
6970 Elf :: Static ( Box :: leak ( bytes. into_boxed_slice ( ) ) )
7071}
7172
72- #[ test]
73- fn guest_rejects_forged_logs ( ) {
73+ #[ tokio :: test]
74+ async fn guest_rejects_forged_logs ( ) {
7475 let dir = fixtures_dir ( ) . join ( "reject-machine" ) ;
7576 assert ! (
7677 dir. exists( ) ,
@@ -80,8 +81,8 @@ fn guest_rejects_forged_logs() {
8081 let text = fs:: read_to_string ( dir. join ( "_manifest.csv" ) )
8182 . unwrap_or_else ( |e| panic ! ( "failed to read reject manifest: {e}" ) ) ;
8283
83- let cli = env ! ( "CARGO_BIN_EXE_cartesi-sp1-cli" ) ;
84- let guest = repo_root ( ) . join ( "sp1/cpp/guest.elf" ) ;
84+ let client = ProverClient :: builder ( ) . light ( ) . build ( ) . await ;
85+ let elf = guest_elf ( ) ;
8586 let mut checked = 0 ;
8687 for line in text. lines ( ) . skip ( 1 ) {
8788 if line. is_empty ( ) {
@@ -96,21 +97,15 @@ fn guest_rejects_forged_logs() {
9697 let ( name, tag) = ( cols[ 1 ] , cols[ 2 ] ) ;
9798 let path = dir. join ( name) ;
9899
99- let output = Command :: new ( cli)
100- . args ( [ "--guest-elf" , guest. to_str ( ) . unwrap ( ) ] )
101- . args ( [ "execute" , path. to_str ( ) . unwrap ( ) ] )
102- . output ( )
103- . unwrap_or_else ( |e| panic ! ( "running {cli}: {e}" ) ) ;
104- assert ! (
105- !output. status. success( ) ,
106- "guest ACCEPTED forged log {name} (tag {tag})"
107- ) ;
108- let stderr = String :: from_utf8_lossy ( & output. stderr ) ;
100+ let error = try_execute ( & client, elf. clone ( ) , path. to_str ( ) . unwrap ( ) )
101+ . await
102+ . err ( )
103+ . unwrap_or_else ( || panic ! ( "guest ACCEPTED forged log {name} (tag {tag})" ) ) ;
109104 let expected = expected_message ( tag) ;
110105 assert ! (
111- stderr . contains( expected) ,
106+ error . contains( expected) ,
112107 "forged log {name} (tag {tag}) rejected for the wrong reason:\n \
113- expected substring {expected:?}\n stderr : {stderr }"
108+ expected substring {expected:?}\n error : {error }"
114109 ) ;
115110 checked += 1 ;
116111 }
0 commit comments