@@ -6,12 +6,12 @@ pub mod view;
6
6
#[ cfg( test) ]
7
7
pub ( crate ) mod tests {
8
8
use near_sdk:: {
9
- json_types:: { Base64VecU8 , U128 , U64 } ,
9
+ json_types:: { Base64VecU8 , U128 } ,
10
10
test_utils:: accounts,
11
11
} ;
12
12
13
13
use crate :: {
14
- common:: { tests:: Context , UDecimal } ,
14
+ common:: { tests:: Context , Duration , UDecimal } ,
15
15
product:: {
16
16
api:: ProductApi ,
17
17
command:: { FixedProductTermsDto , RegisterProductCommand , TermsDto , WithdrawalFeeDto } ,
@@ -26,6 +26,8 @@ pub(crate) mod tests {
26
26
]
27
27
}
28
28
29
+ pub ( crate ) const YEAR_IN_MS : Duration = 365 * 24 * 60 * 60 * 1000 ;
30
+
29
31
pub ( crate ) fn get_product ( ) -> Product {
30
32
Product {
31
33
id : "product" . to_string ( ) ,
@@ -35,7 +37,7 @@ pub(crate) mod tests {
35
37
max : 100_000_000_000 ,
36
38
} ,
37
39
terms : Terms :: Fixed ( FixedProductTerms {
38
- lockup_term : 365 * 24 * 60 * 60 * 1000 ,
40
+ lockup_term : YEAR_IN_MS ,
39
41
allows_top_up : false ,
40
42
allows_restaking : false ,
41
43
} ) ,
@@ -45,71 +47,48 @@ pub(crate) mod tests {
45
47
}
46
48
}
47
49
48
- pub ( crate ) fn get_fee_product_command ( fee : WithdrawalFeeDto ) -> RegisterProductCommand {
50
+ pub ( crate ) fn get_product_with_fee_command ( fee : WithdrawalFeeDto ) -> RegisterProductCommand {
49
51
RegisterProductCommand {
50
52
id : "product_with_fee" . to_string ( ) ,
51
- apy_default : ( U128 ( 12 ) , 2 ) ,
52
- apy_fallback : None ,
53
- cap_min : U128 ( 100 ) ,
54
- cap_max : U128 ( 100_000_000_000 ) ,
55
- terms : TermsDto :: Fixed ( FixedProductTermsDto {
56
- lockup_term : U64 ( 365 * 24 * 60 * 60 * 1000 ) ,
57
- allows_restaking : false ,
58
- allows_top_up : false ,
59
- } ) ,
60
53
withdrawal_fee : Some ( fee) ,
61
- public_key : None ,
62
- is_enabled : true ,
54
+ ..Default :: default ( )
63
55
}
64
56
}
65
57
66
58
pub ( crate ) fn get_register_product_command ( ) -> RegisterProductCommand {
67
59
RegisterProductCommand {
68
60
id : "product" . to_string ( ) ,
69
- apy_default : ( U128 ( 12 ) , 2 ) ,
70
- apy_fallback : None ,
71
- cap_min : U128 ( 100 ) ,
72
- cap_max : U128 ( 100_000_000_000 ) ,
61
+ ..Default :: default ( )
62
+ }
63
+ }
64
+
65
+ pub ( crate ) fn get_register_refillable_product_command ( ) -> RegisterProductCommand {
66
+ RegisterProductCommand {
67
+ id : "product_refillable" . to_string ( ) ,
73
68
terms : TermsDto :: Fixed ( FixedProductTermsDto {
74
- lockup_term : U64 ( 365 * 24 * 60 * 60 * 1000 ) ,
75
- allows_restaking : false ,
76
- allows_top_up : false ,
69
+ allows_top_up : true ,
70
+ ..Default :: default ( )
77
71
} ) ,
78
- withdrawal_fee : None ,
79
- public_key : None ,
80
- is_enabled : true ,
72
+ ..Default :: default ( )
81
73
}
82
74
}
83
75
84
76
pub ( crate ) fn get_register_flexible_product_command ( ) -> RegisterProductCommand {
85
77
RegisterProductCommand {
86
78
id : "product_flexible" . to_string ( ) ,
87
- apy_default : ( U128 ( 12 ) , 2 ) ,
88
- apy_fallback : None ,
89
- cap_min : U128 ( 100 ) ,
90
- cap_max : U128 ( 100_000_000_000 ) ,
91
79
terms : TermsDto :: Flexible ,
92
- withdrawal_fee : None ,
93
- public_key : None ,
94
- is_enabled : true ,
80
+ ..Default :: default ( )
95
81
}
96
82
}
97
83
98
84
pub ( crate ) fn get_register_restakable_product_command ( ) -> RegisterProductCommand {
99
85
RegisterProductCommand {
100
86
id : "product_restakable" . to_string ( ) ,
101
- apy_default : ( U128 ( 12 ) , 2 ) ,
102
- apy_fallback : None ,
103
- cap_min : U128 ( 100 ) ,
104
- cap_max : U128 ( 100_000_000_000 ) ,
105
87
terms : TermsDto :: Fixed ( FixedProductTermsDto {
106
- lockup_term : U64 ( 365 * 24 * 60 * 60 * 1000 ) ,
107
88
allows_restaking : true ,
108
- allows_top_up : false ,
89
+ .. Default :: default ( )
109
90
} ) ,
110
- withdrawal_fee : None ,
111
- public_key : None ,
112
- is_enabled : true ,
91
+ ..Default :: default ( )
113
92
}
114
93
}
115
94
@@ -118,16 +97,8 @@ pub(crate) mod tests {
118
97
id : "product_premium" . to_string ( ) ,
119
98
apy_default : ( U128 ( 20 ) , 2 ) ,
120
99
apy_fallback : Some ( ( U128 ( 10 ) , 2 ) ) ,
121
- cap_min : U128 ( 100 ) ,
122
- cap_max : U128 ( 100_000_000_000 ) ,
123
- terms : TermsDto :: Fixed ( FixedProductTermsDto {
124
- lockup_term : U64 ( 365 * 24 * 60 * 60 * 1000 ) ,
125
- allows_top_up : false ,
126
- allows_restaking : false ,
127
- } ) ,
128
- withdrawal_fee : None ,
129
100
public_key : public_key. or_else ( || Some ( Base64VecU8 ( get_premium_product_public_key ( ) ) ) ) ,
130
- is_enabled : true ,
101
+ .. Default :: default ( )
131
102
}
132
103
}
133
104
0 commit comments