@dashevo/dashpay-contract 0.25.21 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc CHANGED
@@ -17,6 +17,7 @@
17
17
  "mocha": true
18
18
  },
19
19
  "globals": {
20
- "expect": true
20
+ "expect": true,
21
+ "BigInt": true
21
22
  }
22
23
  }
package/Cargo.toml CHANGED
@@ -1,11 +1,13 @@
1
1
  [package]
2
2
  name = "dashpay-contract"
3
3
  description = "DashPay data contract schema and tools"
4
- version = "0.25.21"
4
+ version = "1.0.0-beta.1"
5
5
  edition = "2021"
6
- rust-version = "1.73"
6
+ rust-version = "1.76"
7
7
  license = "MIT"
8
8
 
9
9
  [dependencies]
10
+ platform-version = { path = "../rs-platform-version" }
11
+ thiserror = "1.0.58"
10
12
  serde_json = { version = "1.0" }
11
13
  platform-value = { path = "../rs-platform-value" }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/dashpay-contract",
3
- "version": "0.25.21",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "Reference contract of the DashPay DPA on Dash Evolution",
5
5
  "scripts": {
6
6
  "lint": "eslint .",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "homepage": "https://github.com/dashevo/dashpay-contract#readme",
27
27
  "devDependencies": {
28
- "@dashevo/wasm-dpp": "0.25.21",
28
+ "@dashevo/wasm-dpp": "1.0.0-beta.1",
29
29
  "chai": "^4.3.10",
30
30
  "dirty-chai": "^2.0.1",
31
31
  "eslint": "^8.53.0",
@@ -27,6 +27,7 @@
27
27
  "avatarUrl": {
28
28
  "type": "string",
29
29
  "format": "uri",
30
+ "minLength": 1,
30
31
  "maxLength": 2048,
31
32
  "position": 0
32
33
  },
@@ -48,15 +49,23 @@
48
49
  },
49
50
  "publicMessage": {
50
51
  "type": "string",
52
+ "minLength": 1,
51
53
  "maxLength": 140,
52
54
  "position": 3
53
55
  },
54
56
  "displayName": {
55
57
  "type": "string",
58
+ "minLength": 1,
56
59
  "maxLength": 25,
57
60
  "position": 4
58
61
  }
59
62
  },
63
+ "minProperties": 1,
64
+ "dependentRequired": {
65
+ "avatarUrl": ["avatarHash", "avatarFingerprint"],
66
+ "avatarHash": ["avatarUrl", "avatarFingerprint"],
67
+ "avatarFingerprint": ["avatarUrl", "avatarHash"]
68
+ },
60
69
  "required": [
61
70
  "$createdAt",
62
71
  "$updatedAt"
@@ -131,6 +140,8 @@
131
140
  "additionalProperties": false
132
141
  },
133
142
  "contactRequest": {
143
+ "documentsMutable": false,
144
+ "canBeDeleted": false,
134
145
  "requiresIdentityEncryptionBoundedKey": 2,
135
146
  "requiresIdentityDecryptionBoundedKey": 2,
136
147
  "type": "object",
@@ -228,15 +239,11 @@
228
239
  "minItems": 38,
229
240
  "maxItems": 102,
230
241
  "position": 6
231
- },
232
- "coreHeightCreatedAt": {
233
- "type": "integer",
234
- "minimum": 1,
235
- "position": 7
236
242
  }
237
243
  },
