@dashevo/wasm-dpp 0.25.6 → 0.25.9

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.
Files changed (95) hide show
  1. package/Cargo.toml +3 -2
  2. package/README.md +1 -1
  3. package/dist/wasm/wasm_dpp.d.ts +808 -712
  4. package/dist/wasm/wasm_dpp.js +853 -452
  5. package/dist/wasm/wasm_dpp_bg.js +1 -1
  6. package/lib/bls/bls.js +48 -0
  7. package/lib/test/fixtures/getChainAssetLockProofFixture.js +20 -1
  8. package/lib/test/fixtures/getDataContractFixture.js +4 -6
  9. package/lib/test/fixtures/getDocumentTransitionsFixture.js +31 -1
  10. package/lib/test/fixtures/getInstantAssetLockProofFixture.js +32 -12
  11. package/lib/test/mocks/getBlsAdapterMock.js +1 -1
  12. package/lib/utils/creditsConverter.js +14 -0
  13. package/lib/utils/hash.js +18 -0
  14. package/lib/wasm/wasm_dpp.d.ts +808 -712
  15. package/package.json +3 -5
  16. package/src/dash_platform_protocol.rs +5 -5
  17. package/src/document/errors/invalid_document_error.rs +5 -0
  18. package/src/document/extended_document.rs +15 -0
  19. package/src/document/state_transition/document_batch_transition/document_transition/document_create_transition.rs +219 -214
  20. package/src/document/state_transition/document_batch_transition/document_transition/mod.rs +1 -1
  21. package/src/errors/consensus/basic/identity/identity_insufficient_balance_error.rs +4 -2
  22. package/src/errors/consensus/basic/json_schema_error.rs +35 -5
  23. package/src/identity/identity_facade.rs +7 -5
  24. package/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs +32 -17
  25. package/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs +22 -13
  26. package/src/identity/state_transition/asset_lock_proof/mod.rs +12 -11
  27. package/src/identity/state_transition/identity_create_transition/identity_create_transition.rs +1 -0
  28. package/src/identity/state_transition/identity_create_transition/to_object.rs +1 -0
  29. package/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs +1 -0
  30. package/src/identity/state_transition/identity_topup_transition/to_object.rs +1 -0
  31. package/src/lib.rs +1 -1
  32. package/src/validation/mod.rs +2 -2
  33. package/src/validation/validation_result.rs +16 -15
  34. package/test/integration/document/DocumentFacade.spec.js +11 -27
  35. package/test/integration/document/stateTransition/DocumentsBatchTransition/DocumentBatchTransition.spec.js +9 -19
  36. package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/basic/validateDocumentsBatchTransitionBasicFactory.spec.js +2 -2
  37. package/test/integration/document/validation/validateDocumentFactory.spec.js +2 -2
  38. package/test/integration/identity/IdentityFacade.spec.js +1 -2
  39. package/test/integration/identity/stateTransition/assetLockProof/instant/validateInstantAssetLockProofStructureFactory.spec.js +2 -2
  40. package/test/integration/identity/stateTransition/validatePublicKeySignaturesFactory.spec.js +2 -2
  41. package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +6 -8
  42. package/test/unit/document/Document.spec.js +30 -52
  43. package/test/unit/document/DocumentFactory.spec.js +2 -2
  44. package/test/unit/document/errors/InvalidDocumentError.spec.js +9 -9
  45. package/test/unit/document/stateTransition/DocumetsBatchTransition/DocumentsBatchTransition.spec.js +158 -155
  46. package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/findDuplicatesByIndices.spec.js +132 -134
  47. package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/validatePartialCompoundIndices.spec.js +3 -3
  48. package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsBatchTransitionStateFactory.spec.js +568 -591
  49. package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsUniquenessByIndicesFactory.spec.js +5 -13
  50. package/test/unit/identity/Identity.spec.js +2 -2
  51. package/test/unit/identity/stateTransition/assetLockProof/ChainAssetLockProof.spec.js +9 -28
  52. package/test/unit/identity/stateTransition/assetLockProof/InstantAssetLockProof.spec.js +19 -27
  53. package/lib/test/fixtures/getDashPayContractFixture.js +0 -1
  54. package/lib/test/fixtures/getDashPayDocumentFixture.js +0 -1
  55. package/lib/test/fixtures/getDpnsContractFixture.js +0 -1
  56. package/lib/test/fixtures/getDpnsDocumentFixture.js +0 -1
  57. package/lib/test/fixtures/getFeatureFlagsContractFixture.js +0 -1
  58. package/lib/test/fixtures/getFeatureFlagsDocumentsFixture.js +0 -1
  59. package/lib/test/fixtures/getIdentityTopUpTransitionFixtureJs.js +0 -1
  60. package/lib/test/fixtures/getMasternodeRewardShareDocumentsFixture.js +0 -1
  61. package/lib/test/fixtures/getMasternodeRewardSharesContractFixture.js +0 -1
  62. package/lib/test/fixtures/getPreorderDocumentFixture.js +0 -1
  63. package/lib/test/fixtures/getRawTransactionFixture.js +0 -1
  64. package/lib/test/fixtures/js/generateRandomIdentifier.js +0 -1
  65. package/lib/test/fixtures/js/getChainAssetLockProofFixture.js +0 -1
  66. package/lib/test/fixtures/js/getDataContractFixture.js +0 -1
  67. package/lib/test/fixtures/js/getDocumentTransitionsFixture.js +0 -1
  68. package/lib/test/fixtures/js/getDocumentsFixture.js +0 -1
  69. package/lib/test/fixtures/js/getInstantAssetLockProofFixture.js +0 -1
  70. package/test/integration/DashPlatformProtocol.spec.js +0 -53
  71. package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/state/executeDataTriggersFactory.spec.js +0 -195
  72. package/test/integration/stateTransition/AbstractStateTransitionIdentitySigned.spec.js +0 -500
  73. package/test/integration/stateTransition/calculateStateTransitionFeeFromOperationsFactory.spec.js +0 -53
  74. package/test/unit/dataContract/getBinaryPropertiesFromSchema.spec.js +0 -103
  75. package/test/unit/dataContract/getPropertyDefinitionByPath.spec.js +0 -84
  76. package/test/unit/dataContract/stateTransition/DataContractCreateTransition/applyDataContractCreateTransitionFactory.spec.js +0 -45
  77. package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/applyDataContractUpdateTransitionFactory.spec.js +0 -49
  78. package/test/unit/dataTrigger/DataTrigger.spec.js +0 -132
  79. package/test/unit/dataTrigger/DataTriggerExecutionContext.spec.js +0 -29
  80. package/test/unit/dataTrigger/dashpayDataTriggers/createContactRequestDataTrigger.spec.js +0 -107
  81. package/test/unit/dataTrigger/dpnsTriggers/createDomainDataTrigger.spec.js +0 -382
  82. package/test/unit/dataTrigger/featureFlagDataTriggers/createFeatureFlagDataTrigger.spec.js +0 -99
  83. package/test/unit/dataTrigger/getDataTriggersFactory.spec.js +0 -113
  84. package/test/unit/dataTrigger/rejectDataTrigger.spec.js +0 -51
  85. package/test/unit/dataTrigger/rewardShareDataTriggers/createMasternodeRewardSharesDataTrigger.spec.js +0 -202
  86. package/test/unit/document/stateTransition/DocumetsBatchTransition/applyDocumentsBatchTransitionFactory.spec.js +0 -256
  87. package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/fetchDocumentsFactory.spec.js +0 -94
  88. package/test/unit/errors/consensus/codes.spec.js +0 -102
  89. package/test/unit/identity/creditsConverter.spec.js +0 -34
  90. package/test/unit/identity/stateTransition/IdentityCreateTransition/applyIdentityCreateTransitionFactory.spec.js +0 -83
  91. package/test/unit/identity/stateTransition/IdentityTopUpTransition/applyIdentityTopUpTransitionFactory.spec.js +0 -138
  92. package/test/unit/identity/stateTransition/IdentityUpdateTransition/applyIdentityUpdateTransitionFactory.spec.js +0 -100
  93. package/test/unit/identity/stateTransition/assetLockProof/createAssetLockProofInstance.spec.js +0 -36
  94. package/test/unit/identity/stateTransition/assetLockProof/fetchAssetLockPublicKeyHashFactory.spec.js +0 -63
  95. package/test/unit/identity/validation/validateRequiredPurposeAndSecurityLevelFactory.spec.js +0 -47
