@@ -25,7 +25,7 @@ use crate::{mock::*, *};
2525#[ test]
2626fn create_order_should_work ( ) {
2727 new_test_ext ( ) . execute_with ( || {
28- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 1 . to_fixed ( ) ) ) ;
28+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 100 ) ) ;
2929
3030 assert_eq ! ( Auction :: order_id( ) , 1 ) ;
3131
@@ -46,8 +46,8 @@ fn create_order_should_work() {
4646#[ test]
4747fn double_create_order_should_work ( ) {
4848 new_test_ext ( ) . execute_with ( || {
49- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 1 . to_fixed ( ) ) ) ;
50- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 1 . to_fixed ( ) ) ) ;
49+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 50 ) ) ;
50+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 50 ) ) ;
5151
5252 assert_eq ! ( Auction :: order_id( ) , 2 ) ;
5353
@@ -71,11 +71,11 @@ fn double_create_order_should_work() {
7171fn create_order_by_origin_illegal_should_fail ( ) {
7272 new_test_ext ( ) . execute_with ( || {
7373 assert_noop ! (
74- Auction :: create_order( Origin :: root( ) , 3000 , 13 , 20 , 100 , 1 . to_fixed ( ) ) ,
74+ Auction :: create_order( Origin :: root( ) , 3000 , 13 , 20 , 100 , 100 ) ,
7575 DispatchError :: BadOrigin
7676 ) ;
7777 assert_noop ! (
78- Auction :: create_order( Origin :: none( ) , 3000 , 13 , 20 , 100 , 1 . to_fixed ( ) ) ,
78+ Auction :: create_order( Origin :: none( ) , 3000 , 13 , 20 , 100 , 100 ) ,
7979 DispatchError :: BadOrigin
8080 ) ;
8181 } ) ;
@@ -85,7 +85,7 @@ fn create_order_by_origin_illegal_should_fail() {
8585fn create_order_under_minimum_supply_should_fail ( ) {
8686 new_test_ext ( ) . execute_with ( || {
8787 assert_noop ! (
88- Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 0 , 1 . to_fixed ( ) ) ,
88+ Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 0 , 0 ) ,
8989 Error :: <Test >:: NotEnoughSupply
9090 ) ;
9191 } ) ;
@@ -95,14 +95,14 @@ fn create_order_under_minimum_supply_should_fail() {
9595fn create_order_without_enough_vsbond_should_fail ( ) {
9696 new_test_ext ( ) . execute_with ( || {
9797 assert_noop ! (
98- Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 1000 , 1 . to_fixed ( ) ) ,
98+ Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 1000 , 1000 ) ,
9999 Error :: <Test >:: NotEnoughBalanceToReserve ,
100100 ) ;
101101
102102 const LOCK_ID : LockIdentifier = 0u64 . to_be_bytes ( ) ;
103103 assert_ok ! ( Tokens :: set_lock( LOCK_ID , VSBOND , & ALICE , 50 ) ) ;
104104 assert_noop ! (
105- Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 51 , 1 . to_fixed ( ) ) ,
105+ Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 51 , 51 ) ,
106106 Error :: <Test >:: NotEnoughBalanceToReserve ,
107107 ) ;
108108 } ) ;
@@ -112,11 +112,11 @@ fn create_order_without_enough_vsbond_should_fail() {
112112fn create_order_exceed_maximum_order_in_trade_should_fail ( ) {
113113 new_test_ext ( ) . execute_with ( || {
114114 for _ in 0 ..MaximumOrderInTrade :: get ( ) {
115- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 1 , 1 . to_fixed ( ) ) ) ;
115+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 1 , 1 ) ) ;
116116 }
117117
118118 assert_noop ! (
119- Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 1 , 1 . to_fixed ( ) ) ,
119+ Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 1 , 1 ) ,
120120 Error :: <Test >:: ExceedMaximumOrderInTrade ,
121121 ) ;
122122 } ) ;
@@ -125,7 +125,7 @@ fn create_order_exceed_maximum_order_in_trade_should_fail() {
125125#[ test]
126126fn revoke_order_should_work ( ) {
127127 new_test_ext ( ) . execute_with ( || {
128- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 1 . to_fixed ( ) ) ) ;
128+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 100 ) ) ;
129129 assert_ok ! ( Auction :: revoke_order( Some ( ALICE ) . into( ) , 0 ) ) ;
130130
131131 assert_eq ! ( Auction :: order_id( ) , 1 ) ;
@@ -150,7 +150,7 @@ fn revoke_order_should_work() {
150150#[ test]
151151fn revoke_order_which_be_partial_clinchd_should_work ( ) {
152152 new_test_ext ( ) . execute_with ( || {
153- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 1 . to_fixed ( ) ) ) ;
153+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 50 ) ) ;
154154 assert_ok ! ( Auction :: partial_clinch_order( Some ( BRUCE ) . into( ) , 0 , 25 ) ) ;
155155 assert_ok ! ( Auction :: revoke_order( Some ( ALICE ) . into( ) , 0 ) ) ;
156156
@@ -177,18 +177,14 @@ fn revoke_order_which_be_partial_clinchd_should_work() {
177177#[ test]
178178fn revoke_order_not_exist_should_fail ( ) {
179179 new_test_ext ( ) . execute_with ( || {
180- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 1 . to_fixed( ) ) ) ;
181- assert_noop ! (
182- Auction :: partial_clinch_order( Some ( BRUCE ) . into( ) , 1 , 25 ) ,
183- Error :: <Test >:: NotFindOrderInfo
184- ) ;
180+ assert_noop ! ( Auction :: revoke_order( Some ( ALICE ) . into( ) , 0 ) , Error :: <Test >:: NotFindOrderInfo ) ;
185181 } ) ;
186182}
187183
188184#[ test]
189185fn revoke_order_without_enough_reserved_vsbond_should_fail ( ) {
190186 new_test_ext ( ) . execute_with ( || {
191- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 1 . to_fixed ( ) ) ) ;
187+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 50 ) ) ;
192188 assert_ok ! ( Tokens :: repatriate_reserved(
193189 VSBOND ,
194190 & ALICE ,
@@ -206,7 +202,7 @@ fn revoke_order_without_enough_reserved_vsbond_should_fail() {
206202#[ test]
207203fn revoke_order_by_origin_illegal_should_fail ( ) {
208204 new_test_ext ( ) . execute_with ( || {
209- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 1 . to_fixed ( ) ) ) ;
205+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 50 ) ) ;
210206 assert_noop ! (
211207 Auction :: revoke_order( Some ( BRUCE ) . into( ) , 0 ) ,
212208 Error :: <Test >:: ForbidRevokeOrderWithoutOwnership
@@ -219,14 +215,14 @@ fn revoke_order_by_origin_illegal_should_fail() {
219215#[ test]
220216fn revoke_order_not_in_trade_should_fail ( ) {
221217 new_test_ext ( ) . execute_with ( || {
222- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 1 . to_fixed ( ) ) ) ;
218+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 50 ) ) ;
223219 assert_ok ! ( Auction :: revoke_order( Some ( ALICE ) . into( ) , 0 ) ) ;
224220 assert_noop ! (
225221 Auction :: revoke_order( Some ( ALICE ) . into( ) , 0 ) ,
226222 Error :: <Test >:: ForbidRevokeOrderNotInTrade
227223 ) ;
228224
229- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 1 . to_fixed ( ) ) ) ;
225+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 50 , 50 ) ) ;
230226 assert_ok ! ( Auction :: clinch_order( Some ( BRUCE ) . into( ) , 1 ) ) ;
231227 assert_noop ! (
232228 Auction :: revoke_order( Some ( ALICE ) . into( ) , 1 ) ,
@@ -238,7 +234,7 @@ fn revoke_order_not_in_trade_should_fail() {
238234#[ test]
239235fn partial_clinch_order_should_work ( ) {
240236 new_test_ext ( ) . execute_with ( || {
241- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 0.33 . to_fixed ( ) ) ) ;
237+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 33 ) ) ;
242238 assert_ok ! ( Auction :: partial_clinch_order( Some ( BRUCE ) . into( ) , 0 , 33 ) ) ;
243239
244240 assert_eq ! ( Auction :: order_id( ) , 1 ) ;
@@ -304,7 +300,7 @@ fn partial_clinch_order_should_work() {
304300#[ test]
305301fn partial_clinch_order_not_exist_should_fail ( ) {
306302 new_test_ext ( ) . execute_with ( || {
307- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 1 . to_fixed ( ) ) ) ;
303+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 100 ) ) ;
308304 assert_noop ! ( Auction :: clinch_order( Some ( BRUCE ) . into( ) , 1 ) , Error :: <Test >:: NotFindOrderInfo ) ;
309305 assert_noop ! (
310306 Auction :: partial_clinch_order( Some ( BRUCE ) . into( ) , 1 , 50 ) ,
@@ -316,7 +312,7 @@ fn partial_clinch_order_not_exist_should_fail() {
316312#[ test]
317313fn clinch_order_by_origin_illegal_should_fail ( ) {
318314 new_test_ext ( ) . execute_with ( || {
319- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 1 . to_fixed ( ) ) ) ;
315+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 100 ) ) ;
320316 assert_noop ! (
321317 Auction :: clinch_order( Some ( ALICE ) . into( ) , 0 ) ,
322318 Error :: <Test >:: ForbidClinchOrderWithinOwnership
@@ -340,14 +336,14 @@ fn clinch_order_by_origin_illegal_should_fail() {
340336#[ test]
341337fn clinch_order_not_in_trade_should_fail ( ) {
342338 new_test_ext ( ) . execute_with ( || {
343- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 1 . to_fixed ( ) ) ) ;
339+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 100 ) ) ;
344340 assert_ok ! ( Auction :: revoke_order( Some ( ALICE ) . into( ) , 0 ) ) ;
345341 assert_noop ! (
346342 Auction :: partial_clinch_order( Some ( BRUCE ) . into( ) , 0 , 50 ) ,
347343 Error :: <Test >:: ForbidClinchOrderNotInTrade
348344 ) ;
349345
350- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 1 . to_fixed ( ) ) ) ;
346+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 100 ) ) ;
351347 assert_ok ! ( Auction :: clinch_order( Some ( BRUCE ) . into( ) , 1 ) ) ;
352348 assert_noop ! (
353349 Auction :: partial_clinch_order( Some ( BRUCE ) . into( ) , 1 , 50 ) ,
@@ -359,20 +355,20 @@ fn clinch_order_not_in_trade_should_fail() {
359355#[ test]
360356fn clinch_order_without_enough_token_should_fail ( ) {
361357 new_test_ext ( ) . execute_with ( || {
362- assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 2 . to_fixed ( ) ) ) ;
358+ assert_ok ! ( Auction :: create_order( Some ( ALICE ) . into( ) , 3000 , 13 , 20 , 100 , 200 ) ) ;
363359 assert_ok ! ( Auction :: partial_clinch_order( Some ( BRUCE ) . into( ) , 0 , 50 ) ) ;
364360 assert_noop ! ( Auction :: clinch_order( Some ( BRUCE ) . into( ) , 0 ) , Error :: <Test >:: CantPayThePrice ) ;
365361 } ) ;
366362}
367363
368364// Test Utilities
369365#[ test]
370- fn check_total_price ( ) {
366+ fn check_price_to_pay ( ) {
371367 let unit_price: U64F64 = 0.333f64 . to_fixed ( ) ;
372368 let quantities: [ BalanceOf < Test > ; 4 ] = [ 3 , 33 , 333 , 3333 ] ;
373- let total_prices : [ BalanceOf < Test > ; 4 ] = [ 1 , 11 , 111 , 1110 ] ;
369+ let price_to_pays : [ BalanceOf < Test > ; 4 ] = [ 1 , 11 , 111 , 1110 ] ;
374370
375- for ( quantity, total_price ) in quantities. iter ( ) . zip ( total_prices . iter ( ) ) {
376- assert_eq ! ( Auction :: total_price ( * quantity, unit_price) , * total_price ) ;
371+ for ( quantity, price_to_pay ) in quantities. iter ( ) . zip ( price_to_pays . iter ( ) ) {
372+ assert_eq ! ( Auction :: price_to_pay ( * quantity, unit_price) , * price_to_pay ) ;
377373 }
378374}
0 commit comments