238
244
  "required": [
239
245
  "$createdAt",
246
+ "$createdAtCoreBlockHeight",
240
247
  "toUserId",
241
248
  "encryptedPublicKey",
242
249
  "senderKeyIndex",
package/src/error.rs ADDED
@@ -0,0 +1,17 @@
1
+ use platform_version::version::FeatureVersion;
2
+
3
+ #[derive(thiserror::Error, Debug)]
4
+ pub enum Error {
5
+ /// Platform expected some specific versions
6
+ #[error("platform unknown version on {method}, received: {received}")]
7
+ UnknownVersionMismatch {
8
+ /// method
9
+ method: String,
10
+ /// the allowed versions for this method
11
+ known_versions: Vec<FeatureVersion>,
12
+ /// requested core height
13
+ received: FeatureVersion,
14
+ },
15
+ #[error("schema deserialize error: {0}")]
16
+ InvalidSchemaJson(#[from] serde_json::Error),
17
+ }
package/src/lib.rs CHANGED
@@ -1,5 +1,9 @@
1
+ mod error;
2
+ pub mod v1;
3
+
4
+ pub use crate::error::Error;
1
5
  use platform_value::{Identifier, IdentifierBytes32};
2
- use serde_json::Error;
6
+ use platform_version::version::PlatformVersion;
3
7
  use serde_json::Value;
4
8
 
5
9
  pub const ID_BYTES: [u8; 32] = [
@@ -12,21 +16,26 @@ pub const OWNER_ID_BYTES: [u8; 32] = [
12
16
  215, 90, 101, 229, 15, 115, 5, 44, 117, 182, 217,
13
17
  ];
14
18
 
15
- pub mod document_types {
16
- pub mod contact_request {
17
- pub const NAME: &str = "contactRequest";
18
-
19
- pub mod properties {
20
- pub const TO_USER_ID: &str = "toUserId";
21
- pub const CORE_HEIGHT_CREATED_AT: &str = "coreHeightCreatedAt";
22
- pub const CORE_CHAIN_LOCKED_HEIGHT: &str = "coreChainLockedHeight";
23
- }
24
- }
25
- }
26
-
27
19
  pub const ID: Identifier = Identifier(IdentifierBytes32(ID_BYTES));
28
20
  pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
29
21
 
30
- pub fn load_documents_schemas() -> Result<Value, Error> {
31
- serde_json::from_str(include_str!("../schema/dashpay.schema.json"))
22
+ pub fn load_definitions(platform_version: &PlatformVersion) -> Result<Option<Value>, Error> {
23
+ match platform_version.system_data_contracts.dashpay {
24
+ 1 => Ok(None),
25
+ version => Err(Error::UnknownVersionMismatch {
26
+ method: "dashpay_contract::load_definitions".to_string(),
27
+ known_versions: vec![1],
28
+ received: version,
29
+ }),
30
+ }
31
+ }
32
+ pub fn load_documents_schemas(platform_version: &PlatformVersion) -> Result<Value, Error> {
33
+ match platform_version.system_data_contracts.dashpay {
34
+ 1 => v1::load_documents_schemas(),
35
+ version => Err(Error::UnknownVersionMismatch {
36
+ method: "dashpay_contract::load_documents_schemas".to_string(),
37
+ known_versions: vec![1],
38
+ received: version,
39
+ }),
40
+ }
32
41
  }
package/src/v1/mod.rs ADDED
@@ -0,0 +1,17 @@
1
+ use crate::error::Error;
2
+ use serde_json::Value;
3
+
4
+ pub mod document_types {
5
+ pub mod contact_request {
6
+ pub const NAME: &str = "contactRequest";
7
+
8
+ pub mod properties {
9
+ pub const TO_USER_ID: &str = "toUserId";
10
+ }
11
+ }
12
+ }
13
+
14
+ pub fn load_documents_schemas() -> Result<Value, Error> {
15
+ serde_json::from_str(include_str!("../../schema/v1/dashpay.schema.json"))
16
+ .map_err(Error::InvalidSchemaJson)
17
+ }
@@ -1,19 +1,28 @@
1
1
  const { expect } = require('chai');
2
2
  const crypto = require('crypto');
3
- const { DashPlatformProtocol, JsonSchemaError } = require('@dashevo/wasm-dpp');
3
+ const {
4
+ DashPlatformProtocol,
5
+ JsonSchemaError,
6
+ } = require('@dashevo/wasm-dpp');
4
7
  const generateRandomIdentifier = require('@dashevo/wasm-dpp/lib/test/utils/generateRandomIdentifierAsync');
5
- const schema = require('../../schema/dashpay.schema.json');
8
+ const schema = require('../../schema/v1/dashpay.schema.json');
6
9
 
7
10
  const whitepaperMasternodeText = 'Full nodes are servers running on a P2P network that allow peers to use them to receive updates about the events on the network. These nodes utilize significant amounts of traffic and other resources that incur a substantial cost. As a result, a steady decrease in the amount of these nodes has been observed for some time on the Bitcoin network and as a result, block propagation times have been upwards of 40 seconds. Many solutions have been proposed such as a new reward scheme by Microsoft Research and the Bitnodes incentive program';
8
11
  const encoded32Chars = '4fafc98bbfe597f7ba2c9f767d52036d';
9
12
  const encoded64Chars = '4fafc98bbfe597f7ba2c9f767d52036d2226175960a908e355e5c575711eb166';
10
13
 
11
- const expectJsonSchemaError = (validationResult) => {
14
+ const expectJsonSchemaError = (validationResult, count = 1, index = 0) => {
12
15
  const errors = validationResult.getErrors();
13
- expect(errors).to.have.length(1);
16
+ expect(errors)
17
+ .to
18
+ .have
19
+ .length(count);
14
20
 
15
- const error = validationResult.getErrors()[0];
16
- expect(error).to.be.instanceof(JsonSchemaError);
21
+ const error = validationResult.getErrors()[index];
22
+ expect(error)
23
+ .to
24
+ .be
25
+ .instanceof(JsonSchemaError);
17
26
 
18
27
  return error;
19
28
  };
@@ -29,11 +38,14 @@ describe('Dashpay Contract', () => {
29
38
  );
30
39
 
31
40
  identityId = await generateRandomIdentifier();
32
- contract = dpp.dataContract.create(identityId, schema);
41
+ contract = dpp.dataContract.create(identityId, BigInt(1), schema);
33
42
  });
34
43
 
35
44
  it('should have a valid contract definition', async () => {
36
- expect(() => dpp.dataContract.create(identityId, schema)).to.not.throw();
45
+ expect(() => dpp.dataContract.create(identityId, BigInt(1), schema))
46
+ .to
47
+ .not
48
+ .throw();
37
49
  });
38
50
 
39
51
  describe('Documents', () => {
@@ -43,7 +55,6 @@ describe('Dashpay Contract', () => {
43
55
  beforeEach(() => {
44
56
  profileData = {
45
57
  displayName: 'Bob',
46
- publicMessage: 'Hello Dashpay!',
47
58
  };
48
59
  });
49
60
 
@@ -55,8 +66,13 @@ describe('Dashpay Contract', () => {
55
66
  const validationResult = document.validate(dpp.protocolVersion);
56
67
  const error = expectJsonSchemaError(validationResult);
57
68
 
58
- expect(error.keyword).to.equal('maxLength');
59
- expect(error.instancePath).to.deep.equal('/displayName');
69
+ expect(error.keyword)
70
+ .to
71
+ .equal('maxLength');
72
+ expect(error.instancePath)
73
+ .to
74
+ .deep
75
+ .equal('/displayName');
60
76
  });
61
77
  });
62
78
 
@@ -68,113 +84,286 @@ describe('Dashpay Contract', () => {
68
84
  const validationResult = document.validate(dpp.protocolVersion);
69
85
  const error = expectJsonSchemaError(validationResult);
70
86
 
71
- expect(error.keyword).to.equal('maxLength');
72
- expect(error.instancePath).to.deep.equal('/publicMessage');
87
+ expect(error.keyword)
88
+ .to
89
+ .equal('maxLength');
90
+ expect(error.instancePath)
91
+ .to
92
+ .deep
93
+ .equal('/publicMessage');
73
94
  });
74
95
  });
75
96
 
76
97
  describe('avatarUrl', () => {
77
98
  it('should not be empty', async () => {
78
- profileData.avatarUrl = '';
99
+ profileData = {
100
+ avatarUrl: '',
101
+ avatarHash: Buffer.alloc(32),
102
+ avatarFingerprint: Buffer.alloc(8),
103
+ };
79
104
 
80
105
  const document = dpp.document.create(contract, identityId, 'profile', profileData);
81
106
  const validationResult = document.validate(dpp.protocolVersion);
82
- const error = expectJsonSchemaError(validationResult);
107
+ const error = expectJsonSchemaError(validationResult, 2);
83
108
 
84
- expect(error.keyword).to.equal('format');
85
- expect(error.instancePath).to.deep.equal('/avatarUrl');
109
+ expect(error.keyword)
110
+ .to
111
+ .equal('format');
112
+ expect(error.instancePath)
113
+ .to
114
+ .deep
115
+ .equal('/avatarUrl');
86
116
  });
87
117
 
88
118
  it('should have less than 2048 chars length', async () => {
89
- profileData.avatarUrl = `https://github.com/dashpay/dash/wiki/Whitepaper?text=${encodeURI(whitepaperMasternodeText)}${encodeURI(whitepaperMasternodeText)}${encodeURI(whitepaperMasternodeText)}${encodeURI(whitepaperMasternodeText)}${encodeURI(whitepaperMasternodeText)}`;
119
+ profileData = {
120
+ avatarUrl: `https://github.com/dashpay/dash/wiki/Whitepaper?text=${encodeURI(whitepaperMasternodeText)}${encodeURI(whitepaperMasternodeText)}${encodeURI(whitepaperMasternodeText)}${encodeURI(whitepaperMasternodeText)}${encodeURI(whitepaperMasternodeText)}`,
121
+ avatarHash: Buffer.alloc(32),
122
+ avatarFingerprint: Buffer.alloc(8),
123
+ };
90
124
 
91
125
  const document = dpp.document.create(contract, identityId, 'profile', profileData);
92
126
  const validationResult = document.validate(dpp.protocolVersion);
93
127
  const error = expectJsonSchemaError(validationResult);
94
128
 
95
- expect(error.keyword).to.equal('maxLength');
96
- expect(error.instancePath).to.deep.equal('/avatarUrl');
129
+ expect(error.keyword)
130
+ .to
131
+ .equal('maxLength');
132
+ expect(error.instancePath)
133
+ .to
134
+ .deep
135
+ .equal('/avatarUrl');
97
136
  });
98
137
 
99
138
  it('should be of type URL', async () => {
100
- profileData.avatarUrl = 'notAUrl';
139
+ profileData = {
140
+ avatarUrl: 'notAUrl',
141
+ avatarHash: Buffer.alloc(32),
142
+ avatarFingerprint: Buffer.alloc(8),
143
+ };
101
144
 
102
145
  const document = dpp.document.create(contract, identityId, 'profile', profileData);
103
146
  const validationResult = document.validate(dpp.protocolVersion);
104
147
  const error = expectJsonSchemaError(validationResult);
105
148
 
106
- expect(error.keyword).to.equal('format');
107
- expect(error.instancePath).to.deep.equal('/avatarUrl');
149
+ expect(error.keyword)
150
+ .to
151
+ .equal('format');
152
+ expect(error.instancePath)
153
+ .to
154
+ .deep
155
+ .equal('/avatarUrl');
156
+ });
157
+
158
+ it('should be present if other avatar properties are present', async () => {
159
+ profileData = {
160
+ avatarHash: Buffer.alloc(32),
161
+ avatarFingerprint: Buffer.alloc(8),
162
+ };
163
+
164
+ const document = dpp.document.create(contract, identityId, 'profile', profileData);
165
+ const validationResult = document.validate(dpp.protocolVersion);
166
+ let error = expectJsonSchemaError(validationResult, 2, 0);
167
+
168
+ expect(error.keyword)
169
+ .to
170
+ .equal('required');
171
+ expect(error.params)
172
+ .to
173
+ .deep
174
+ .equal({ missingProperty: 'avatarUrl' });
175
+
176
+ error = expectJsonSchemaError(validationResult, 2, 1);
177
+
178
+ expect(error.keyword)
179
+ .to
180
+ .equal('required');
181
+ expect(error.params)
182
+ .to
183
+ .deep
184
+ .equal({ missingProperty: 'avatarUrl' });
108
185
  });
109
186
  });
110
187
 
111
188
  describe('avatarHash', () => {
112
189
  it('should have minimum length of 32', async () => {
113
- profileData.avatarHash = Buffer.alloc(0);
190
+ profileData = {
191
+ avatarUrl: 'https://github.com/dashpay/dash.jpg',
192
+ avatarHash: Buffer.alloc(0),
193
+ avatarFingerprint: Buffer.alloc(8),
194
+ };
114
195
 
115
196
  const document = dpp.document.create(contract, identityId, 'profile', profileData);
116
197
  const validationResult = document.validate(dpp.protocolVersion);
117
198
  const error = expectJsonSchemaError(validationResult);
118
199
 
119
- expect(error.keyword).to.equal('minItems');
120
- expect(error.instancePath).to.deep.equal('/avatarHash');
200
+ expect(error.keyword)
201
+ .to
202
+ .equal('minItems');
203
+ expect(error.instancePath)
204
+ .to
205
+ .deep
206
+ .equal('/avatarHash');
121
207
  });
122
208
 
123
209
  it('should have maximum length of 32', async () => {
124
- profileData.avatarHash = Buffer.alloc(33);
210
+ profileData = {
211
+ avatarUrl: 'https://github.com/dashpay/dash.jpg',
212
+ avatarHash: Buffer.alloc(33),
213
+ avatarFingerprint: Buffer.alloc(8),
214
+ };
125
215
 
126
216
  const document = dpp.document.create(contract, identityId, 'profile', profileData);
127
217
  const validationResult = document.validate(dpp.protocolVersion);
128
218
  const error = expectJsonSchemaError(validationResult);
129
219
 
130
- expect(error.keyword).to.equal('maxItems');
131
- expect(error.instancePath).to.deep.equal('/avatarHash');
220
+ expect(error.keyword)
221
+ .to
222
+ .equal('maxItems');
223
+ expect(error.instancePath)
224
+ .to
225
+ .deep
226
+ .equal('/avatarHash');
132
227
  });
133
228
 
134
229
  it('should be of type array', async () => {
135
- profileData.avatarHash = 'notAnArray';
230
+ profileData = {
231
+ avatarUrl: 'https://github.com/dashpay/dash.jpg',
232
+ avatarHash: 'notAnArray',
233
+ avatarFingerprint: Buffer.alloc(8),
234
+ };
136
235
 
137
236
  const document = dpp.document.create(contract, identityId, 'profile', profileData);
138
237
  const validationResult = document.validate(dpp.protocolVersion);
139
- const error = expectJsonSchemaError(validationResult);
238
+ const error = expectJsonSchemaError(validationResult, 2);
239
+
240
+ expect(error.keyword)
241
+ .to
242
+ .equal('type');
243
+ expect(error.instancePath)
244
+ .to
245
+ .deep
246
+ .equal('/avatarHash');
247
+ });
248
+
249
+ it('should be present if other avatar properties are present', async () => {
250
+ profileData = {
251
+ avatarUrl: 'https://github.com/dashpay/dash.jpg',
252
+ avatarFingerprint: Buffer.alloc(8),
253
+ };
254
+
255
+ const document = dpp.document.create(contract, identityId, 'profile', profileData);
256
+ const validationResult = document.validate(dpp.protocolVersion);
257
+ let error = expectJsonSchemaError(validationResult, 2, 0);
258
+
259
+ expect(error.keyword)
260
+ .to
261
+ .equal('required');
262
+ expect(error.params)
263
+ .to
264
+ .deep
265
+ .equal({ missingProperty: 'avatarHash' });
140
266
 
141
- expect(error.keyword).to.equal('type');
142
- expect(error.instancePath).to.deep.equal('/avatarHash');
267
+ error = expectJsonSchemaError(validationResult, 2, 1);
268
+
269
+ expect(error.keyword)
270
+ .to
271
+ .equal('required');
272
+ expect(error.params)
273
+ .to
274
+ .deep
275
+ .equal({ missingProperty: 'avatarHash' });
143
276
  });
144
277
  });
145
278
 
146
279
  describe('avatarFingerprint', () => {
147
280
  it('should have minimum length of 8', async () => {
148
- profileData.avatarFingerprint = Buffer.alloc(0);
281
+ profileData = {
282
+ avatarUrl: 'https://github.com/dashpay/dash.jpg',
283
+ avatarHash: Buffer.alloc(32),
284
+ avatarFingerprint: Buffer.alloc(0),
285
+ };
149
286
 
150
287
  const document = dpp.document.create(contract, identityId, 'profile', profileData);
151
288
  const validationResult = document.validate(dpp.protocolVersion);
152
289
  const error = expectJsonSchemaError(validationResult);
153
290
 
154
- expect(error.keyword).to.equal('minItems');
155
- expect(error.instancePath).to.deep.equal('/avatarFingerprint');
291
+ expect(error.keyword)
292
+ .to
293
+ .equal('minItems');
294
+ expect(error.instancePath)
295
+ .to
296
+ .deep
297
+ .equal('/avatarFingerprint');
156
298
  });
157
299
 
158
300
  it('should have maximum length of 8', async () => {
159
- profileData.avatarFingerprint = Buffer.alloc(33);
301
+ profileData = {
302
+ avatarUrl: 'https://github.com/dashpay/dash.jpg',
303
+ avatarHash: Buffer.alloc(32),
304
+ avatarFingerprint: Buffer.alloc(33),
305
+ };
160
306
 
161
307
  const document = dpp.document.create(contract, identityId, 'profile', profileData);
162
308
  const validationResult = document.validate(dpp.protocolVersion);
163
309
  const error = expectJsonSchemaError(validationResult);
164
310
 
165
- expect(error.keyword).to.equal('maxItems');
166
- expect(error.instancePath).to.deep.equal('/avatarFingerprint');
311
+ expect(error.keyword)
312
+ .to
313
+ .equal('maxItems');
314
+ expect(error.instancePath)
315
+ .to
316
+ .deep
317
+ .equal('/avatarFingerprint');
167
318
  });
168
319
 
169
320
  it('should be of type array', async () => {
170
- profileData.avatarFingerprint = 'notAnArray';
321
+ profileData = {
322
+ avatarUrl: 'https://github.com/dashpay/dash.jpg',
323
+ avatarHash: Buffer.alloc(32),
324
+ avatarFingerprint: 'notAnArray',
325
+ };
171
326
 
172
327
  const document = dpp.document.create(contract, identityId, 'profile', profileData);
173
328
  const validationResult = document.validate(dpp.protocolVersion);
174
- const error = expectJsonSchemaError(validationResult);
329
+ const error = expectJsonSchemaError(validationResult, 2);
175
330
 
176
- expect(error.keyword).to.equal('type');
177
- expect(error.instancePath).to.deep.equal('/avatarFingerprint');
331
+ expect(error.keyword)
332
+ .to
333
+ .equal('type');
334
+ expect(error.instancePath)
335
+ .to
336
+ .deep
337
+ .equal('/avatarFingerprint');
338
+ });
339
+
340
+ it('should be present if other avatar properties are present', async () => {
341
+ profileData = {
342
+ avatarUrl: 'https://github.com/dashpay/dash.jpg',
343
+ avatarHash: Buffer.alloc(32),
344
+ };
345
+
346
+ const document = dpp.document.create(contract, identityId, 'profile', profileData);
347
+ const validationResult = document.validate(dpp.protocolVersion);
348
+ let error = expectJsonSchemaError(validationResult, 2, 0);
349
+
350
+ expect(error.keyword)
351
+ .to
352
+ .equal('required');
353
+ expect(error.params)
354
+ .to
355
+ .deep
356
+ .equal({ missingProperty: 'avatarFingerprint' });
357
+
358
+ error = expectJsonSchemaError(validationResult, 2, 1);
359
+
360
+ expect(error.keyword)
361
+ .to
362
+ .equal('required');
363
+ expect(error.params)
364
+ .to
365
+ .deep
366
+ .equal({ missingProperty: 'avatarFingerprint' });
178
367
  });
179
368
  });
180
369
 
@@ -185,8 +374,25 @@ describe('Dashpay Contract', () => {
185
374
  const validationResult = document.validate(dpp.protocolVersion);
186
375
  const error = expectJsonSchemaError(validationResult);
187
376
 
188
- expect(error.keyword).to.equal('additionalProperties');
189
- expect(error.params.additionalProperties).to.deep.equal(['someOtherProperty']);
377
+ expect(error.keyword)
378
+ .to
379
+ .equal('additionalProperties');
380
+ expect(error.params.additionalProperties)
381
+ .to
382
+ .deep
383
+ .equal(['someOtherProperty']);
384
+ });
385
+
386
+ it('at least one of avatarUrl, publicMessage or displayName should be present', async () => {
387
+ const profile = dpp.document.create(contract, identityId, 'profile', { });
388
+
389
+ const result = profile.validate(dpp.protocolVersion);
390
+
391
+ const error = expectJsonSchemaError(result);
392
+
393
+ expect(error.keyword)
394
+ .to
395
+ .equal('minProperties');
190
396
  });
191
397
 
192
398
  it('should be valid', async () => {
@@ -194,7 +400,10 @@ describe('Dashpay Contract', () => {
194
400
 
195
401
  const result = profile.validate(dpp.protocolVersion);
196
402
 
197
- expect(result.isValid()).to.be.true();
403
+ expect(result.isValid())
404
+ .to
405
+ .be
406
+ .true();
198
407
  });
199
408
  });
200
409
 
@@ -218,8 +427,12 @@ describe('Dashpay Contract', () => {
218
427
  const validationResult = document.validate(dpp.protocolVersion);
219
428
  const error = expectJsonSchemaError(validationResult);
220
429
 
221
- expect(error.keyword).to.equal('required');
222
- expect(error.params.missingProperty).to.equal('encToUserId');
430
+ expect(error.keyword)
431
+ .to
432
+ .equal('required');
433
+ expect(error.params.missingProperty)
434
+ .to
435
+ .equal('encToUserId');
223
436
  });
224
437
 
225
438
  it('should have exactly 32 chars length', async () => {
@@ -229,8 +442,12 @@ describe('Dashpay Contract', () => {
229
442
  const validationResult = document.validate(dpp.protocolVersion);
230
443
  const error = expectJsonSchemaError(validationResult);
231
444
 
232
- expect(error.keyword).to.equal('maxItems');
233
- expect(error.instancePath).to.equal('/encToUserId');
445
+ expect(error.keyword)
446
+ .to
447
+ .equal('maxItems');
448
+ expect(error.instancePath)
449
+ .to
450
+ .equal('/encToUserId');
234
451
  });
235
452
 
236
453
  it('should have more or 32 chars length', async () => {
@@ -240,8 +457,12 @@ describe('Dashpay Contract', () => {
240
457
  const validationResult = document.validate(dpp.protocolVersion);
241
458
  const error = expectJsonSchemaError(validationResult);
242
459
 
243
- expect(error.keyword).to.equal('minItems');
244
- expect(error.instancePath).to.equal('/encToUserId');
460
+ expect(error.keyword)
461
+ .to
462
+ .equal('minItems');
463
+ expect(error.instancePath)
464
+ .to
465
+ .equal('/encToUserId');
245
466
  });
246
467
  });
247
468
 
@@ -253,8 +474,12 @@ describe('Dashpay Contract', () => {
253
474
  const validationResult = document.validate(dpp.protocolVersion);
254
475
  const error = expectJsonSchemaError(validationResult);
255
476
 
256
- expect(error.keyword).to.equal('required');
257
- expect(error.params.missingProperty).to.equal('rootEncryptionKeyIndex');
477
+ expect(error.keyword)
478
+ .to
479
+ .equal('required');
480
+ expect(error.params.missingProperty)
481
+ .to
482
+ .equal('rootEncryptionKeyIndex');
258
483
  });
259
484
 
260
485
  it('should not be less than 0', async () => {
@@ -264,8 +489,12 @@ describe('Dashpay Contract', () => {
264
489
  const validationResult = document.validate(dpp.protocolVersion);
265
490
  const error = expectJsonSchemaError(validationResult);
266
491
 
267
- expect(error.keyword).to.equal('minimum');
268
- expect(error.instancePath).to.equal('/rootEncryptionKeyIndex');
492
+ expect(error.keyword)
493
+ .to
494
+ .equal('minimum');
495
+ expect(error.instancePath)
496
+ .to
497
+ .equal('/rootEncryptionKeyIndex');
269
498
  });
270
499
  });
271
500
 
@@ -277,8 +506,12 @@ describe('Dashpay Contract', () => {
277
506
  const validationResult = document.validate(dpp.protocolVersion);
278
507
  const error = expectJsonSchemaError(validationResult);
279
508
 
280
- expect(error.keyword).to.equal('required');
281
- expect(error.params.missingProperty).to.equal('privateData');
509
+ expect(error.keyword)
510
+ .to
511
+ .equal('required');
512
+ expect(error.params.missingProperty)
513
+ .to
514
+ .equal('privateData');
282
515
  });
283
516
  });
284
517
 
@@ -289,8 +522,13 @@ describe('Dashpay Contract', () => {
289
522
  const validationResult = document.validate(dpp.protocolVersion);
290
523
  const error = expectJsonSchemaError(validationResult);
291
524
 
292
- expect(error.keyword).to.equal('additionalProperties');
293
- expect(error.params.additionalProperties).to.deep.equal(['someOtherProperty']);
525
+ expect(error.keyword)
526
+ .to
527
+ .equal('additionalProperties');
528
+ expect(error.params.additionalProperties)
529
+ .to
530
+ .deep
531
+ .equal(['someOtherProperty']);
294
532
  });
295
533
  });
296
534
 
@@ -315,8 +553,12 @@ describe('Dashpay Contract', () => {
315
553
  const validationResult = document.validate(dpp.protocolVersion);
316
554
  const error = expectJsonSchemaError(validationResult);
317
555
 
318
- expect(error.keyword).to.equal('required');
319
- expect(error.params.missingProperty).to.equal('toUserId');
556
+ expect(error.keyword)
557
+ .to
558
+ .equal('required');
559
+ expect(error.params.missingProperty)
560
+ .to
561
+ .equal('toUserId');
320
562
  });
321
563
  });