@@ -1,16 +1,7 @@
1
1
  const crypto = require('crypto');
2
- const JsDataContractFactory = require('@dashevo/dpp/lib/dataContract/DataContractFactory');
3
- const JsIdentifier = require('@dashevo/dpp/lib/identifier/Identifier');
4
- const JsDocument = require('@dashevo/dpp/lib/document/Document');
5
- const DocumentCreateTransition = require(
6
- '@dashevo/dpp/lib/document/stateTransition/DocumentsBatchTransition/documentTransition/DocumentCreateTransition',
7
- );
8
-
9
- const createDPPMock = require('@dashevo/dpp/lib/test/mocks/createDPPMock');
10
- const generateRandomIdentifier = require('@dashevo/dpp/lib/test/utils/generateRandomIdentifier');
11
2
 
12
3
  const generateRandomIdentifierAsync = require('../../../lib/test/utils/generateRandomIdentifierAsync');
13
- const { default: loadWasmDpp } = require('../../..');
4
+ const { default: loadWasmDpp, DocumentCreateTransition } = require('../../..');
14
5
  const { getLatestProtocolVersion } = require('../../..');
15
6
 
16
7
  let DataContractFactory;
@@ -24,8 +15,6 @@ describe('Document', () => {
24
15
  let document;
25
16
  let dataContract;
26
17
  let documentJs;
27
- let dataContractJs;
28
- let rawDocumentJs;
29
18
  let rawDocumentWithBuffers;
30
19
 
31
20
  // eslint-disable-next-line prefer-arrow-callback
@@ -36,11 +25,8 @@ describe('Document', () => {
36
25
 
37
26
  const now = new Date().getTime();
38
27
  const id = await generateRandomIdentifierAsync();
39
- const jsId = new JsIdentifier(id.toBuffer());
40
28
 
41
29
  const ownerId = await generateRandomIdentifierAsync();
42
- const jsOwnerId = new JsIdentifier(Buffer.from(ownerId.toBuffer()));
43
- const jsDataContractFactory = new JsDataContractFactory(createDPPMock(), () => { });
44
30
  const dataContractFactory = new DataContractFactory(
45
31
  1,
46
32
  { generate: () => crypto.randomBytes(32) },
@@ -62,7 +48,7 @@ describe('Document', () => {
62
48
  identifier: {
63
49
  type: 'array',
64
50
  byteArray: true,
65
- contentMediaType: JsIdentifier.MEDIA_TYPE,
51
+ contentMediaType: Identifier.MEDIA_TYPE,
66
52
  minItems: 32,
67
53
  maxItems: 32,
68
54
  },
@@ -84,7 +70,6 @@ describe('Document', () => {
84
70
  };
85
71
 
86
72
  dataContract = dataContractFactory.create(ownerId, rawDataContract);
87
- dataContractJs = jsDataContractFactory.create(jsOwnerId, rawDataContract);
88
73
 
89
74
  rawDocument = {
90
75
  $protocolVersion: getLatestProtocolVersion(),
@@ -109,13 +94,6 @@ describe('Document', () => {
109
94
  };
110
95
 
111
96
  document = new ExtendedDocument(rawDocument, dataContract);
112
- rawDocumentJs = { ...rawDocument };
113
- rawDocumentJs.$id = jsId;
114
- rawDocumentJs.$ownerId = jsOwnerId;
115
-
116
- rawDocumentJs.$dataContractId = dataContractJs.id;
117
- documentJs = new JsDocument(rawDocumentJs, dataContractJs);
118
- documentJs.dataContractId = JsIdentifier.from(Buffer.from(dataContract.getId().toBuffer()));
119
97
  });
120
98
 
121
99
  describe('constructor', () => {
@@ -136,18 +114,18 @@ describe('Document', () => {
136
114
  });
137
115
 
138
116
  it.skip('should create DocumentCreateTransition with $type and data if present', () => {
139
- const data = {
140
- test: 1,
141
- };
142
-
143
- rawDocument = {
144
- $type: 'test',
145
- ...data,
146
- };
147
-
148
- document = new DocumentCreateTransition(rawDocument, dataContract);
149
-
150
- expect(document.getType()).to.equal(rawDocument.$type);
117
+ // const data = {
118
+ // test: 1,
119
+ // };
120
+ //
121
+ // rawDocument = {
122
+ // $type: 'test',
123
+ // ...data,
124
+ // };
125
+ //
126
+ // document = new DocumentCreateTransition(rawDocument, dataContract);
127
+ //
128
+ // expect(document.getType()).to.equal(rawDocument.$type);
151
129
  });
152
130
 
153
131
  it('should not create ExtendedDocument if $ownerId is missing', async () => {
@@ -429,22 +407,22 @@ describe('Document', () => {
429
407
  // TODO: remove or replace?
430
408
  // can not be compared to JS buffers anymore because uses bin code
431
409
  it.skip('should return the same bytes as JS version when dynamic identifier is in Document', () => {
432
- const jsId = generateRandomIdentifier();
433
- const id = new Identifier(jsId.toBuffer());
434
- const path = 'dataObject.binaryObject.identifier';
435
-
436
- documentJs.set(path, jsId);
437
- document.set(path, id);
438
-
439
- const documentJsIdBuffer = documentJs.get(path).toBuffer();
440
- const documentIdBuffer = document.get(path).toBuffer();
441
-
442
- expect(documentJsIdBuffer).to.deep.equal(jsId);
443
- expect(documentIdBuffer).to.deep.equal(jsId);
444
-
445
- const jsBuffer = documentJs.toBuffer();
446
- const buffer = document.toBuffer();
447
- expect(jsBuffer).to.deep.equal(buffer);
410
+ // const jsId = generateRandomIdentifier();
411
+ // const id = new Identifier(jsId.toBuffer());
412
+ // const path = 'dataObject.binaryObject.identifier';
413
+ //
414
+ // documentJs.set(path, jsId);
415
+ // document.set(path, id);
416
+ //
417
+ // const documentJsIdBuffer = documentJs.get(path).toBuffer();
418
+ // const documentIdBuffer = document.get(path).toBuffer();
419
+ //
420
+ // expect(documentJsIdBuffer).to.deep.equal(jsId);
421
+ // expect(documentIdBuffer).to.deep.equal(jsId);
422
+ //
423
+ // const jsBuffer = documentJs.toBuffer();
424
+ // const buffer = document.toBuffer();
425
+ // expect(jsBuffer).to.deep.equal(buffer);
448
426
  });
449
427
 
450
428
  // TODO: remove or replace?
@@ -1,6 +1,5 @@
1
1
  const bs58 = require('bs58');
2
2
  const crypto = require('crypto');
3
- const DocumentCreateTransition = require('@dashevo/dpp/lib/document/stateTransition/DocumentsBatchTransition/documentTransition/DocumentCreateTransition');
4
3
 
5
4
  const getDataContractFixture = require('../../../lib/test/fixtures/getDataContractFixture');
6
5
  const getDocumentsFixture = require('../../../lib/test/fixtures/getDocumentsFixture');
@@ -10,7 +9,7 @@ let {
10
9
  Identifier, DocumentFactory, ExtendedDocument,
11
10
  InvalidDocumentTypeInDataContractError, InvalidDocumentError,
12
11
  JsonSchemaError, NoDocumentsSuppliedError, MismatchOwnerIdsError, InvalidInitialRevisionError,
13
- InvalidActionNameError,
12
+ InvalidActionNameError, DocumentCreateTransition,
14
13
  } = require('../../..');
15
14
 
16
15
  const { default: loadWasmDpp, SerializedObjectParsingError } = require('../../..');
@@ -38,6 +37,7 @@ describe('DocumentFactory', () => {
38
37
  MismatchOwnerIdsError,
39
38
  InvalidInitialRevisionError,
40
39
  InvalidActionNameError,
40
+ DocumentCreateTransition,
41
41
  } = await loadWasmDpp());
42
42
  });
43
43
 
@@ -1,21 +1,21 @@
1
- const InvalidDocumentError = require('@dashevo/dpp/lib/document/errors/InvalidDocumentError');
2
- const getDocumentsFixture = require('@dashevo/dpp/lib/test/fixtures/getDocumentsFixture');
1
+ const { InvalidDocumentError } = require('../../../..');
2
+ const getDocumentsFixture = require('../../../../lib/test/fixtures/getDocumentsFixture');
3
3
 
4
4
  describe('InvalidDocumentError', () => {
5
5
  let rawDocument;
6
6
  let error;
7
7
 
8
- beforeEach(() => {
8
+ beforeEach(async () => {
9
9
  error = new Error('Some error');
10
10
 
11
- const [document] = getDocumentsFixture();
11
+ const [document] = await getDocumentsFixture();
12
12
  rawDocument = document.toObject();
13
13
  });
14
14
 
15
15
  it('should return errors', () => {
16
16
  const errors = [error];
17
17
 
18
- const invalidDocumentError = new InvalidDocumentError(errors, rawDocument);
18
+ const invalidDocumentError = new InvalidDocumentError(rawDocument, errors);
19
19
 
20
20
  expect(invalidDocumentError.getErrors()).to.deep.equal(errors);
21
21
  });
@@ -23,7 +23,7 @@ describe('InvalidDocumentError', () => {
23
23
  it('should return Document', async () => {
24
24
  const errors = [error];
25
25
 
26
- const invalidDocumentError = new InvalidDocumentError(errors, rawDocument);
26
+ const invalidDocumentError = new InvalidDocumentError(rawDocument, errors);
27
27
 
28
28
  expect(invalidDocumentError.getRawDocument()).to.deep.equal(rawDocument);
29
29
  });
@@ -31,9 +31,9 @@ describe('InvalidDocumentError', () => {
31
31
  it('should contain message for 1 error', async () => {
32
32
  const errors = [error];
33
33
 
34
- const invalidDocumentError = new InvalidDocumentError(errors, rawDocument);
34
+ const invalidDocumentError = new InvalidDocumentError(rawDocument, errors);
35
35
 
36
- expect(invalidDocumentError.message).to.equal(`Invalid Document: "${error.message}"`);
36
+ expect(invalidDocumentError.getMessage()).to.contain('Invalid document: ');
37
37
  });
38
38
 
39
39
  it('should contain message for multiple errors', async () => {
@@ -41,6 +41,6 @@ describe('InvalidDocumentError', () => {
41
41
 
42
42
  const invalidDocumentError = new InvalidDocumentError(errors, rawDocument);
43
43
 
44
- expect(invalidDocumentError.message).to.equal(`Invalid Document: "${error.message}" and 1 more`);
44
+ expect(invalidDocumentError.getMessage()).to.contain('Invalid document: ');
45
45
  });
46
46
  });
@@ -1,158 +1,161 @@
1
- const getDataContractFixture = require('@dashevo/dpp/lib/test/fixtures/getDataContractFixture');
2
- const getDocumentsFixture = require('@dashevo/dpp/lib/test/fixtures/getDocumentsFixture');
3
- const stateTransitionTypes = require('@dashevo/dpp/lib/stateTransition/stateTransitionTypes');
4
- const createDPPMock = require('@dashevo/dpp/lib/test/mocks/createDPPMock');
5
- const protocolVersion = require('@dashevo/dpp/lib/version/protocolVersion');
6
- const DocumentFactoryJs = require('@dashevo/dpp/lib/document/DocumentFactory');
7
- const { default: loadWasmDpp } = require('../../../../../dist');
8
-
9
- let DocumentFactory;
10
- // let DataContract;
11
- let ExtendedDocument;
12
- let DocumentValidator;
13
- let ProtocolVersionValidator;
1
+ // TODO: tests can't be done using comparison with JS version anymore
2
+ // consider restoring them using the new wasm version
3
+
4
+ // const getDocumentsFixture = require('../../../../../lib/test/fixtures/getDocumentsFixture');
5
+ // const getDataContractFixture =
6
+ // require('../../../../../lib/test/fixtures/getDataContractFixture');
7
+ // const {
8
+ // default: loadWasmDpp,
9
+ // StateTransitionTypes,
10
+ // getLatestProtocolVersion,
11
+ // } = require('../../../../../dist');
12
+ //
13
+ // let DocumentFactory;
14
+ // let ExtendedDocument;
15
+ // let DocumentValidator;
16
+ // let ProtocolVersionValidator;
14
17
 
15
18
  describe.skip('DocumentsBatchTransition', () => {
16
- let stateTransitionJs;
17
- let stateTransition;
18
- let documentsJs;
19
- let documents;
20
- let dataContractJs;
21
- let dataContract;
22
- let factoryJs;
23
-
24
- beforeEach(async () => {
25
- ({
26
- ProtocolVersionValidator, DocumentValidator, DocumentFactory,
27
- ExtendedDocument,
28
- } = await loadWasmDpp());
29
- });
30
-
31
- beforeEach(async () => {
32
- dataContractJs = getDataContractFixture();
33
- // dataContract = DataContract.fromBuffer(dataContractJs.toBuffer());
34
-
35
- documentsJs = getDocumentsFixture(dataContractJs);
36
- documents = documentsJs.map((d) => {
37
- const doc = new ExtendedDocument(d.toObject(), dataContract);
38
- doc.setEntropy(d.entropy);
39
- return doc;
40
- });
41
-
42
- const protocolVersionValidatorRs = new ProtocolVersionValidator();
43
- const documentValidatorRs = new DocumentValidator(protocolVersionValidatorRs);
44
- const factory = new DocumentFactory(1, documentValidatorRs, {});
45
- factoryJs = new DocumentFactoryJs(createDPPMock(), undefined, undefined);
46
-
47
- stateTransitionJs = factoryJs.createStateTransition({
48
- create: documentsJs,
49
- });
50
-
51
- stateTransition = factory.createStateTransition({
52
- create: documents,
53
- });
54
- });
55
-
56
- describe('#getProtocolVersion', () => {
57
- it('should return the current protocol version', () => {
58
- const result = stateTransition.getProtocolVersion();
59
-
60
- expect(result).to.equal(protocolVersion.latestVersion);
61
- });
62
- });
63
-
64
- describe('#getType', () => {
65
- it('should return State Transition type', () => {
66
- const result = stateTransition.getType();
67
-
68
- expect(result).to.equal(stateTransitionTypes.DOCUMENTS_BATCH);
69
- });
70
- });
71
-
72
- describe('#getTransitions', () => {
73
- it('should return document transitions', () => {
74
- const result = stateTransition.getTransitions().map((t) => t.toObject());
75
-
76
- expect(result).to.deep.equal(stateTransitionJs.getTransitions().map((t) => t.toObject()));
77
- });
78
- });
79
-
80
- describe('#toJSON', () => {
81
- it('should return State Transition as JSON', () => {
82
- expect(stateTransition.toJSON()).to.deep.equal({
83
- protocolVersion: protocolVersion.latestVersion,
84
- type: stateTransitionTypes.DOCUMENTS_BATCH,
85
- ownerId: documentsJs[0].getOwnerId().toString(),
86
- transitions: stateTransitionJs.getTransitions().map((d) => d.toJSON()),
87
- signaturePublicKeyId: undefined,
88
- signature: undefined,
89
- });
90
- });
91
- });
92
-
93
- describe('#toObject', () => {
94
- it('should return State Transition as plain object', () => {
95
- expect(stateTransition.toObject()).to.deep.equal({
96
- protocolVersion: protocolVersion.latestVersion,
97
- type: stateTransitionTypes.DOCUMENTS_BATCH,
98
- ownerId: documentsJs[0].getOwnerId(),
99
- transitions: stateTransitionJs.getTransitions().map((d) => d.toObject()),
100
- signaturePublicKeyId: undefined,
101
- signature: undefined,
102
- });
103
- });
104
- });
105
-
106
- describe('#toBuffer', () => {
107
- it('should return the same bytes as JS version', () => {
108
- const buffer = stateTransition.toBuffer();
109
- expect(buffer).to.be.instanceOf(Buffer);
110
- expect(buffer).to.have.length(23960);
111
- });
112
- });
113
-
114
- describe('#hash', () => {
115
- it('should return the same hash as the JS version', () => {
116
- const hashJs = stateTransitionJs.hash();
117
- const hash = stateTransitionJs.hash();
118
-
119
- expect(hash).to.deep.equal(hashJs);
120
- });
121
- });
122
-
123
- describe('#getOwnerId', () => {
124
- it('should return owner id', async () => {
125
- const result = stateTransition.getOwnerId();
126
-
127
- expect(result.toBuffer()).to.deep.equal(getDocumentsFixture.ownerId.toBuffer());
128
- });
129
- });
130
-
131
- describe('#getModifiedDataIds', () => {
132
- it('should return ids of affected documents', () => {
133
- const expectedIds = documentsJs.map((doc) => doc.getId().toBuffer());
134
- const result = stateTransition.getModifiedDataIds().map((id) => id.toBuffer());
135
-
136
- expect(result.length).to.be.equal(10);
137
- expect(result).to.be.deep.equal(expectedIds);
138
- });
139
- });
140
-
141
- describe('#isDataContractStateTransition', () => {
142
- it('should return false', () => {
143
- expect(stateTransition.isDataContractStateTransition()).to.be.false();
144
- });
145
- });
146
-
147
- describe('#isDocumentStateTransition', () => {
148
- it('should return true', () => {
149
- expect(stateTransition.isDocumentStateTransition()).to.be.true();
150
- });
151
- });
152
-
153
- describe('#isIdentityStateTransition', () => {
154
- it('should return false', () => {
155
- expect(stateTransition.isIdentityStateTransition()).to.be.false();
156
- });
157
- });
19
+ // let stateTransitionJs;
20
+ // let stateTransition;
21
+ // let documentsJs;
22
+ // let documents;
23
+ // let dataContractJs;
24
+ // let dataContract;
25
+ // let factoryJs;
26
+ //
27
+ // beforeEach(async () => {
28
+ // ({
29
+ // ProtocolVersionValidator, DocumentValidator, DocumentFactory,
30
+ // ExtendedDocument,
31
+ // } = await loadWasmDpp());
32
+ // });
33
+ //
34
+ // beforeEach(async () => {
35
+ // dataContractJs = getDataContractFixture();
36
+ // // dataContract = DataContract.fromBuffer(dataContractJs.toBuffer());
37
+ //
38
+ // documentsJs = getDocumentsFixture(dataContractJs);
39
+ // documents = documentsJs.map((d) => {
40
+ // const doc = new ExtendedDocument(d.toObject(), dataContract);
41
+ // doc.setEntropy(d.entropy);
42
+ // return doc;
43
+ // });
44
+ //
45
+ // const protocolVersionValidatorRs = new ProtocolVersionValidator();
46
+ // const documentValidatorRs = new DocumentValidator(protocolVersionValidatorRs);
47
+ // const factory = new DocumentFactory(1, documentValidatorRs, {});
48
+ // factoryJs = new DocumentFactoryJs(createDPPMock(), undefined, undefined);
49
+ //
50
+ // stateTransitionJs = factoryJs.createStateTransition({
51
+ // create: documentsJs,
52
+ // });
53
+ //
54
+ // stateTransition = factory.createStateTransition({
55
+ // create: documents,
56
+ // });
57
+ // });
58
+ //
59
+ // describe('#getProtocolVersion', () => {
60
+ // it('should return the current protocol version', () => {
61
+ // const result = stateTransition.getProtocolVersion();
62
+ //
63
+ // expect(result).to.equal(protocolVersion.latestVersion);
64
+ // });
65
+ // });
66
+ //
67
+ // describe('#getType', () => {
68
+ // it('should return State Transition type', () => {
69
+ // const result = stateTransition.getType();
70
+ //
71
+ // expect(result).to.equal(stateTransitionTypes.DOCUMENTS_BATCH);
72
+ // });
73
+ // });
74
+ //
75
+ // describe('#getTransitions', () => {
76
+ // it('should return document transitions', () => {
77
+ // const result = stateTransition.getTransitions().map((t) => t.toObject());
78
+ //
79
+ // expect(result).to.deep.equal(stateTransitionJs.getTransitions().map((t) => t.toObject()));
80
+ // });
81
+ // });
82
+ //
83
+ // describe('#toJSON', () => {
84
+ // it('should return State Transition as JSON', () => {
85
+ // expect(stateTransition.toJSON()).to.deep.equal({
86
+ // protocolVersion: protocolVersion.latestVersion,
87
+ // type: stateTransitionTypes.DOCUMENTS_BATCH,
88
+ // ownerId: documentsJs[0].getOwnerId().toString(),
89
+ // transitions: stateTransitionJs.getTransitions().map((d) => d.toJSON()),
90
+ // signaturePublicKeyId: undefined,
91
+ // signature: undefined,
92
+ // });
93
+ // });
94
+ // });
95
+ //
96
+ // describe('#toObject', () => {
97
+ // it('should return State Transition as plain object', () => {
98
+ // expect(stateTransition.toObject()).to.deep.equal({
99
+ // protocolVersion: protocolVersion.latestVersion,
100
+ // type: stateTransitionTypes.DOCUMENTS_BATCH,
101
+ // ownerId: documentsJs[0].getOwnerId(),
102
+ // transitions: stateTransitionJs.getTransitions().map((d) => d.toObject()),
103
+ // signaturePublicKeyId: undefined,
104
+ // signature: undefined,
105
+ // });
106
+ // });
107
+ // });
108
+ //
109
+ // describe('#toBuffer', () => {
110
+ // it('should return the same bytes as JS version', () => {
111
+ // const buffer = stateTransition.toBuffer();
112
+ // expect(buffer).to.be.instanceOf(Buffer);
113
+ // expect(buffer).to.have.length(23960);
114
+ // });
115
+ // });
116
+ //
117
+ // describe('#hash', () => {
118
+ // it('should return the same hash as the JS version', () => {
119
+ // const hashJs = stateTransitionJs.hash();
120
+ // const hash = stateTransitionJs.hash();
121
+ //
122
+ // expect(hash).to.deep.equal(hashJs);
123
+ // });
124
+ // });
125
+ //
126
+ // describe('#getOwnerId', () => {
127
+ // it('should return owner id', async () => {
128
+ // const result = stateTransition.getOwnerId();
129
+ //
130
+ // expect(result.toBuffer()).to.deep.equal(getDocumentsFixture.ownerId.toBuffer());
131
+ // });
132
+ // });
133
+ //
134
+ // describe('#getModifiedDataIds', () => {
135
+ // it('should return ids of affected documents', () => {
136
+ // const expectedIds = documentsJs.map((doc) => doc.getId().toBuffer());
137
+ // const result = stateTransition.getModifiedDataIds().map((id) => id.toBuffer());
138
+ //
139
+ // expect(result.length).to.be.equal(10);
140
+ // expect(result).to.be.deep.equal(expectedIds);
141
+ // });
142
+ // });
143
+ //
144
+ // describe('#isDataContractStateTransition', () => {
145
+ // it('should return false', () => {
146
+ // expect(stateTransition.isDataContractStateTransition()).to.be.false();
147
+ // });
148
+ // });
149
+ //
150
+ // describe('#isDocumentStateTransition', () => {
151
+ // it('should return true', () => {
152
+ // expect(stateTransition.isDocumentStateTransition()).to.be.true();
153
+ // });
154
+ // });
155
+ //
156
+ // describe('#isIdentityStateTransition', () => {
157
+ // it('should return false', () => {
158
+ // expect(stateTransition.isIdentityStateTransition()).to.be.false();
159
+ // });
160
+ // });
158
161
  });