@@ -71,141 +71,15 @@ pub use client::{
7171 preset,
7272} ;
7373pub use error:: E2EError ;
74+ pub use ink_e2e:: IntoAccountId ;
75+ pub use ink_e2e_macro:: test;
76+
77+ // Re-export assertion macros from ink_e2e for unified API across backends
7478pub use ink_e2e:: {
75- IntoAccountId ,
7679 assert_last_event,
7780 assert_noop,
7881 assert_ok,
7982} ;
80- pub use ink_e2e_macro:: test;
81-
82- /// Asserts that a contract call succeeded without reverting.
83- ///
84- /// This macro follows FRAME's `assert_ok!` convention for consistency across
85- /// the Polkadot ecosystem. It verifies that a contract call completed successfully
86- /// and did not revert. If the call reverted, the macro panics with a detailed
87- /// error message extracted from the call trace.
88- ///
89- /// # Behavior
90- ///
91- /// - Takes a `CallResult` as input
92- /// - Checks if `dry_run.did_revert()` is `false`
93- /// - Panics with error details if the call reverted
94- /// - Returns the `CallResult` for further inspection if successful
95- ///
96- /// # Examples
97- ///
98- /// ```ignore
99- /// let result = client.call(&alice, &transfer).submit().await?;
100- /// assert_ok!(result);
101- /// ```
102- #[ macro_export]
103- macro_rules! assert_ok {
104- ( $result: expr) => { {
105- let result = $result;
106- if result. dry_run. did_revert( ) {
107- panic!(
108- "Expected call to succeed but it reverted.\n Error: {:?}" ,
109- result. extract_error( )
110- ) ;
111- }
112- result
113- } } ;
114- ( $result: expr, $( $msg: tt) +) => { {
115- let result = $result;
116- if result. dry_run. did_revert( ) {
117- panic!(
118- "{}\n Expected call to succeed but it reverted.\n Error: {:?}" ,
119- format_args!( $( $msg) +) ,
120- result. extract_error( )
121- ) ;
122- }
123- result
124- } } ;
125- }
126-
127- /// Asserts that a contract call reverted with a specific error.
128- ///
129- /// This macro follows FRAME's `assert_noop!` convention, which stands for
130- /// "assert no operation" - meaning the call should fail without changing state.
131- /// It verifies that a contract call reverted and that the revert reason matches
132- /// the expected error string.
133- ///
134- /// # Behavior
135- ///
136- /// - Takes a `CallResult` and an expected error string as input
137- /// - Checks if `dry_run.did_revert()` is `true`
138- /// - Panics if the call succeeded (did not revert)
139- /// - Extracts the error from the call trace using `extract_error()`
140- /// - Panics if the actual error doesn't match the expected error
141- /// - Returns the `CallResult` if both checks pass
142- ///
143- /// # Examples
144- ///
145- /// ```ignore
146- /// let result = client.call(&alice, &insufficient_transfer).submit().await?;
147- /// assert_noop!(result, "BalanceLow");
148- /// ```
149- #[ macro_export]
150- macro_rules! assert_noop {
151- ( $result: expr, $expected_error: expr) => { {
152- let result = $result;
153- if !result. dry_run. did_revert( ) {
154- panic!(
155- "Expected call to revert with '{}' but it succeeded" ,
156- $expected_error
157- ) ;
158- }
159-
160- let actual_error = result. extract_error( ) ;
161- if actual_error != Some ( $expected_error. to_string( ) ) {
162- panic!(
163- "Expected error '{}' but got {:?}" ,
164- $expected_error,
165- actual_error
166- ) ;
167- }
168-
169- result
170- } } ;
171- ( $result: expr, $expected_error: expr, $( $msg: tt) +) => { {
172- let result = $result;
173- if !result. dry_run. did_revert( ) {
174- panic!(
175- "{}\n Expected call to revert with '{}' but it succeeded" ,
176- format_args!( $( $msg) +) ,
177- $expected_error
178- ) ;
179- }
180-
181- let actual_error = result. extract_error( ) ;
182- if actual_error != Some ( $expected_error. to_string( ) ) {
183- panic!(
184- "{}\n Expected error '{}' but got {:?}" ,
185- format_args!( $( $msg) +) ,
186- $expected_error,
187- actual_error
188- ) ;
189- }
190-
191- result
192- } } ;
193- }
194-
195- /// Asserts that the latest contract event matches an expected event.
196- ///
197- /// This macro verifies that the last emitted contract event from the sandbox
198- /// matches the provided expected event.
199- ///
200- /// # Parameters
201- /// - `client` - Mutable reference to the sandbox client
202- /// - `event` - The expected event
203- #[ macro_export]
204- macro_rules! assert_last_event {
205- ( $client: expr, $event: expr $( , ) ?) => {
206- $crate:: client:: assert_last_contract_event_inner( $client, $event)
207- } ;
208- }
20983
21084/// A snapshot of the storage.
21185#[ derive( Clone , Debug ) ]
0 commit comments