@@ -24,7 +24,6 @@ pub enum Backend {
2424 ///
2525 /// This runs a runtime emulator within `TestExternalities`
2626 /// the same process as the test.
27- #[ cfg( any( test, feature = "sandbox" ) ) ]
2827 RuntimeOnly ( RuntimeOnly ) ,
2928}
3029
@@ -64,22 +63,21 @@ impl Node {
6463}
6564
6665/// The runtime emulator that should be used within `TestExternalities`
67- #[ cfg( any( test, feature = "sandbox" ) ) ]
6866#[ derive( Clone , Eq , PartialEq , Debug , darling:: FromMeta ) ]
69- pub enum RuntimeOnly {
70- #[ darling( word) ]
71- #[ darling( skip) ]
72- Default ,
73- Sandbox ( syn:: Path ) ,
67+ pub struct RuntimeOnly {
68+ /// The sandbox runtime type (e.g., `ink_sandbox::DefaultSandbox`)
69+ pub sandbox : syn:: Path ,
70+ /// The client type implementing the backend traits (e.g.,
71+ /// `ink_sandbox::SandboxClient`)
72+ pub client : syn:: Path ,
7473}
7574
76- #[ cfg( any( test, feature = "sandbox" ) ) ]
77- impl From < RuntimeOnly > for syn:: Path {
78- fn from ( value : RuntimeOnly ) -> Self {
79- match value {
80- RuntimeOnly :: Default => syn:: parse_quote! { :: ink_e2e:: DefaultSandbox } ,
81- RuntimeOnly :: Sandbox ( path) => path,
82- }
75+ impl RuntimeOnly {
76+ pub fn runtime_path ( & self ) -> syn:: Path {
77+ self . sandbox . clone ( )
78+ }
79+ pub fn client_path ( & self ) -> syn:: Path {
80+ self . client . clone ( )
8381 }
8482}
8583
@@ -146,7 +144,7 @@ mod tests {
146144 fn config_works_backend_runtime_only ( ) {
147145 let input = quote ! {
148146 environment = crate :: CustomEnvironment ,
149- backend( runtime_only) ,
147+ backend( runtime_only( sandbox = :: ink_sandbox :: DefaultSandbox , client = :: ink_sandbox :: SandboxClient ) ) ,
150148 } ;
151149 let config =
152150 E2EConfig :: from_list ( & NestedMeta :: parse_meta_list ( input) . unwrap ( ) ) . unwrap ( ) ;
@@ -156,7 +154,13 @@ mod tests {
156154 Some ( syn:: parse_quote! { crate :: CustomEnvironment } )
157155 ) ;
158156
159- assert_eq ! ( config. backend( ) , Backend :: RuntimeOnly ( RuntimeOnly :: Default ) ) ;
157+ assert_eq ! (
158+ config. backend( ) ,
159+ Backend :: RuntimeOnly ( RuntimeOnly {
160+ sandbox: syn:: parse_quote! { :: ink_sandbox:: DefaultSandbox } ,
161+ client: syn:: parse_quote! { :: ink_sandbox:: SandboxClient } ,
162+ } )
163+ ) ;
160164 }
161165
162166 #[ test]
@@ -168,22 +172,29 @@ mod tests {
168172 let config =
169173 E2EConfig :: from_list ( & NestedMeta :: parse_meta_list ( input) . unwrap ( ) ) . unwrap ( ) ;
170174
171- assert_eq ! ( config. backend( ) , Backend :: RuntimeOnly ( RuntimeOnly :: Default ) ) ;
175+ assert_eq ! (
176+ config. backend( ) ,
177+ Backend :: RuntimeOnly ( RuntimeOnly {
178+ sandbox: syn:: parse_quote! { :: ink_sandbox:: DefaultSandbox } ,
179+ client: syn:: parse_quote! { :: ink_sandbox:: SandboxClient } ,
180+ } )
181+ ) ;
172182 }
173183
174184 #[ test]
175185 fn config_works_runtime_only_with_custom_backend ( ) {
176186 let input = quote ! {
177- backend( runtime_only( sandbox = :: ink_e2e :: DefaultSandbox ) ) ,
187+ backend( runtime_only( sandbox = :: ink_sandbox :: DefaultSandbox , client = :: ink_sandbox :: SandboxClient ) ) ,
178188 } ;
179189 let config =
180190 E2EConfig :: from_list ( & NestedMeta :: parse_meta_list ( input) . unwrap ( ) ) . unwrap ( ) ;
181191
182192 assert_eq ! (
183193 config. backend( ) ,
184- Backend :: RuntimeOnly ( RuntimeOnly :: Sandbox (
185- syn:: parse_quote! { :: ink_e2e:: DefaultSandbox }
186- ) )
194+ Backend :: RuntimeOnly ( RuntimeOnly {
195+ sandbox: syn:: parse_quote! { :: ink_sandbox:: DefaultSandbox } ,
196+ client: syn:: parse_quote! { :: ink_sandbox:: SandboxClient } ,
197+ } )
187198 ) ;
188199 }
189200
0 commit comments