@@ -69,170 +69,3 @@ pub fn asset_listed(channel: &Channel, whitelist: &[String]) -> bool {
69
69
. iter ( )
70
70
. any ( |allowed| allowed == & channel. deposit_asset )
71
71
}
72
-
73
- //#[cfg(test)]
74
- //mod test {
75
- // use time::Duration;
76
- //
77
- // use domain::channel::fixtures::{get_channel_spec, ValidatorsOption};
78
- // use domain::fixtures::{get_channel, get_validator};
79
- //
80
- // use crate::adapter::ConfigBuilder;
81
- //
82
- // use super::*;
83
- //
84
- // pub struct DummySanityChecker {}
85
- // impl SanityChecker for DummySanityChecker {}
86
- //
87
- // #[test]
88
- // fn sanity_check_disallows_channels_without_current_adapter() {
89
- // let channel = get_channel("channel_1", &None, None);
90
- // let config = ConfigBuilder::new("non_existent_validator").build();
91
- // assert_eq!(
92
- // Err(SanityError::AdapterNotIncluded),
93
- // DummySanityChecker::check(&config, &channel)
94
- // )
95
- // }
96
- //
97
- // #[test]
98
- // fn sanity_check_disallows_channels_with_passed_valid_until() {
99
- // let passed_valid_until = Utc::now() - Duration::seconds(1);
100
- // let channel = get_channel("channel_1", &Some(passed_valid_until), None);
101
- //
102
- // let identity = channel.spec.validators.leader().id.clone();
103
- // let config = ConfigBuilder::new(&identity).build();
104
- //
105
- // assert_eq!(
106
- // Err(SanityError::PassedValidUntil),
107
- // DummySanityChecker::check(&config, &channel)
108
- // )
109
- // }
110
- //
111
- // #[test]
112
- // fn sanity_check_disallows_channels_with_unlisted_in_whitelist_validators() {
113
- // let channel = get_channel("channel_1", &None, None);
114
- //
115
- // // as identity use the leader, otherwise we won't pass the AdapterNotIncluded check
116
- // let identity = channel.spec.validators.leader().id.clone();
117
- // let config = ConfigBuilder::new(&identity)
118
- // .set_validators_whitelist(&["my validator"])
119
- // .build();
120
- //
121
- // // make sure we don't use the leader or follower validators as a whitelisted validator
122
- // assert_ne!(
123
- // &identity, "my validator",
124
- // "The whitelisted validator and the leader have the same id"
125
- // );
126
- // assert_ne!(
127
- // &channel.spec.validators.follower().id,
128
- // "my validator",
129
- // "The whitelisted validator and the follower have the same id"
130
- // );
131
- //
132
- // assert_eq!(
133
- // Err(SanityError::UnlistedValidator),
134
- // DummySanityChecker::check(&config, &channel)
135
- // )
136
- // }
137
- //
138
- // #[test]
139
- // fn sanity_check_disallows_channels_with_unlisted_creator() {
140
- // let channel = get_channel("channel_1", &None, None);
141
- //
142
- // // as identity use the leader, otherwise we won't pass the AdapterNotIncluded check
143
- // let identity = channel.spec.validators.leader().id.clone();
144
- // let config = ConfigBuilder::new(&identity)
145
- // .set_creators_whitelist(&["creator"])
146
- // .build();
147
- //
148
- // assert_ne!(
149
- // &channel.creator, "creator",
150
- // "The channel creator should be different than the whitelisted creator"
151
- // );
152
- //
153
- // assert_eq!(
154
- // Err(SanityError::UnlistedCreator),
155
- // DummySanityChecker::check(&config, &channel)
156
- // )
157
- // }
158
- //
159
- // #[test]
160
- // fn sanity_check_disallows_channels_with_unlisted_asset() {
161
- // let channel = get_channel("channel_1", &None, None);
162
- //
163
- // // as identity use the leader, otherwise we won't pass the AdapterNotIncluded check
164
- // let identity = channel.spec.validators.leader().id.clone();
165
- // let config = ConfigBuilder::new(&identity)
166
- // .set_assets_whitelist(&["ASSET".into()])
167
- // .build();
168
- //
169
- // assert_ne!(
170
- // &channel.deposit_asset,
171
- // &"ASSET".into(),
172
- // "The channel deposit_asset should be different than the whitelisted asset"
173
- // );
174
- //
175
- // assert_eq!(
176
- // Err(SanityError::UnlistedAsset),
177
- // DummySanityChecker::check(&config, &channel)
178
- // )
179
- // }
180
- //
181
- // #[test]
182
- // fn sanity_check_disallows_channel_deposit_less_than_minimum_deposit() {
183
- // let channel = get_channel("channel_1", &None, None);
184
- //
185
- // // as identity use the leader, otherwise we won't pass the AdapterNotIncluded check
186
- // let identity = channel.spec.validators.leader().id.clone();
187
- // let config = ConfigBuilder::new(&identity)
188
- // // set the minimum deposit to the `channel.deposit_amount + 1`
189
- // .set_minimum_deposit(&channel.deposit_amount + &1.into())
190
- // .build();
191
- //
192
- // assert_eq!(
193
- // Err(SanityError::MinimumDepositNotMet),
194
- // DummySanityChecker::check(&config, &channel)
195
- // )
196
- // }
197
- //
198
- // #[test]
199
- // fn sanity_check_disallows_validator_fee_less_than_minimum_fee() {
200
- // let channel = get_channel("channel_1", &None, None);
201
- //
202
- // let leader = channel.spec.validators.leader();
203
- // // as identity use the leader, otherwise we won't pass the AdapterNotIncluded check
204
- // let identity = leader.id.clone();
205
- // let config = ConfigBuilder::new(&identity)
206
- // // set the minimum deposit to the `leader.fee + 1`
207
- // .set_minimum_fee(&leader.fee + &1.into())
208
- // .build();
209
- //
210
- // assert_eq!(
211
- // Err(SanityError::MinimumValidatorFeeNotMet),
212
- // DummySanityChecker::check(&config, &channel)
213
- // )
214
- // }
215
- //
216
- // #[test]
217
- // fn sanity_check_allows_for_valid_values() {
218
- // let validators = [
219
- // get_validator("my leader", Some(10.into())),
220
- // get_validator("my follower", Some(15.into())),
221
- // ];
222
- // let spec = get_channel_spec(ValidatorsOption::SpecValidators(validators.into()));
223
- // let channel = get_channel("channel_1", &None, Some(spec));
224
- //
225
- // // as identity use the leader, otherwise we won't pass the AdapterNotIncluded check
226
- // let config = ConfigBuilder::new("my leader")
227
- // .set_validators_whitelist(&["my leader", "my follower"])
228
- // .set_creators_whitelist(&[&channel.creator])
229
- // .set_assets_whitelist(&[channel.deposit_asset.clone()])
230
- // // set the minimum deposit to the `channel.deposit_amount - 1`
231
- // .set_minimum_deposit(&channel.deposit_amount - &1.into())
232
- // // set the minimum fee to the `leader.fee - 1`, i.e. `10 - 1 = 9`
233
- // .set_minimum_fee(9.into())
234
- // .build();
235
- //
236
- // assert!(DummySanityChecker::check(&config, &channel).is_ok())
237
- // }
238
- //}
0 commit comments