322
564
 
@@ -328,8 +570,12 @@ describe('Dashpay Contract', () => {
328
570
  const validationResult = document.validate(dpp.protocolVersion);
329
571
  const error = expectJsonSchemaError(validationResult);
330
572
 
331
- expect(error.keyword).to.equal('required');
332
- expect(error.params.missingProperty).to.equal('encryptedPublicKey');
573
+ expect(error.keyword)
574
+ .to
575
+ .equal('required');
576
+ expect(error.params.missingProperty)
577
+ .to
578
+ .equal('encryptedPublicKey');
333
579
  });
334
580
  });
335
581
 
@@ -341,8 +587,12 @@ describe('Dashpay Contract', () => {
341
587
  const validationResult = document.validate(dpp.protocolVersion);
342
588
  const error = expectJsonSchemaError(validationResult);
343
589
 
344
- expect(error.keyword).to.equal('required');
345
- expect(error.params.missingProperty).to.equal('senderKeyIndex');
590
+ expect(error.keyword)
591
+ .to
592
+ .equal('required');
593
+ expect(error.params.missingProperty)
594
+ .to
595
+ .equal('senderKeyIndex');
346
596
  });
347
597
 
348
598
  it('should not be less than 0', async () => {
@@ -352,8 +602,12 @@ describe('Dashpay Contract', () => {
352
602
  const validationResult = document.validate(dpp.protocolVersion);
353
603
  const error = expectJsonSchemaError(validationResult);
354
604
 
355
- expect(error.keyword).to.equal('minimum');
356
- expect(error.instancePath).to.equal('/senderKeyIndex');
605
+ expect(error.keyword)
606
+ .to
607
+ .equal('minimum');
608
+ expect(error.instancePath)
609
+ .to
610
+ .equal('/senderKeyIndex');
357
611
  });
358
612
  });
