@@ -7,80 +7,82 @@ fn main() {
7
7
{
8
8
let create_campaign = CreateCampaign :: from_campaign_erased ( DUMMY_CAMPAIGN . clone ( ) , None ) ;
9
9
10
- let create_campaign_as_json_str = json ! ( " {
11
- \ " id\ " :null,
12
- \ " channel\ " :{
13
- \ " leader\" : \ " 0x80690751969B234697e9059e04ed72195c3507fa\ " ,
14
- \ " follower\" : \ " 0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7\ " ,
15
- \ " guardian\" : \ " 0xe061E1EB461EaBE512759aa18A201B20Fe90631D\ " ,
16
- \ " token\" : \ " 0x2BCaf6968aEC8A3b5126FBfAb5Fd419da6E8AD8E\ " ,
17
- \ " nonce\" : \ " 987654321\ "
10
+ let create_campaign_json = json ! ( {
11
+ "id" : null,
12
+ "channel" : {
13
+ "leader" : "0x80690751969B234697e9059e04ed72195c3507fa" ,
14
+ "follower" : "0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7" ,
15
+ "guardian" : "0xe061E1EB461EaBE512759aa18A201B20Fe90631D" ,
16
+ "token" : "0x2BCaf6968aEC8A3b5126FBfAb5Fd419da6E8AD8E" ,
17
+ "nonce" : "987654321"
18
18
} ,
19
- \ " creator\" : \ " 0xaCBaDA2d5830d1875ae3D2de207A1363B316Df2F\ " ,
20
- \ " budget\" : \ " 100000000000\ " ,
21
- \ " validators\ " :[
19
+ "creator" : "0xaCBaDA2d5830d1875ae3D2de207A1363B316Df2F" ,
20
+ "budget" : "100000000000" ,
21
+ "validators" : [
22
22
{
23
- \ " id\" : \ " 0x80690751969B234697e9059e04ed72195c3507fa\ " ,
24
- \ " fee\" : \ " 2000000\ " ,
25
- \ " url\" : \ " http://localhost:8005\ "
23
+ "id" : "0x80690751969B234697e9059e04ed72195c3507fa" ,
24
+ "fee" : "2000000" ,
25
+ "url" : "http://localhost:8005"
26
26
} ,
27
27
{
28
- \ " id\" : \ " 0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7\ " ,
29
- \ " fee\" : \ " 3000000\ " ,
30
- \ " url\" : \ " http://localhost:8006\ "
28
+ "id" : "0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7" ,
29
+ "fee" : "3000000" ,
30
+ "url" : "http://localhost:8006"
31
31
}
32
32
] ,
33
- \ " title\" : \ " Dummy Campaign\ " ,
34
- \ " pricingBounds\ " :{\ " CLICK\ " :{\ " min\" : \" 0 \" , \ " max\" : \" 0 \ " },\ " IMPRESSION\ " :{\ " min\" : \" 1 \" , \ " max\" : \ " 10\ " }},
35
- \ " eventSubmission\ " :{\ " allow\ " :[]},
36
- \ " targetingRules\ " :[],
37
- \ " created\" :1612162800000 ,
38
- \" active_to \" :4073414400000
39
- }" ) ;
33
+ "title" : "Dummy Campaign" ,
34
+ "pricingBounds" : { "CLICK" : { "min" : "0" , "max" : "0 "} , "IMPRESSION" : { "min" : "1" , "max" : "10" } } ,
35
+ "eventSubmission" : { "allow" : [ ] } ,
36
+ "targetingRules" : [ ] ,
37
+ "created" : 1612162800000_u64 ,
38
+ "activeTo" : 4073414400000_u64
39
+ } ) ;
40
40
41
- let create_campaign_from_json = serde_json:: from_str ( create_campaign_as_json_str) . expect ( "should deserialize" ) ;
41
+ let create_campaign_json = serde_json:: to_string ( & create_campaign_json) . expect ( "should serialize" ) ;
42
+ let deserialized: CreateCampaign = serde_json:: from_str ( & create_campaign_json) . expect ( "should deserialize" ) ;
42
43
43
- assert_eq ! ( create_campaign, create_campaign_from_json ) ;
44
+ assert_eq ! ( create_campaign, deserialized ) ;
44
45
}
45
46
46
47
// CreateCampaign with a provided ID
47
48
{
48
49
let mut create_campaign = CreateCampaign :: from_campaign_erased ( DUMMY_CAMPAIGN . clone ( ) , None ) ;
49
50
create_campaign. id = Some ( CampaignId :: from_str ( "0x936da01f9abd4d9d80c702af85c822a8" ) . expect ( "Should be valid id" ) ) ;
50
51
51
- let create_campaign_as_json_str = " {
52
- \ " id\" : \ " 0x936da01f9abd4d9d80c702af85c822a8\ " ,
53
- \ " channel\ " :{
54
- \ " leader\" : \ " 0x80690751969B234697e9059e04ed72195c3507fa\ " ,
55
- \ " follower\" : \ " 0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7\ " ,
56
- \ " guardian\" : \ " 0xe061E1EB461EaBE512759aa18A201B20Fe90631D\ " ,
57
- \ " token\" : \ " 0x2BCaf6968aEC8A3b5126FBfAb5Fd419da6E8AD8E\ " ,
58
- \ " nonce\" : \ " 987654321\ "
52
+ let create_campaign_json = json ! ( {
53
+ "id" : "0x936da01f9abd4d9d80c702af85c822a8" ,
54
+ "channel" : {
55
+ "leader" : "0x80690751969B234697e9059e04ed72195c3507fa" ,
56
+ "follower" : "0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7" ,
57
+ "guardian" : "0xe061E1EB461EaBE512759aa18A201B20Fe90631D" ,
58
+ "token" : "0x2BCaf6968aEC8A3b5126FBfAb5Fd419da6E8AD8E" ,
59
+ "nonce" : "987654321"
59
60
} ,
60
- \ " creator\" : \ " 0xaCBaDA2d5830d1875ae3D2de207A1363B316Df2F\ " ,
61
- \ " budget\" : \ " 100000000000\ " ,
62
- \ " validators\ " :[
61
+ "creator" : "0xaCBaDA2d5830d1875ae3D2de207A1363B316Df2F" ,
62
+ "budget" : "100000000000" ,
63
+ "validators" : [
63
64
{
64
- \ " id\" : \ " 0x80690751969B234697e9059e04ed72195c3507fa\ " ,
65
- \ " fee\" : \ " 2000000\ " ,
66
- \ " url\" : \ " http://localhost:8005\ "
65
+ "id" : "0x80690751969B234697e9059e04ed72195c3507fa" ,
66
+ "fee" : "2000000" ,
67
+ "url" : "http://localhost:8005"
67
68
} ,
68
69
{
69
- \ " id\" : \ " 0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7\ " ,
70
- \ " fee\" : \ " 3000000\ " ,
71
- \ " url\" : \ " http://localhost:8006\ "
70
+ "id" : "0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7" ,
71
+ "fee" : "3000000" ,
72
+ "url" : "http://localhost:8006"
72
73
}
73
74
] ,
74
- \ " title\" : \ " Dummy Campaign\ " ,
75
- \ " pricingBounds\ " :{\ " CLICK\ " :{\ " min\" : \" 0 \" , \ " max\" : \" 0 \ " },\ " IMPRESSION\ " :{\ " min\" : \" 1 \" , \ " max\" : \ " 10\ " }},
76
- \ " eventSubmission\ " :{\ " allow\ " :[]},
77
- \ " targetingRules\ " :[],
78
- \ " created\" :1612162800000 ,
79
- \" active_to \" :4073414400000
80
- }" ;
75
+ "title" : "Dummy Campaign" ,
76
+ "pricingBounds" : { "CLICK" : { "min" : "0" , "max" : "0 "} , "IMPRESSION" : { "min" : "1" , "max" : "10" } } ,
77
+ "eventSubmission" : { "allow" : [ ] } ,
78
+ "targetingRules" : [ ] ,
79
+ "created" : 1612162800000_u64 ,
80
+ "activeTo" : 4073414400000_u64
81
+ } ) ;
81
82
82
- let create_campaign_from_json = serde_json:: from_str ( create_campaign_as_json_str) . expect ( "should deserialize" ) ;
83
+ let create_campaign_json = serde_json:: to_string ( & create_campaign_json) . expect ( "should serialize" ) ;
84
+ let deserialized: CreateCampaign = serde_json:: from_str ( & create_campaign_json) . expect ( "should deserialize" ) ;
83
85
84
- assert_eq ! ( create_campaign, create_campaign_from_json ) ;
86
+ assert_eq ! ( create_campaign, deserialized ) ;
85
87
}
86
88
}
0 commit comments