@@ -29,6 +29,12 @@ async fn local_node_place_order_with_quote_same_token_pair() {
2929 run_test ( place_order_with_quote_same_token_pair) . await ;
3030}
3131
32+ #[ tokio:: test]
33+ #[ ignore]
34+ async fn local_node_place_order_with_quote_same_token_pair_error ( ) {
35+ run_test ( place_order_with_quote_same_token_pair_error) . await ;
36+ }
37+
3238async fn place_order_with_quote ( web3 : Web3 ) {
3339 let mut onchain = OnchainComponents :: deploy ( web3. clone ( ) ) . await ;
3440
@@ -121,7 +127,7 @@ async fn place_order_with_quote(web3: Web3) {
121127 assert_eq ! ( quote_metadata. unwrap( ) . 0 , order_quote. metadata) ;
122128}
123129
124- async fn place_order_with_quote_same_token_pair ( web3 : Web3 ) {
130+ async fn place_order_with_quote_same_token_pair_error ( web3 : Web3 ) {
125131 let mut onchain = OnchainComponents :: deploy ( web3. clone ( ) ) . await ;
126132
127133 let [ solver] = onchain. make_solvers ( to_wei ( 10 ) . into_alloy ( ) ) . await ;
@@ -130,7 +136,7 @@ async fn place_order_with_quote_same_token_pair(web3: Web3) {
130136 . deploy_tokens_with_weth_uni_v2_pools ( to_wei ( 1_000 ) , to_wei ( 1_000 ) )
131137 . await ;
132138
133- token. mint ( trader. address ( ) , to_wei ( 10 ) ) . await ;
139+ token. mint ( trader. address ( ) , eth ( 10 ) ) . await ;
134140
135141 token
136142 . approve ( onchain. contracts ( ) . allowance . into_alloy ( ) , eth ( 10 ) )
@@ -143,6 +149,58 @@ async fn place_order_with_quote_same_token_pair(web3: Web3) {
143149 let services = Services :: new ( & onchain) . await ;
144150 services. start_protocol ( solver. clone ( ) ) . await ;
145151
152+ // Disable auto-mine so we don't accidentally mine a settlement
153+ web3. api :: < TestNodeApi < _ > > ( )
154+ . set_automine_enabled ( false )
155+ . await
156+ . expect ( "Must be able to disable automine" ) ;
157+
158+ tracing:: info!( "Quoting" ) ;
159+ let quote_sell_amount = to_wei ( 1 ) ;
160+ let quote_request = OrderQuoteRequest {
161+ from : trader. address ( ) ,
162+ sell_token : * token. address ( ) ,
163+ buy_token : * token. address ( ) ,
164+ side : OrderQuoteSide :: Sell {
165+ sell_amount : SellAmount :: BeforeFee {
166+ value : NonZeroU256 :: try_from ( quote_sell_amount) . unwrap ( ) ,
167+ } ,
168+ } ,
169+ ..Default :: default ( )
170+ } ;
171+ assert ! ( services. submit_quote( & quote_request) . await . is_err( ) ) ;
172+ }
173+
174+ async fn place_order_with_quote_same_token_pair ( web3 : Web3 ) {
175+ let mut onchain = OnchainComponents :: deploy ( web3. clone ( ) ) . await ;
176+
177+ let [ solver] = onchain. make_solvers ( eth ( 10 ) ) . await ;
178+ let [ trader] = onchain. make_accounts ( eth ( 10 ) ) . await ;
179+ let [ token] = onchain
180+ . deploy_tokens_with_weth_uni_v2_pools ( to_wei ( 1_000 ) , to_wei ( 1_000 ) )
181+ . await ;
182+
183+ token. mint ( trader. address ( ) , eth ( 10 ) ) . await ;
184+
185+ token
186+ . approve ( onchain. contracts ( ) . allowance . into_alloy ( ) , eth ( 10 ) )
187+ . from ( trader. address ( ) )
188+ . send_and_watch ( )
189+ . await
190+ . unwrap ( ) ;
191+
192+ tracing:: info!( "Starting services." ) ;
193+ let services = Services :: new ( & onchain) . await ;
194+ services
195+ . start_protocol_with_args (
196+ ExtraServiceArgs {
197+ api : vec ! [ "--allow-same-sell-and-buy-token=true" . to_string( ) ] ,
198+ ..Default :: default ( )
199+ } ,
200+ solver. clone ( ) ,
201+ )
202+ . await ;
203+
146204 // Disable auto-mine so we don't accidentally mine a settlement
147205 web3. api :: < TestNodeApi < _ > > ( )
148206 . set_automine_enabled ( false )
0 commit comments