359
613
 
@@ -365,8 +619,12 @@ describe('Dashpay Contract', () => {
365
619
  const validationResult = document.validate(dpp.protocolVersion);
366
620
  const error = expectJsonSchemaError(validationResult);
367
621
 
368
- expect(error.keyword).to.equal('required');
369
- expect(error.params.missingProperty).to.equal('recipientKeyIndex');
622
+ expect(error.keyword)
623
+ .to
624
+ .equal('required');
625
+ expect(error.params.missingProperty)
626
+ .to
627
+ .equal('recipientKeyIndex');
370
628
  });
371
629
 
372
630
  it('should not be less than 0', async () => {
@@ -376,8 +634,12 @@ describe('Dashpay Contract', () => {
376
634
  const validationResult = document.validate(dpp.protocolVersion);
377
635
  const error = expectJsonSchemaError(validationResult);
378
636
 
379
- expect(error.keyword).to.equal('minimum');
380
- expect(error.instancePath).to.equal('/recipientKeyIndex');
637
+ expect(error.keyword)
638
+ .to
639
+ .equal('minimum');
640
+ expect(error.instancePath)
641
+ .to
642
+ .equal('/recipientKeyIndex');
381
643
  });
382
644
  });
383
645
 
@@ -389,8 +651,13 @@ describe('Dashpay Contract', () => {
389
651
  const validationResult = document.validate(dpp.protocolVersion);
390
652
  const error = expectJsonSchemaError(validationResult);
391
653
 
392
- expect(error.keyword).to.equal('minItems');
393
- expect(error.instancePath).to.deep.equal('/encryptedAccountLabel');
654
+ expect(error.keyword)
655
+ .to
656
+ .equal('minItems');
657
+ expect(error.instancePath)
658
+ .to
659
+ .deep
660
+ .equal('/encryptedAccountLabel');
394
661
  });
