@@ -88,85 +88,8 @@ mod call_builder {
8888 type E2EResult < T > = std:: result:: Result < T , Box < dyn std:: error:: Error > > ;
8989
9090 #[ ink_e2e:: test(
91- additional_contracts = "../integration-flipper /Cargo.toml ../constructors-return-value /Cargo.toml"
91+ additional_contracts = "../constructors-return-value /Cargo.toml ../integration-flipper /Cargo.toml"
9292 ) ]
93- async fn e2e_invalid_message_selector_can_be_handled (
94- mut client : ink_e2e:: Client < C , E > ,
95- ) -> E2EResult < ( ) > {
96- use call_builder:: contract_types:: ink_primitives:: {
97- types:: AccountId as E2EAccountId ,
98- LangError as E2ELangError ,
99- } ;
100-
101- let constructor = call_builder:: constructors:: new ( ) ;
102- let contract_acc_id = client
103- . instantiate ( & mut ink_e2e:: charlie ( ) , constructor, 0 , None )
104- . await
105- . expect ( "instantiate failed" )
106- . account_id ;
107-
108- let flipper_constructor = integration_flipper:: constructors:: default ( ) ;
109- let flipper_acc_id = client
110- . instantiate ( & mut ink_e2e:: charlie ( ) , flipper_constructor, 0 , None )
111- . await
112- . expect ( "instantiate `flipper` failed" )
113- . account_id ;
114-
115- let get_call_result = client
116- . call (
117- & mut ink_e2e:: charlie ( ) ,
118- flipper_acc_id. clone ( ) ,
119- integration_flipper:: messages:: get ( ) ,
120- 0 ,
121- None ,
122- )
123- . await
124- . expect ( "Calling `flipper::get` failed" ) ;
125- let initial_value = get_call_result
126- . value
127- . expect ( "Input is valid, call must not fail." ) ;
128-
129- let flipper_ink_acc_id = E2EAccountId ( flipper_acc_id. clone ( ) . into ( ) ) ;
130- let invalid_selector = [ 0x00 , 0x00 , 0x00 , 0x00 ] ;
131- let call_result = client
132- . call (
133- & mut ink_e2e:: charlie ( ) ,
134- contract_acc_id. clone ( ) ,
135- call_builder:: messages:: call ( flipper_ink_acc_id, invalid_selector) ,
136- 0 ,
137- None ,
138- )
139- . await
140- . expect ( "Calling `call_builder::call` failed" ) ;
141-
142- let flipper_result = call_result
143- . value
144- . expect ( "Call to `call_builder::call` failed" ) ;
145-
146- assert ! ( matches!(
147- flipper_result,
148- Some ( E2ELangError :: CouldNotReadInput )
149- ) ) ;
150-
151- let get_call_result = client
152- . call (
153- & mut ink_e2e:: charlie ( ) ,
154- flipper_acc_id. clone ( ) ,
155- integration_flipper:: messages:: get ( ) ,
156- 0 ,
157- None ,
158- )
159- . await
160- . expect ( "Calling `flipper::get` failed" ) ;
161- let flipped_value = get_call_result
162- . value
163- . expect ( "Input is valid, call must not fail." ) ;
164- assert ! ( flipped_value == initial_value) ;
165-
166- Ok ( ( ) )
167- }
168-
169- #[ ink_e2e:: test( additional_contracts = "../constructors-return-value/Cargo.toml" ) ]
17093 async fn e2e_create_builder_works_with_valid_selector (
17194 mut client : ink_e2e:: Client < C , E > ,
17295 ) -> E2EResult < ( ) > {
@@ -264,4 +187,86 @@ mod call_builder {
264187 Ok ( ( ) )
265188 }
266189 }
190+
191+ #[ cfg( all( test, feature = "e2e-tests" ) ) ]
192+ mod e2e_message_tests {
193+ type E2EResult < T > = std:: result:: Result < T , Box < dyn std:: error:: Error > > ;
194+
195+ #[ ink_e2e:: test( additional_contracts = "../integration-flipper/Cargo.toml" ) ]
196+ async fn e2e_invalid_message_selector_can_be_handled (
197+ mut client : ink_e2e:: Client < C , E > ,
198+ ) -> E2EResult < ( ) > {
199+ use call_builder:: contract_types:: ink_primitives:: {
200+ types:: AccountId as E2EAccountId ,
201+ LangError as E2ELangError ,
202+ } ;
203+
204+ let constructor = call_builder:: constructors:: new ( ) ;
205+ let contract_acc_id = client
206+ . instantiate ( & mut ink_e2e:: charlie ( ) , constructor, 0 , None )
207+ . await
208+ . expect ( "instantiate failed" )
209+ . account_id ;
210+
211+ let flipper_constructor = integration_flipper:: constructors:: default ( ) ;
212+ let flipper_acc_id = client
213+ . instantiate ( & mut ink_e2e:: charlie ( ) , flipper_constructor, 0 , None )
214+ . await
215+ . expect ( "instantiate `flipper` failed" )
216+ . account_id ;
217+
218+ let get_call_result = client
219+ . call (
220+ & mut ink_e2e:: charlie ( ) ,
221+ flipper_acc_id. clone ( ) ,
222+ integration_flipper:: messages:: get ( ) ,
223+ 0 ,
224+ None ,
225+ )
226+ . await
227+ . expect ( "Calling `flipper::get` failed" ) ;
228+ let initial_value = get_call_result
229+ . value
230+ . expect ( "Input is valid, call must not fail." ) ;
231+
232+ let flipper_ink_acc_id = E2EAccountId ( flipper_acc_id. clone ( ) . into ( ) ) ;
233+ let invalid_selector = [ 0x00 , 0x00 , 0x00 , 0x00 ] ;
234+ let call_result = client
235+ . call (
236+ & mut ink_e2e:: charlie ( ) ,
237+ contract_acc_id. clone ( ) ,
238+ call_builder:: messages:: call ( flipper_ink_acc_id, invalid_selector) ,
239+ 0 ,
240+ None ,
241+ )
242+ . await
243+ . expect ( "Calling `call_builder::call` failed" ) ;
244+
245+ let flipper_result = call_result
246+ . value
247+ . expect ( "Call to `call_builder::call` failed" ) ;
248+
249+ assert ! ( matches!(
250+ flipper_result,
251+ Some ( E2ELangError :: CouldNotReadInput )
252+ ) ) ;
253+
254+ let get_call_result = client
255+ . call (
256+ & mut ink_e2e:: charlie ( ) ,
257+ flipper_acc_id. clone ( ) ,
258+ integration_flipper:: messages:: get ( ) ,
259+ 0 ,
260+ None ,
261+ )
262+ . await
263+ . expect ( "Calling `flipper::get` failed" ) ;
264+ let flipped_value = get_call_result
265+ . value
266+ . expect ( "Input is valid, call must not fail." ) ;
267+ assert ! ( flipped_value == initial_value) ;
268+
269+ Ok ( ( ) )
270+ }
271+ }
267272}
0 commit comments