@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.
- package/Cargo.toml +3 -2
- package/README.md +1 -1
- package/dist/wasm/wasm_dpp.d.ts +808 -712
- package/dist/wasm/wasm_dpp.js +853 -452
- package/dist/wasm/wasm_dpp_bg.js +1 -1
- package/lib/bls/bls.js +48 -0
- package/lib/test/fixtures/getChainAssetLockProofFixture.js +20 -1
- package/lib/test/fixtures/getDataContractFixture.js +4 -6
- package/lib/test/fixtures/getDocumentTransitionsFixture.js +31 -1
- package/lib/test/fixtures/getInstantAssetLockProofFixture.js +32 -12
- package/lib/test/mocks/getBlsAdapterMock.js +1 -1
- package/lib/utils/creditsConverter.js +14 -0
- package/lib/utils/hash.js +18 -0
- package/lib/wasm/wasm_dpp.d.ts +808 -712
- package/package.json +3 -5
- package/src/dash_platform_protocol.rs +5 -5
- package/src/document/errors/invalid_document_error.rs +5 -0
- package/src/document/extended_document.rs +15 -0
- package/src/document/state_transition/document_batch_transition/document_transition/document_create_transition.rs +219 -214
- package/src/document/state_transition/document_batch_transition/document_transition/mod.rs +1 -1
- package/src/errors/consensus/basic/identity/identity_insufficient_balance_error.rs +4 -2
- package/src/errors/consensus/basic/json_schema_error.rs +35 -5
- package/src/identity/identity_facade.rs +7 -5
- package/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs +32 -17
- package/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs +22 -13
- package/src/identity/state_transition/asset_lock_proof/mod.rs +12 -11
- package/src/identity/state_transition/identity_create_transition/identity_create_transition.rs +1 -0
- package/src/identity/state_transition/identity_create_transition/to_object.rs +1 -0
- package/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs +1 -0
- package/src/identity/state_transition/identity_topup_transition/to_object.rs +1 -0
- package/src/lib.rs +1 -1
- package/src/validation/mod.rs +2 -2
- package/src/validation/validation_result.rs +16 -15
- package/test/integration/document/DocumentFacade.spec.js +11 -27
- package/test/integration/document/stateTransition/DocumentsBatchTransition/DocumentBatchTransition.spec.js +9 -19
- package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/basic/validateDocumentsBatchTransitionBasicFactory.spec.js +2 -2
- package/test/integration/document/validation/validateDocumentFactory.spec.js +2 -2
- package/test/integration/identity/IdentityFacade.spec.js +1 -2
- package/test/integration/identity/stateTransition/assetLockProof/instant/validateInstantAssetLockProofStructureFactory.spec.js +2 -2
- package/test/integration/identity/stateTransition/validatePublicKeySignaturesFactory.spec.js +2 -2
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +6 -8
- package/test/unit/document/Document.spec.js +30 -52
- package/test/unit/document/DocumentFactory.spec.js +2 -2
- package/test/unit/document/errors/InvalidDocumentError.spec.js +9 -9
- package/test/unit/document/stateTransition/DocumetsBatchTransition/DocumentsBatchTransition.spec.js +158 -155
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/findDuplicatesByIndices.spec.js +132 -134
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/validatePartialCompoundIndices.spec.js +3 -3
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsBatchTransitionStateFactory.spec.js +568 -591
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsUniquenessByIndicesFactory.spec.js +5 -13
- package/test/unit/identity/Identity.spec.js +2 -2
- package/test/unit/identity/stateTransition/assetLockProof/ChainAssetLockProof.spec.js +9 -28
- package/test/unit/identity/stateTransition/assetLockProof/InstantAssetLockProof.spec.js +19 -27
- package/lib/test/fixtures/getDashPayContractFixture.js +0 -1
- package/lib/test/fixtures/getDashPayDocumentFixture.js +0 -1
- package/lib/test/fixtures/getDpnsContractFixture.js +0 -1
- package/lib/test/fixtures/getDpnsDocumentFixture.js +0 -1
- package/lib/test/fixtures/getFeatureFlagsContractFixture.js +0 -1
- package/lib/test/fixtures/getFeatureFlagsDocumentsFixture.js +0 -1
- package/lib/test/fixtures/getIdentityTopUpTransitionFixtureJs.js +0 -1
- package/lib/test/fixtures/getMasternodeRewardShareDocumentsFixture.js +0 -1
- package/lib/test/fixtures/getMasternodeRewardSharesContractFixture.js +0 -1
- package/lib/test/fixtures/getPreorderDocumentFixture.js +0 -1
- package/lib/test/fixtures/getRawTransactionFixture.js +0 -1
- package/lib/test/fixtures/js/generateRandomIdentifier.js +0 -1
- package/lib/test/fixtures/js/getChainAssetLockProofFixture.js +0 -1
- package/lib/test/fixtures/js/getDataContractFixture.js +0 -1
- package/lib/test/fixtures/js/getDocumentTransitionsFixture.js +0 -1
- package/lib/test/fixtures/js/getDocumentsFixture.js +0 -1
- package/lib/test/fixtures/js/getInstantAssetLockProofFixture.js +0 -1
- package/test/integration/DashPlatformProtocol.spec.js +0 -53
- package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/state/executeDataTriggersFactory.spec.js +0 -195
- package/test/integration/stateTransition/AbstractStateTransitionIdentitySigned.spec.js +0 -500
- package/test/integration/stateTransition/calculateStateTransitionFeeFromOperationsFactory.spec.js +0 -53
- package/test/unit/dataContract/getBinaryPropertiesFromSchema.spec.js +0 -103
- package/test/unit/dataContract/getPropertyDefinitionByPath.spec.js +0 -84
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/applyDataContractCreateTransitionFactory.spec.js +0 -45
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/applyDataContractUpdateTransitionFactory.spec.js +0 -49
- package/test/unit/dataTrigger/DataTrigger.spec.js +0 -132
- package/test/unit/dataTrigger/DataTriggerExecutionContext.spec.js +0 -29
- package/test/unit/dataTrigger/dashpayDataTriggers/createContactRequestDataTrigger.spec.js +0 -107
- package/test/unit/dataTrigger/dpnsTriggers/createDomainDataTrigger.spec.js +0 -382
- package/test/unit/dataTrigger/featureFlagDataTriggers/createFeatureFlagDataTrigger.spec.js +0 -99
- package/test/unit/dataTrigger/getDataTriggersFactory.spec.js +0 -113
- package/test/unit/dataTrigger/rejectDataTrigger.spec.js +0 -51
- package/test/unit/dataTrigger/rewardShareDataTriggers/createMasternodeRewardSharesDataTrigger.spec.js +0 -202
- package/test/unit/document/stateTransition/DocumetsBatchTransition/applyDocumentsBatchTransitionFactory.spec.js +0 -256
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/fetchDocumentsFactory.spec.js +0 -94
- package/test/unit/errors/consensus/codes.spec.js +0 -102
- package/test/unit/identity/creditsConverter.spec.js +0 -34
- package/test/unit/identity/stateTransition/IdentityCreateTransition/applyIdentityCreateTransitionFactory.spec.js +0 -83
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/applyIdentityTopUpTransitionFactory.spec.js +0 -138
- package/test/unit/identity/stateTransition/IdentityUpdateTransition/applyIdentityUpdateTransitionFactory.spec.js +0 -100
- package/test/unit/identity/stateTransition/assetLockProof/createAssetLockProofInstance.spec.js +0 -36
- package/test/unit/identity/stateTransition/assetLockProof/fetchAssetLockPublicKeyHashFactory.spec.js +0 -63
- 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:
|
|
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
|
-
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
rawDocument = {
|
|
144
|
-
|
|
145
|
-
|
|
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('
|
|
2
|
-
const getDocumentsFixture = require('
|
|
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(
|
|
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(
|
|
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(
|
|
34
|
+
const invalidDocumentError = new InvalidDocumentError(rawDocument, errors);
|
|
35
35
|
|
|
36
|
-
expect(invalidDocumentError.
|
|
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.
|
|
44
|
+
expect(invalidDocumentError.getMessage()).to.contain('Invalid document: ');
|
|
45
45
|
});
|
|
46
46
|
});
|
package/test/unit/document/stateTransition/DocumetsBatchTransition/DocumentsBatchTransition.spec.js
CHANGED
|
@@ -1,158 +1,161 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
beforeEach(async () => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe('#getProtocolVersion', () => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe('#getType', () => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('#getTransitions', () => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('#toJSON', () => {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe('#toObject', () => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('#toBuffer', () => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
describe('#hash', () => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
describe('#getOwnerId', () => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
describe('#getModifiedDataIds', () => {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describe('#isDataContractStateTransition', () => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
describe('#isDocumentStateTransition', () => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
describe('#isIdentityStateTransition', () => {
|
|
154
|
-
|
|
155
|
-
|
|
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
|
});
|