395
662
 
396
663
  it('should have maximum length of 80', async () => {
@@ -400,8 +667,13 @@ describe('Dashpay Contract', () => {
400
667
  const validationResult = document.validate(dpp.protocolVersion);
401
668
  const error = expectJsonSchemaError(validationResult);
402
669
 
403
- expect(error.keyword).to.equal('maxItems');
404
- expect(error.instancePath).to.deep.equal('/encryptedAccountLabel');
670
+ expect(error.keyword)
671
+ .to
672
+ .equal('maxItems');
673
+ expect(error.instancePath)
674
+ .to
675
+ .deep
676
+ .equal('/encryptedAccountLabel');
405
677
  });
406
678
 
407
679
  it('should be of type array', async () => {
@@ -409,10 +681,15 @@ describe('Dashpay Contract', () => {
409
681
 
410
682
  const document = dpp.document.create(contract, identityId, 'contactRequest', contactRequestData);
411
683
  const validationResult = document.validate(dpp.protocolVersion);
412
- const error = expectJsonSchemaError(validationResult);
684
+ const error = expectJsonSchemaError(validationResult, 2);
413
685
 
414
- expect(error.keyword).to.equal('type');
415
- expect(error.instancePath).to.deep.equal('/encryptedAccountLabel');
686
+ expect(error.keyword)
687
+ .to
688
+ .equal('type');
689
+ expect(error.instancePath)
690
+ .to
691
+ .deep
692
+ .equal('/encryptedAccountLabel');
416
693
  });
417
694
  });
418
695
 
@@ -424,8 +701,13 @@ describe('Dashpay Contract', () => {
424
701
  const validationResult = document.validate(dpp.protocolVersion);
425
702
  const error = expectJsonSchemaError(validationResult);
426
703
 
427
- expect(error.keyword).to.equal('minItems');
428
- expect(error.instancePath).to.deep.equal('/autoAcceptProof');
704
+ expect(error.keyword)
705
+ .to
706
+ .equal('minItems');
707
+ expect(error.instancePath)
708
+ .to
709
+ .deep
710
+ .equal('/autoAcceptProof');
429
711
  });
430
712
 
431
713
  it('should have maximum length of 102', async () => {
@@ -435,8 +717,13 @@ describe('Dashpay Contract', () => {
435
717
  const validationResult = document.validate(dpp.protocolVersion);
436
718
  const error = expectJsonSchemaError(validationResult);
437
719
 
438
- expect(error.keyword).to.equal('maxItems');
439
- expect(error.instancePath).to.deep.equal('/autoAcceptProof');
720
+ expect(error.keyword)
721
+ .to
722
+ .equal('maxItems');
723
+ expect(error.instancePath)
724
+ .to
725
+ .deep
726
+ .equal('/autoAcceptProof');
440
727
  });
441
728
 
442
729
  it('should be of type array', async () => {
@@ -444,10 +731,15 @@ describe('Dashpay Contract', () => {
444
731
 
445
732
  const document = dpp.document.create(contract, identityId, 'contactRequest', contactRequestData);
446
733
  const validationResult = document.validate(dpp.protocolVersion);
447
- const error = expectJsonSchemaError(validationResult);
734
+ const error = expectJsonSchemaError(validationResult, 2);
448
735
 
449
- expect(error.keyword).to.equal('type');
450
- expect(error.instancePath).to.deep.equal('/autoAcceptProof');
736
+ expect(error.keyword)
737
+ .to
738
+ .equal('type');
739
+ expect(error.instancePath)
740
+ .to
741
+ .deep
742
+ .equal('/autoAcceptProof');
451
743
  });
452
744
  });
453
745
 
@@ -459,8 +751,12 @@ describe('Dashpay Contract', () => {
459
751
  const validationResult = document.validate(dpp.protocolVersion);
460
752
  const error = expectJsonSchemaError(validationResult);
461
753
 
462
- expect(error.keyword).to.equal('required');
463
- expect(error.params.missingProperty).to.equal('accountReference');
754
+ expect(error.keyword)
755
+ .to
756
+ .equal('required');
757
+ expect(error.params.missingProperty)
758
+ .to
759
+ .equal('accountReference');
464
760
  });
465
761
 
466
762
  it('should not be less than 0', async () => {
@@ -470,21 +766,12 @@ describe('Dashpay Contract', () => {
470
766
  const validationResult = document.validate(dpp.protocolVersion);
471
767
  const error = expectJsonSchemaError(validationResult);
472
768
 
473
- expect(error.keyword).to.equal('minimum');
474
- expect(error.instancePath).to.equal('/accountReference');
475
- });
476
- });
477
-
478
- describe('coreHeightCreatedAt', () => {
479
- it('should not be less than 1', async () => {
480
- contactRequestData.coreHeightCreatedAt = -1;
481
-
482
- const document = dpp.document.create(contract, identityId, 'contactRequest', contactRequestData);
483
- const validationResult = document.validate(dpp.protocolVersion);
484
- const error = expectJsonSchemaError(validationResult);
485
-
486
- expect(error.keyword).to.equal('minimum');
487
- expect(error.instancePath).to.equal('/coreHeightCreatedAt');
769
+ expect(error.keyword)
770
+ .to
771
+ .equal('minimum');
772
+ expect(error.instancePath)
773
+ .to
774
+ .equal('/accountReference');
488
775
  });
489
776
  });
490
777
 
@@ -495,8 +782,13 @@ describe('Dashpay Contract', () => {
495
782
  const validationResult = document.validate(dpp.protocolVersion);
496
783
  const error = expectJsonSchemaError(validationResult);
497
784
 
498
- expect(error.keyword).to.equal('additionalProperties');
499
- expect(error.params.additionalProperties).to.deep.equal(['someOtherProperty']);
785
+ expect(error.keyword)
786
+ .to
787
+ .equal('additionalProperties');
788
+ expect(error.params.additionalProperties)
789
+ .to
790
+ .deep
791
+ .equal(['someOtherProperty']);
500
792
  });
501
793
  });
502
794
  });