Skip to content

Commit bd2bf5a

Browse files
committed
current todos
1 parent 6a2475a commit bd2bf5a

File tree

16 files changed

+129
-71
lines changed

16 files changed

+129
-71
lines changed

adapter/src/ethereum/ewt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl Token {
154154

155155
let payload = Payload::base64_decode(payload_encoded)?;
156156

157-
let decoded_signature = base64::decode_config(&signature_encoded, base64::URL_SAFE_NO_PAD)
157+
let decoded_signature = base64::decode_config(signature_encoded, base64::URL_SAFE_NO_PAD)
158158
.map_err(EwtVerifyError::SignatureDecoding)?;
159159

160160
// if it returns the same slice, then there was no suffix

adview-manager/serve/src/routes.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ pub async fn get_preview_ad(Extension(state): Extension<Arc<State>>) -> Html<Str
5151
// All passed tokens must be of the same price and decimals, so that the amounts can be accurately compared
5252
whitelisted_tokens,
5353
size: Some(Size::new(300, 100)),
54-
// TODO: Check this value
55-
navigator_language: Some("bg".into()),
54+
navigator_language: Some("bg-BG".into()),
5655
/// Defaulted
5756
disabled_video,
5857
disabled_sticky: false,
@@ -157,8 +156,7 @@ pub async fn get_preview_video(Extension(state): Extension<Arc<State>>) -> Html<
157156
// All passed tokens must be of the same price and decimals, so that the amounts can be accurately compared
158157
whitelisted_tokens,
159158
size: Some(Size::new(728, 90)),
160-
// TODO: Check this value
161-
navigator_language: Some("bg".into()),
159+
navigator_language: Some("bg-BG".into()),
162160
/// Defaulted
163161
disabled_video,
164162
disabled_sticky: false,

adview-manager/src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ mod test {
371371
// All passed tokens must be of the same price and decimals, so that the amounts can be accurately compared
372372
whitelisted_tokens,
373373
size: Some(Size::new(300, 100)),
374-
navigator_language: Some("bg".into()),
374+
navigator_language: Some("bg-BG".into()),
375375
disabled_video: false,
376376
disabled_sticky: false,
377377
validators: vec![validator_1_url, validator_2_url],

adview-manager/src/manager.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ impl Manager {
396396
None
397397
}
398398
})
399-
// TODO: Check what should happen here if we don't find the Validator
399+
// There should always be validators since we are finding the campaign from the campaigns where we obtained the campaign id in the first place
400400
.unwrap();
401401

402402
let html = get_unit_html_with_events(
@@ -465,7 +465,7 @@ mod test {
465465
// All passed tokens must be of the same price and decimals, so that the amounts can be accurately compared
466466
whitelisted_tokens,
467467
size: Some(Size::new(300, 100)),
468-
navigator_language: Some("bg".into()),
468+
navigator_language: Some("bg-BG".into()),
469469
disabled_video: false,
470470
disabled_sticky: false,
471471
validators: vec![validator_1_url, validator_2_url, validator_3_url],
@@ -673,7 +673,6 @@ mod test {
673673

674674
assert!(res.is_some());
675675

676-
// TODO: Here we modify the campaign manually, verify that such a scenario is possible
677676
let campaign = Campaign {
678677
campaign: DUMMY_CAMPAIGN.clone(),
679678
units_with_price: vec![UnitsWithPrice {

primitives/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#![deny(clippy::all)]
33
#![deny(rustdoc::broken_intra_doc_links)]
44
#![cfg_attr(docsrs, feature(doc_cfg))]
5-
// TODO: Remove once stabled and upstream num::Integer::div_floor(...) is fixed
6-
#![allow(unstable_name_collisions)]
75
use std::{error, fmt};
86

97
#[doc(inline)]

primitives/src/targeting/eval.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ impl From<Value> for SerdeValue {
205205

206206
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
207207
#[serde(rename_all = "camelCase")]
208-
// TODO: https://github.com/AdExNetwork/adex-validator-stack-rust/issues/296
209208
pub enum Function {
210209
/// Multiplies first two values and then divides product by third value
211210
MulDiv(Box<Rule>, Box<Rule>, Box<Rule>),

primitives/src/targeting/eval_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn get_default_input() -> Input {
1515
ad_view: Some(input::AdView {
1616
seconds_since_campaign_impression: Some(10),
1717
has_custom_preferences: false,
18-
navigator_language: "bg".to_string(),
18+
navigator_language: "bg-BG".to_string(),
1919
}),
2020
global: input::Global {
2121
ad_slot_id: DUMMY_IPFS[0],

primitives/src/targeting/input.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -350,19 +350,6 @@ pub mod balances {
350350
..
351351
}) => Some(Value::UnifiedNum(*campaign_total_spent)),
352352
},
353-
// Leave the default of `0` if the publisher is not found in the balances.
354-
field::Balances::PublisherEarnedFromCampaign => {
355-
Some(Value::UnifiedNum(match self {
356-
Get::Getter(Getter {
357-
balances,
358-
publisher_id,
359-
}) => balances.get(publisher_id).cloned().unwrap_or_default(),
360-
Get::Value(Values {
361-
publisher_earned_from_campaign,
362-
..
363-
}) => *publisher_earned_from_campaign,
364-
}))
365-
}
366353
}
367354
}
368355
}
@@ -424,7 +411,7 @@ mod test {
424411
ad_view: Some(AdView {
425412
seconds_since_campaign_impression: Some(10),
426413
has_custom_preferences: true,
427-
navigator_language: "en".into(),
414+
navigator_language: "en-US".into(),
428415
}),
429416
global: Global {
430417
ad_slot_id: IPFS[0],

primitives/src/targeting/input/field.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::str::FromStr;
44

55
use crate::targeting::Error;
66

7-
pub const FIELDS: [Field; 23] = [
7+
pub const FIELDS: [Field; 22] = [
88
// AdView scope, accessible only on the AdView
99
Field::AdView(AdView::SecondsSinceCampaignImpression),
1010
Field::AdView(AdView::HasCustomPreferences),
@@ -31,7 +31,6 @@ pub const FIELDS: [Field; 23] = [
3131
Field::Campaign(Campaign::EventMaxPrice),
3232
// Balances
3333
Field::Balances(Balances::CampaignTotalSpent),
34-
Field::Balances(Balances::PublisherEarnedFromCampaign),
3534
// AdSlot scope, accessible on Supermarket and AdView
3635
Field::AdSlot(AdSlot::Categories),
3736
Field::AdSlot(AdSlot::Hostname),
@@ -147,8 +146,6 @@ impl From<Campaign> for String {
147146
#[display(style = "camelCase")]
148147
pub enum Balances {
149148
CampaignTotalSpent,
150-
// TODO: AIP#61 Should be dropped since we can't know
151-
PublisherEarnedFromCampaign,
152149
}
153150

154151
impl TryFrom<String> for Balances {
@@ -319,10 +316,6 @@ mod test {
319316
Field::Campaign(Campaign::CampaignBudget),
320317
SerdeValue::String("campaignBudget".into()),
321318
);
322-
test_field(
323-
Field::Balances(Balances::PublisherEarnedFromCampaign),
324-
SerdeValue::String("publisherEarnedFromCampaign".into()),
325-
);
326319
test_field(
327320
Field::AdSlot(AdSlot::Hostname),
328321
SerdeValue::String("adSlot.hostname".into()),

primitives/src/unified_num.rs

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,27 +309,22 @@ impl Integer for UnifiedNum {
309309
UnifiedNum::div_floor(self, other)
310310
}
311311

312-
// TODO: Check math and write tests
313312
fn mod_floor(&self, other: &Self) -> Self {
314313
self.0.mod_floor(&other.0).into()
315314
}
316315

317-
// TODO: Check math and write tests
318316
fn gcd(&self, other: &Self) -> Self {
319317
self.0.gcd(&other.0).into()
320318
}
321319

322-
// TODO: Check math and write tests
323320
fn lcm(&self, other: &Self) -> Self {
324321
self.0.lcm(&other.0).into()
325322
}
326323

327-
// TODO: Check math and write tests
328324
fn divides(&self, other: &Self) -> bool {
329325
self.0.divides(&other.0)
330326
}
331327

332-
// TODO: Check math and write tests
333328
fn is_multiple_of(&self, other: &Self) -> bool {
334329
self.0.is_multiple_of(&other.0)
335330
}
@@ -342,7 +337,6 @@ impl Integer for UnifiedNum {
342337
!self.is_even()
343338
}
344339

345-
// TODO: Check math and write tests
346340
fn div_rem(&self, other: &Self) -> (Self, Self) {
347341
let (quotient, remainder) = self.0.div_rem(&other.0);
348342

@@ -961,6 +955,69 @@ mod test {
961955
);
962956
}
963957
}
958+
959+
#[test]
960+
fn test_unified_num_mod_floor_gcd_lcm_divides_is_multiple_of_div_rem() {
961+
// Mod floor
962+
{
963+
assert_eq!(
964+
(UnifiedNum::from_u64(8)).mod_floor(&UnifiedNum::from_u64(3)),
965+
UnifiedNum::from_u64(2)
966+
);
967+
assert_eq!(
968+
(UnifiedNum::from_u64(1)).mod_floor(&UnifiedNum::from_u64(2)),
969+
UnifiedNum::from_u64(1)
970+
);
971+
}
972+
973+
// GCD
974+
{
975+
assert_eq!(
976+
UnifiedNum::from_u64(6).gcd(&UnifiedNum::from_u64(8)),
977+
UnifiedNum::from_u64(2)
978+
);
979+
assert_eq!(
980+
UnifiedNum::from_u64(7).gcd(&UnifiedNum::from_u64(3)),
981+
UnifiedNum::from_u64(1)
982+
);
983+
}
984+
985+
// LCM
986+
{
987+
assert_eq!(
988+
UnifiedNum::from_u64(7).lcm(&UnifiedNum::from_u64(3)),
989+
UnifiedNum::from_u64(21)
990+
);
991+
assert_eq!(
992+
UnifiedNum::from_u64(2).lcm(&UnifiedNum::from_u64(4)),
993+
UnifiedNum::from_u64(4)
994+
);
995+
}
996+
997+
// Is multiple of
998+
{
999+
assert_eq!(
1000+
UnifiedNum::from_u64(9).is_multiple_of(&UnifiedNum::from_u64(3)),
1001+
true
1002+
);
1003+
assert_eq!(
1004+
UnifiedNum::from_u64(3).is_multiple_of(&UnifiedNum::from_u64(9)),
1005+
false
1006+
);
1007+
}
1008+
1009+
// Div rem
1010+
{
1011+
assert_eq!(
1012+
(UnifiedNum::from_u64(8)).div_rem(&UnifiedNum::from_u64(3)),
1013+
(UnifiedNum::from_u64(2), UnifiedNum::from_u64(2))
1014+
);
1015+
assert_eq!(
1016+
(UnifiedNum::from_u64(1)).div_rem(&UnifiedNum::from_u64(2)),
1017+
(UnifiedNum::from_u64(0), UnifiedNum::from_u64(1))
1018+
);
1019+
}
1020+
}
9641021
}
9651022

9661023
#[cfg(feature = "postgres")]

0 commit comments

Comments
 (0)