@dashevo/wasm-dpp 0.24.0-dev.34 → 0.24.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/Cargo.toml +2 -1
- package/dist/wasm/wasm_dpp.d.ts +615 -589
- package/dist/wasm/wasm_dpp.js +58 -51
- package/dist/wasm/wasm_dpp_bg.js +1 -1
- package/lib/test/fixtures/getIdentityCreateTransitionFixture.js +2 -2
- package/lib/test/fixtures/js/generateRandomIdentifier.js +1 -0
- package/lib/test/fixtures/js/getChainAssetLockProofFixture.js +1 -0
- package/lib/test/fixtures/js/getDataContractFixture.js +1 -0
- package/lib/test/fixtures/js/getDocumentTransitionsFixture.js +1 -0
- package/lib/test/fixtures/js/getDocumentsFixture.js +1 -0
- package/lib/test/fixtures/js/getInstantAssetLockProofFixture.js +1 -0
- package/lib/test/mocks/createStateRepositoryMock.js +1 -0
- package/lib/wasm/wasm_dpp.d.ts +615 -589
- package/package.json +3 -3
- package/scripts/build-wasm.sh +4 -4
- package/src/errors/value_error.rs +5 -0
- package/src/identity/state_transition/mod.rs +1 -0
- package/src/identity/state_transition/transition_types.rs +30 -0
- package/src/lib.rs +1 -0
- package/src/protocol_version.rs +7 -0
- package/src/state_transition/errors/invalid_state_transition_error.rs +14 -1
- package/src/state_transition/state_transition_facade.rs +7 -1
- package/test/integration/dataContract/DataContractFacade.spec.js +1 -1
- package/test/integration/dataContract/stateTransition/DataContractCreateTransition/validation/basic/validateDataContractCreateTransitionBasicFactory.spec.js +5 -5
- package/test/integration/dataContract/stateTransition/DataContractUpdateTransition/validation/basic/validateDataContractUpdateTransitionBasicFactory.spec.js +7 -7
- package/test/integration/dataContract/validation/validateDataContractFactory.spec.js +2 -2
- package/test/integration/document/DocumentFacade.spec.js +4 -4
- package/test/integration/document/stateTransition/DocumentsBatchTransition/DocumentBatchTransition.spec.js +5 -6
- package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/basic/validateDocumentsBatchTransitionBasicFactory.spec.js +14 -14
- package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/state/executeDataTriggersFactory.spec.js +1 -1
- package/test/integration/document/validation/validateDocumentFactory.spec.js +2 -2
- package/test/integration/identity/IdentityFacade.spec.js +8 -8
- package/test/integration/identity/stateTransition/IdentityCreateTransition/validation/basic/validateIdentityCreateTransitionBasicFactory.spec.js +4 -6
- package/test/integration/identity/stateTransition/IdentityTopUpTransition/validation/basic/validateIdentityTopUpTransitionBasicFactory.spec.js +3 -6
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validateIdentityUpdateTransitionStateFactory.spec.js +20 -23
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validatePublicKeysState.spec.js +1 -1
- package/test/integration/identity/stateTransition/assetLockProof/chain/validateChainAssetLockProofStructureFactory.spec.js +3 -3
- package/test/integration/identity/stateTransition/assetLockProof/fetchAssetLockTransactionOutputFactory.spec.js +5 -8
- package/test/integration/identity/stateTransition/assetLockProof/instant/validateInstantAssetLockProofStructureFactory.spec.js +3 -4
- package/test/integration/identity/stateTransition/assetLockProof/validateAssetLockTransactionFactory.spec.js +2 -3
- package/test/integration/identity/stateTransition/validatePublicKeySignaturesFactory.spec.js +2 -6
- package/test/integration/identity/validation/validateIdentityFactory.spec.js +6 -5
- package/test/integration/identity/validation/validatePublicKeysFactory.spec.js +4 -24
- package/test/integration/stateTransition/StateTransitionFacade.spec.js +11 -15
- package/test/unit/DashPlatformProtocol.spec.js +6 -7
- package/test/unit/dataContract/DataContract.spec.js +10 -9
- package/test/unit/dataContract/DataContractFactory.spec.js +4 -5
- package/test/unit/dataContract/createDataContract.spec.js +5 -5
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +14 -13
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/applyDataContractCreateTransitionFactory.spec.js +6 -8
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/validation/state/validateDataContractCreateTransitionStateFactory.spec.js +6 -6
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +14 -12
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/applyDataContractUpdateTransitionFactory.spec.js +6 -6
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/basic/validateIndicesAreBackwardCompatible.spec.js +4 -4
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/state/validateDataContractUpdateTransitionStateFactory.spec.js +7 -7
- package/test/unit/dataContract/validation/validateDataContractPatterns.spec.js +6 -6
- package/test/unit/document/Document.spec.js +5 -4
- package/test/unit/document/stateTransition/DocumetsBatchTransition/applyDocumentsBatchTransitionFactory.spec.js +10 -11
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsBatchTransitionStateFactory.spec.js +8 -8
- package/test/unit/identity/Identity.spec.js +6 -6
- package/test/unit/identity/IdentityFactory.spec.js +11 -11
- package/test/unit/identity/stateTransition/IdentityCreateTransition/IdentityCreateTransition.spec.js +13 -14
- package/test/unit/identity/stateTransition/IdentityCreateTransition/applyIdentityCreateTransitionFactory.spec.js +7 -13
- package/test/unit/identity/stateTransition/IdentityCreateTransition/validation/state/validateIdentityCreateTransitionStateFactory.spec.js +3 -7
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/IdentityTopUpTransition.spec.js +13 -14
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/applyIdentityTopUpTransitionFactory.spec.js +5 -9
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/validation/state/validateIdentityTopUpTransitionStateFactory.spec.js +4 -8
- package/test/unit/identity/stateTransition/IdentityUpdateTransition/IdentityUpdateTransition.spec.js +11 -16
- package/test/unit/identity/stateTransition/IdentityUpdateTransition/applyIdentityUpdateTransitionFactory.spec.js +1 -1
- package/test/unit/stateTransition/StateTransitionFactory.spec.js +6 -7
- package/test/unit/stateTransition/createStateTransitionFactory.spec.js +41 -19
- package/test/unit/stateTransition/validation/validateStateTransitionKeySignatureFactory.spec.js +6 -12
- package/test/integration/ajv/keywords/byteArray/addByteArrayKeyword.spec.js +0 -148
- package/test/integration/util/generateEntropy.spec.js +0 -17
- package/test/integration/util/serializer.spec.js +0 -24
- package/test/unit/identity/errors/InvalidIdentityError.spec.js +0 -46
- package/test/unit/stateTransition/errors/InvalidStateTransitionError.spec.js +0 -51
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const getDataContractFixture = require('
|
|
2
|
-
const protocolVersion = require('@dashevo/dpp/lib/version/protocolVersion');
|
|
1
|
+
const getDataContractFixture = require('../../../../../../../lib/test/fixtures/getDataContractFixture');
|
|
3
2
|
|
|
4
|
-
const { default: loadWasmDpp } = require('
|
|
3
|
+
const { default: loadWasmDpp } = require('../../../../../../..');
|
|
4
|
+
const { getLatestProtocolVersion } = require('../../../../../../..');
|
|
5
5
|
|
|
6
6
|
describe('validateDataContractUpdateTransitionStateFactory', () => {
|
|
7
7
|
let validateDataContractUpdateTransitionState;
|
|
@@ -31,7 +31,7 @@ describe('validateDataContractUpdateTransitionStateFactory', () => {
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
beforeEach(async () => {
|
|
34
|
-
dataContract = getDataContractFixture();
|
|
34
|
+
dataContract = await getDataContractFixture();
|
|
35
35
|
|
|
36
36
|
const updatedRawDataContract = dataContract.toObject();
|
|
37
37
|
|
|
@@ -39,7 +39,7 @@ describe('validateDataContractUpdateTransitionStateFactory', () => {
|
|
|
39
39
|
|
|
40
40
|
stateTransition = new DataContractUpdateTransition({
|
|
41
41
|
dataContract: updatedRawDataContract,
|
|
42
|
-
protocolVersion:
|
|
42
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
executionContext = new StateTransitionExecutionContext();
|
|
@@ -47,7 +47,7 @@ describe('validateDataContractUpdateTransitionStateFactory', () => {
|
|
|
47
47
|
stateTransition.setExecutionContext(executionContext);
|
|
48
48
|
|
|
49
49
|
const validator = new DataContractValidator();
|
|
50
|
-
const dataContractFactory = new DataContractFactory(
|
|
50
|
+
const dataContractFactory = new DataContractFactory(getLatestProtocolVersion(), validator);
|
|
51
51
|
const wasmDataContract = await dataContractFactory.createFromBuffer(dataContract.toBuffer());
|
|
52
52
|
|
|
53
53
|
const stateRepositoryLike = {
|
|
@@ -87,7 +87,7 @@ describe('validateDataContractUpdateTransitionStateFactory', () => {
|
|
|
87
87
|
|
|
88
88
|
const badStateTransition = new DataContractUpdateTransition({
|
|
89
89
|
dataContract: badlyUpdatedRawDataContract,
|
|
90
|
-
protocolVersion:
|
|
90
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
const result = await validateTransitionWithExistingContract(badStateTransition);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const getDataContractFixture = require('
|
|
1
|
+
const getDataContractFixture = require('../../../../lib/test/fixtures/getDataContractFixture');
|
|
2
2
|
|
|
3
|
-
const { default: loadWasmDpp } = require('
|
|
3
|
+
const { default: loadWasmDpp } = require('../../../..');
|
|
4
4
|
|
|
5
5
|
describe('validateDataContractPatterns', () => {
|
|
6
6
|
let DataContractValidator;
|
|
@@ -13,8 +13,8 @@ describe('validateDataContractPatterns', () => {
|
|
|
13
13
|
} = await loadWasmDpp());
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
it('should return valid result', () => {
|
|
17
|
-
const rawDataContract = getDataContractFixture().toObject();
|
|
16
|
+
it('should return valid result', async () => {
|
|
17
|
+
const rawDataContract = (await getDataContractFixture()).toObject();
|
|
18
18
|
delete rawDataContract.$defs;
|
|
19
19
|
|
|
20
20
|
const schema = {
|
|
@@ -39,8 +39,8 @@ describe('validateDataContractPatterns', () => {
|
|
|
39
39
|
expect(result.isValid()).to.be.true();
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
it('should return invalid result on incompatible pattern', () => {
|
|
43
|
-
const rawDataContract = getDataContractFixture().toObject();
|
|
42
|
+
it('should return invalid result on incompatible pattern', async () => {
|
|
43
|
+
const rawDataContract = (await getDataContractFixture()).toObject();
|
|
44
44
|
delete rawDataContract.$defs;
|
|
45
45
|
|
|
46
46
|
const schema = {
|
|
@@ -4,12 +4,13 @@ const JsDocument = require('@dashevo/dpp/lib/document/Document');
|
|
|
4
4
|
const DocumentCreateTransition = require(
|
|
5
5
|
'@dashevo/dpp/lib/document/stateTransition/DocumentsBatchTransition/documentTransition/DocumentCreateTransition',
|
|
6
6
|
);
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
const createDPPMock = require('@dashevo/dpp/lib/test/mocks/createDPPMock');
|
|
9
9
|
const generateRandomIdentifier = require('@dashevo/dpp/lib/test/utils/generateRandomIdentifier');
|
|
10
10
|
|
|
11
11
|
const generateRandomIdentifierAsync = require('../../../lib/test/utils/generateRandomIdentifierAsync');
|
|
12
|
-
const { default: loadWasmDpp } = require('
|
|
12
|
+
const { default: loadWasmDpp } = require('../../..');
|
|
13
|
+
const { getLatestProtocolVersion } = require('../../..');
|
|
13
14
|
|
|
14
15
|
let DataContractFactory;
|
|
15
16
|
let DataContractValidator;
|
|
@@ -80,7 +81,7 @@ describe('Document', () => {
|
|
|
80
81
|
dataContractJs = jsDataContractFactory.create(jsOwnerId, rawDataContract);
|
|
81
82
|
|
|
82
83
|
rawDocument = {
|
|
83
|
-
$protocolVersion:
|
|
84
|
+
$protocolVersion: getLatestProtocolVersion(),
|
|
84
85
|
$id: id,
|
|
85
86
|
$type: 'test',
|
|
86
87
|
$dataContractId: dataContract.getId(),
|
|
@@ -91,7 +92,7 @@ describe('Document', () => {
|
|
|
91
92
|
};
|
|
92
93
|
|
|
93
94
|
rawDocumentWithBuffers = {
|
|
94
|
-
$protocolVersion:
|
|
95
|
+
$protocolVersion: getLatestProtocolVersion(),
|
|
95
96
|
$id: id.toBuffer(),
|
|
96
97
|
$type: 'test',
|
|
97
98
|
$dataContractId: dataContract.getId().toBuffer(),
|
|
@@ -7,18 +7,17 @@ const applyDocumentsBatchTransitionFactory = require(
|
|
|
7
7
|
'@dashevo/dpp/lib/document/stateTransition/DocumentsBatchTransition/applyDocumentsBatchTransitionFactory',
|
|
8
8
|
);
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const StateTransitionExecutionContextJs = require('@dashevo/dpp/lib/stateTransition/StateTransitionExecutionContext');
|
|
11
|
+
const getDataContractFixture = require('../../../../../lib/test/fixtures/js/getDataContractFixture');
|
|
12
|
+
const getDocumentsFixture = require('../../../../../lib/test/fixtures/js/getDocumentsFixture');
|
|
12
13
|
const getDocumentTransitionsFixture = require(
|
|
13
|
-
'
|
|
14
|
+
'../../../../../lib/test/fixtures/js/getDocumentTransitionsFixture',
|
|
14
15
|
);
|
|
15
16
|
|
|
16
|
-
const createStateRepositoryMock = require('
|
|
17
|
-
|
|
18
|
-
const protocolVersion = require('@dashevo/dpp/lib/version/protocolVersion');
|
|
19
|
-
const StateTransitionExecutionContextJs = require('@dashevo/dpp/lib/stateTransition/StateTransitionExecutionContext');
|
|
17
|
+
const createStateRepositoryMock = require('../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
20
18
|
|
|
21
|
-
const { default: loadWasmDpp } = require('
|
|
19
|
+
const { default: loadWasmDpp } = require('../../../../..');
|
|
20
|
+
const { getLatestProtocolVersion } = require('../../../../..');
|
|
22
21
|
|
|
23
22
|
let ExtendedDocument;
|
|
24
23
|
let DocumentsBatchTransition;
|
|
@@ -89,13 +88,13 @@ describe('applyDocumentsBatchTransitionFactory', () => {
|
|
|
89
88
|
});
|
|
90
89
|
|
|
91
90
|
stateTransitionJs = new DocumentsBatchTransitionJs({
|
|
92
|
-
protocolVersion:
|
|
91
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
93
92
|
ownerId,
|
|
94
93
|
transitions: documentTransitionsJs.map((t) => t.toObject()),
|
|
95
94
|
}, [dataContractJs]);
|
|
96
95
|
|
|
97
96
|
stateTransition = new DocumentsBatchTransition({
|
|
98
|
-
protocolVersion:
|
|
97
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
99
98
|
ownerId,
|
|
100
99
|
transitions: documentTransitionsJs.map((t) => t.toObject()),
|
|
101
100
|
}, [dataContract]);
|
|
@@ -222,7 +221,7 @@ describe('applyDocumentsBatchTransitionFactory', () => {
|
|
|
222
221
|
});
|
|
223
222
|
|
|
224
223
|
stateTransition = new DocumentsBatchTransition({
|
|
225
|
-
protocolVersion:
|
|
224
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
226
225
|
ownerId,
|
|
227
226
|
transitions: documentTransitionsJs.map((t) => t.toObject()),
|
|
228
227
|
}, [dataContract]);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const DocumentJs = require('@dashevo/dpp/lib/document/Document');
|
|
2
2
|
const DocumentsBatchTransitionJs = require('@dashevo/dpp/lib/document/stateTransition/DocumentsBatchTransition/DocumentsBatchTransition');
|
|
3
3
|
const DataTriggerExecutionResult = require('@dashevo/dpp/lib/dataTrigger/DataTriggerExecutionResult');
|
|
4
|
-
|
|
5
|
-
const getDataContractFixture = require('@dashevo/dpp/lib/test/fixtures/getDataContractFixture');
|
|
6
|
-
const getDocumentsFixture = require('@dashevo/dpp/lib/test/fixtures/getDocumentsFixture');
|
|
7
|
-
const getDocumentTransitionsFixture = require('@dashevo/dpp/lib/test/fixtures/getDocumentTransitionsFixture');
|
|
8
|
-
const createStateRepositoryMock = require('@dashevo/dpp/lib/test/mocks/createStateRepositoryMock');
|
|
9
|
-
|
|
10
4
|
const ValidationResultJs = require('@dashevo/dpp/lib/validation/ValidationResult');
|
|
11
|
-
const generateRandomIdentifier = require('@dashevo/dpp/lib/test/utils/generateRandomIdentifier');
|
|
12
5
|
const StateTransitionExecutionContextJs = require('@dashevo/dpp/lib/stateTransition/StateTransitionExecutionContext');
|
|
6
|
+
|
|
7
|
+
const generateRandomIdentifier = require('../../../../../../../lib/test/utils/generateRandomIdentifierAsync');
|
|
8
|
+
const getDataContractFixture = require('../../../../../../../lib/test/fixtures/js/getDataContractFixture');
|
|
9
|
+
const getDocumentsFixture = require('../../../../../../../lib/test/fixtures/js/getDocumentsFixture');
|
|
10
|
+
const getDocumentTransitionsFixture = require('../../../../../../../lib/test/fixtures/getDocumentTransitionsFixture');
|
|
11
|
+
const createStateRepositoryMock = require('../../../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
12
|
+
|
|
13
13
|
const { default: loadWasmDpp } = require('../../../../../../../dist');
|
|
14
14
|
|
|
15
15
|
let Identifier;
|
|
@@ -262,7 +262,7 @@ describe('validateDocumentsBatchTransitionStateFactory', () => {
|
|
|
262
262
|
replaceDocument.setRevision(1);
|
|
263
263
|
|
|
264
264
|
const fetchedDocument = new ExtendedDocument(documentsJs[0].toObject(), dataContract);
|
|
265
|
-
fetchedDocument.setOwnerId(Identifier.from(generateRandomIdentifier().toBuffer()));
|
|
265
|
+
fetchedDocument.setOwnerId(Identifier.from((await generateRandomIdentifier()).toBuffer()));
|
|
266
266
|
|
|
267
267
|
documentTransitionsJs = getDocumentTransitionsFixture({
|
|
268
268
|
create: [],
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const varint = require('varint');
|
|
2
|
-
|
|
3
|
-
const protocolVersion = require('@dashevo/dpp/lib/version/protocolVersion');
|
|
2
|
+
|
|
4
3
|
const JSIdentity = require('@dashevo/dpp/lib/identity/Identity');
|
|
5
4
|
|
|
6
5
|
const { hash: hashFunction } = require('@dashevo/dpp/lib/util/hash');
|
|
7
6
|
const { expect } = require('chai');
|
|
8
7
|
const generateRandomIdentifierAsync = require('../../../lib/test/utils/generateRandomIdentifierAsync');
|
|
9
|
-
const { default: loadWasmDpp } = require('
|
|
8
|
+
const { default: loadWasmDpp } = require('../../..');
|
|
9
|
+
const { getLatestProtocolVersion } = require('../../..');
|
|
10
10
|
|
|
11
11
|
describe('Identity', () => {
|
|
12
12
|
let rawIdentity;
|
|
@@ -27,7 +27,7 @@ describe('Identity', () => {
|
|
|
27
27
|
|
|
28
28
|
beforeEach(async () => {
|
|
29
29
|
rawIdentity = {
|
|
30
|
-
protocolVersion:
|
|
30
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
31
31
|
id: await generateRandomIdentifierAsync(),
|
|
32
32
|
publicKeys: [
|
|
33
33
|
{
|
|
@@ -109,7 +109,7 @@ describe('Identity', () => {
|
|
|
109
109
|
readOnly: false,
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
const ipk = new
|
|
112
|
+
const ipk = new IdentityPublicKey(rawKey);
|
|
113
113
|
|
|
114
114
|
identity.setPublicKeys([ipk]);
|
|
115
115
|
expect(identity.getPublicKeys()).length(1);
|
|
@@ -176,7 +176,7 @@ describe('Identity', () => {
|
|
|
176
176
|
const jsonIdentity = identity.toJSON();
|
|
177
177
|
|
|
178
178
|
expect(jsonIdentity).to.deep.equal({
|
|
179
|
-
protocolVersion:
|
|
179
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
180
180
|
id: rawIdentity.id.toString(),
|
|
181
181
|
publicKeys: [
|
|
182
182
|
{
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const getIdentityFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityFixture');
|
|
1
|
+
const getInstantAssetLockProofFixture = require('../../../lib/test/fixtures/getInstantAssetLockProofFixture');
|
|
2
|
+
const getIdentityFixture = require('../../../lib/test/fixtures/getIdentityFixture');
|
|
4
3
|
const getChainAssetLockProofFixture = require('../../../lib/test/fixtures/getChainAssetLockProofFixture');
|
|
5
|
-
const { default: loadWasmDpp } = require('
|
|
4
|
+
const { default: loadWasmDpp } = require('../../..');
|
|
5
|
+
const { IdentityPublicKey } = require('../../..');
|
|
6
6
|
const getBlsAdapterMock = require('../../../lib/test/mocks/getBlsAdapterMock');
|
|
7
7
|
|
|
8
8
|
describe('IdentityFactory', () => {
|
|
@@ -35,10 +35,10 @@ describe('IdentityFactory', () => {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
beforeEach(async function () {
|
|
38
|
-
const instantAssetLockProofJS =
|
|
39
|
-
const chainAssetLockProofJS =
|
|
40
|
-
instantAssetLockProof =
|
|
41
|
-
chainAssetLockProof = new ChainAssetLockProof(
|
|
38
|
+
// const instantAssetLockProofJS = ;
|
|
39
|
+
// const chainAssetLockProofJS = ;
|
|
40
|
+
instantAssetLockProof = await getInstantAssetLockProofFixture();
|
|
41
|
+
chainAssetLockProof = new ChainAssetLockProof(getChainAssetLockProofFixture().toObject());
|
|
42
42
|
|
|
43
43
|
const blsAdapter = await getBlsAdapterMock();
|
|
44
44
|
|
|
@@ -49,7 +49,7 @@ describe('IdentityFactory', () => {
|
|
|
49
49
|
identityValidator,
|
|
50
50
|
);
|
|
51
51
|
|
|
52
|
-
const identityObject = getIdentityFixture().toObject();
|
|
52
|
+
const identityObject = (await getIdentityFixture()).toObject();
|
|
53
53
|
identityObject.id = instantAssetLockProof.createIdentifier();
|
|
54
54
|
|
|
55
55
|
identity = new Identity(identityObject);
|
|
@@ -191,8 +191,8 @@ describe('IdentityFactory', () => {
|
|
|
191
191
|
});
|
|
192
192
|
|
|
193
193
|
describe('createChainAssetLockProof', () => {
|
|
194
|
-
it('should create IdentityCreateTransition from Identity model', () => {
|
|
195
|
-
const identityObject = getIdentityFixture().toObject();
|
|
194
|
+
it('should create IdentityCreateTransition from Identity model', async () => {
|
|
195
|
+
const identityObject = (await getIdentityFixture()).toObject();
|
|
196
196
|
identityObject.id = chainAssetLockProof.createIdentifier();
|
|
197
197
|
identity = new Identity(identityObject);
|
|
198
198
|
identity.setAssetLockProof(chainAssetLockProof);
|
package/test/unit/identity/stateTransition/IdentityCreateTransition/IdentityCreateTransition.spec.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const getIdentityCreateTransitionFixture = require('
|
|
2
|
-
const getChainAssetLockProofFixture = require('
|
|
1
|
+
const getIdentityCreateTransitionFixture = require('../../../../../lib/test/fixtures/getIdentityCreateTransitionFixture');
|
|
2
|
+
const getChainAssetLockProofFixture = require('../../../../../lib/test/fixtures/getChainAssetLockProofFixture');
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const { default: loadWasmDpp } = require('../../../../../dist');
|
|
4
|
+
const { default: loadWasmDpp } = require('../../../../..');
|
|
5
|
+
const { getLatestProtocolVersion, StateTransitionTypes } = require('../../../../..');
|
|
7
6
|
|
|
8
7
|
describe('IdentityCreateTransition', () => {
|
|
9
8
|
let rawStateTransition;
|
|
@@ -39,8 +38,8 @@ describe('IdentityCreateTransition', () => {
|
|
|
39
38
|
} = await loadWasmDpp());
|
|
40
39
|
});
|
|
41
40
|
|
|
42
|
-
beforeEach(() => {
|
|
43
|
-
rawStateTransition = getIdentityCreateTransitionFixture().toObject();
|
|
41
|
+
beforeEach(async () => {
|
|
42
|
+
rawStateTransition = (await getIdentityCreateTransitionFixture()).toObject();
|
|
44
43
|
stateTransition = new IdentityCreateTransition(
|
|
45
44
|
rawStateTransition,
|
|
46
45
|
);
|
|
@@ -68,7 +67,7 @@ describe('IdentityCreateTransition', () => {
|
|
|
68
67
|
|
|
69
68
|
describe('#getType', () => {
|
|
70
69
|
it('should return IDENTITY_CREATE type', () => {
|
|
71
|
-
expect(stateTransition.getType()).to.equal(
|
|
70
|
+
expect(stateTransition.getType()).to.equal(StateTransitionTypes.IdentityCreate);
|
|
72
71
|
});
|
|
73
72
|
});
|
|
74
73
|
|
|
@@ -159,8 +158,8 @@ describe('IdentityCreateTransition', () => {
|
|
|
159
158
|
rawStateTransition = stateTransition.toObject();
|
|
160
159
|
|
|
161
160
|
expect(rawStateTransition).to.deep.equal({
|
|
162
|
-
protocolVersion:
|
|
163
|
-
type:
|
|
161
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
162
|
+
type: StateTransitionTypes.IdentityCreate,
|
|
164
163
|
assetLockProof: rawStateTransition.assetLockProof,
|
|
165
164
|
publicKeys: rawStateTransition.publicKeys,
|
|
166
165
|
signature: undefined,
|
|
@@ -171,8 +170,8 @@ describe('IdentityCreateTransition', () => {
|
|
|
171
170
|
rawStateTransition = stateTransition.toObject({ skipSignature: true });
|
|
172
171
|
|
|
173
172
|
expect(rawStateTransition).to.deep.equal({
|
|
174
|
-
protocolVersion:
|
|
175
|
-
type:
|
|
173
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
174
|
+
type: StateTransitionTypes.IdentityCreate,
|
|
176
175
|
assetLockProof: rawStateTransition.assetLockProof,
|
|
177
176
|
publicKeys: rawStateTransition.publicKeys,
|
|
178
177
|
});
|
|
@@ -184,8 +183,8 @@ describe('IdentityCreateTransition', () => {
|
|
|
184
183
|
const jsonStateTransition = stateTransition.toJSON();
|
|
185
184
|
|
|
186
185
|
expect(jsonStateTransition).to.deep.equal({
|
|
187
|
-
protocolVersion:
|
|
188
|
-
type:
|
|
186
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
187
|
+
type: StateTransitionTypes.IdentityCreate,
|
|
189
188
|
assetLockProof: stateTransition.getAssetLockProof().toJSON(),
|
|
190
189
|
publicKeys: stateTransition.getPublicKeys().map((k) => k.toJSON()),
|
|
191
190
|
signature: undefined,
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
const getIdentityCreateTransitionFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityCreateTransitionFixture');
|
|
2
|
-
|
|
3
1
|
const { convertSatoshiToCredits } = require('@dashevo/dpp/lib/identity/creditsConverter');
|
|
4
2
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const protocolVersion = require('@dashevo/dpp/lib/version/protocolVersion');
|
|
3
|
+
const getIdentityCreateTransitionFixture = require('../../../../../lib/test/fixtures/getIdentityCreateTransitionFixture');
|
|
4
|
+
const createStateRepositoryMock = require('../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
8
5
|
|
|
9
|
-
const { default: loadWasmDpp } = require('
|
|
6
|
+
const { default: loadWasmDpp } = require('../../../../..');
|
|
7
|
+
const { getLatestProtocolVersion } = require('../../../../..');
|
|
10
8
|
|
|
11
9
|
describe('applyIdentityCreateTransitionFactory', () => {
|
|
12
10
|
let stateTransition;
|
|
@@ -16,7 +14,6 @@ describe('applyIdentityCreateTransitionFactory', () => {
|
|
|
16
14
|
let executionContext;
|
|
17
15
|
|
|
18
16
|
let StateTransitionExecutionContext;
|
|
19
|
-
let IdentityCreateTransition;
|
|
20
17
|
let Identity;
|
|
21
18
|
|
|
22
19
|
let applyIdentityCreateTransitionDPP;
|
|
@@ -24,21 +21,18 @@ describe('applyIdentityCreateTransitionFactory', () => {
|
|
|
24
21
|
before(async () => {
|
|
25
22
|
({
|
|
26
23
|
StateTransitionExecutionContext,
|
|
27
|
-
IdentityCreateTransition,
|
|
28
24
|
applyIdentityCreateTransition: applyIdentityCreateTransitionDPP,
|
|
29
25
|
Identity,
|
|
30
26
|
} = await loadWasmDpp());
|
|
31
27
|
});
|
|
32
28
|
|
|
33
|
-
beforeEach(function beforeEach() {
|
|
29
|
+
beforeEach(async function beforeEach() {
|
|
34
30
|
stateRepositoryMock = createStateRepositoryMock(this.sinonSandbox);
|
|
35
31
|
stateRepositoryMock.createIdentity.resolves();
|
|
36
32
|
stateRepositoryMock.addToSystemCredits.resolves();
|
|
37
33
|
stateRepositoryMock.markAssetLockTransactionOutPointAsUsed.resolves();
|
|
38
34
|
|
|
39
|
-
stateTransition =
|
|
40
|
-
getIdentityCreateTransitionFixture().toObject(),
|
|
41
|
-
);
|
|
35
|
+
stateTransition = await getIdentityCreateTransitionFixture();
|
|
42
36
|
|
|
43
37
|
executionContext = new StateTransitionExecutionContext();
|
|
44
38
|
|
|
@@ -60,7 +54,7 @@ describe('applyIdentityCreateTransitionFactory', () => {
|
|
|
60
54
|
);
|
|
61
55
|
|
|
62
56
|
const identity = new Identity({
|
|
63
|
-
protocolVersion:
|
|
57
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
64
58
|
id: stateTransition.getIdentityId(),
|
|
65
59
|
publicKeys: stateTransition.getPublicKeys()
|
|
66
60
|
.map((key) => key.toObject({ skipSignature: true })),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const getIdentityCreateTransitionFixture = require('
|
|
1
|
+
const getIdentityCreateTransitionFixture = require('../../../../../../../lib/test/fixtures/getIdentityCreateTransitionFixture');
|
|
2
2
|
|
|
3
|
-
const createStateRepositoryMock = require('
|
|
3
|
+
const createStateRepositoryMock = require('../../../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
4
4
|
|
|
5
5
|
const { default: loadWasmDpp } = require('../../../../../../../dist');
|
|
6
6
|
const { expectValidationError } = require('../../../../../../../lib/test/expect/expectError');
|
|
@@ -10,14 +10,12 @@ describe('validateIdentityCreateTransitionStateFactory', () => {
|
|
|
10
10
|
let stateTransition;
|
|
11
11
|
let stateRepositoryMock;
|
|
12
12
|
|
|
13
|
-
let IdentityCreateTransition;
|
|
14
13
|
let IdentityPublicKey;
|
|
15
14
|
let IdentityAlreadyExistsError;
|
|
16
15
|
let IdentityCreateTransitionStateValidator;
|
|
17
16
|
|
|
18
17
|
before(async () => {
|
|
19
18
|
({
|
|
20
|
-
IdentityCreateTransition,
|
|
21
19
|
IdentityAlreadyExistsError,
|
|
22
20
|
IdentityPublicKey,
|
|
23
21
|
IdentityCreateTransitionStateValidator,
|
|
@@ -31,9 +29,7 @@ describe('validateIdentityCreateTransitionStateFactory', () => {
|
|
|
31
29
|
const validator = new IdentityCreateTransitionStateValidator(stateRepositoryMock);
|
|
32
30
|
validateIdentityCreateTransitionState = (st) => validator.validate(st);
|
|
33
31
|
|
|
34
|
-
stateTransition =
|
|
35
|
-
getIdentityCreateTransitionFixture().toObject(),
|
|
36
|
-
);
|
|
32
|
+
stateTransition = await getIdentityCreateTransitionFixture();
|
|
37
33
|
|
|
38
34
|
await stateTransition.signByPrivateKey(privateKey, IdentityPublicKey.TYPES.ECDSA_SECP256K1);
|
|
39
35
|
|
package/test/unit/identity/stateTransition/IdentityTopUpTransition/IdentityTopUpTransition.spec.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const getIdentityTopUpTransitionFixture = require('
|
|
2
|
-
const getChainAssetLockProofFixture = require('
|
|
1
|
+
const getIdentityTopUpTransitionFixture = require('../../../../../lib/test/fixtures/getIdentityTopUpTransitionFixture');
|
|
2
|
+
const getChainAssetLockProofFixture = require('../../../../../lib/test/fixtures/getChainAssetLockProofFixture');
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const { default: loadWasmDpp } = require('../../../../../dist');
|
|
4
|
+
const { default: loadWasmDpp } = require('../../../../..');
|
|
5
|
+
const { getLatestProtocolVersion, StateTransitionTypes } = require('../../../../..');
|
|
7
6
|
|
|
8
7
|
describe('IdentityTopUpTransition', () => {
|
|
9
8
|
let rawStateTransition;
|
|
@@ -19,8 +18,8 @@ describe('IdentityTopUpTransition', () => {
|
|
|
19
18
|
} = await loadWasmDpp());
|
|
20
19
|
});
|
|
21
20
|
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
rawStateTransition = getIdentityTopUpTransitionFixture().toObject();
|
|
21
|
+
beforeEach(async () => {
|
|
22
|
+
rawStateTransition = (await getIdentityTopUpTransitionFixture()).toObject();
|
|
24
23
|
|
|
25
24
|
stateTransition = new IdentityTopUpTransition(
|
|
26
25
|
rawStateTransition,
|
|
@@ -47,7 +46,7 @@ describe('IdentityTopUpTransition', () => {
|
|
|
47
46
|
|
|
48
47
|
describe('#getType', () => {
|
|
49
48
|
it('should return IDENTITY_TOP_UP type', () => {
|
|
50
|
-
expect(stateTransition.getType()).to.equal(
|
|
49
|
+
expect(stateTransition.getType()).to.equal(StateTransitionTypes.IdentityTopUp);
|
|
51
50
|
});
|
|
52
51
|
});
|
|
53
52
|
|
|
@@ -91,8 +90,8 @@ describe('IdentityTopUpTransition', () => {
|
|
|
91
90
|
rawStateTransition = stateTransition.toObject();
|
|
92
91
|
|
|
93
92
|
expect(rawStateTransition).to.deep.equal({
|
|
94
|
-
protocolVersion:
|
|
95
|
-
type:
|
|
93
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
94
|
+
type: StateTransitionTypes.IdentityTopUp,
|
|
96
95
|
assetLockProof: rawStateTransition.assetLockProof,
|
|
97
96
|
identityId: rawStateTransition.identityId,
|
|
98
97
|
signature: undefined,
|
|
@@ -103,8 +102,8 @@ describe('IdentityTopUpTransition', () => {
|
|
|
103
102
|
rawStateTransition = stateTransition.toObject({ skipSignature: true });
|
|
104
103
|
|
|
105
104
|
expect(rawStateTransition).to.deep.equal({
|
|
106
|
-
protocolVersion:
|
|
107
|
-
type:
|
|
105
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
106
|
+
type: StateTransitionTypes.IdentityTopUp,
|
|
108
107
|
assetLockProof: rawStateTransition.assetLockProof,
|
|
109
108
|
identityId: rawStateTransition.identityId,
|
|
110
109
|
});
|
|
@@ -116,8 +115,8 @@ describe('IdentityTopUpTransition', () => {
|
|
|
116
115
|
const jsonStateTransition = stateTransition.toJSON();
|
|
117
116
|
|
|
118
117
|
expect(jsonStateTransition).to.deep.equal({
|
|
119
|
-
protocolVersion:
|
|
120
|
-
type:
|
|
118
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
119
|
+
type: StateTransitionTypes.IdentityTopUp,
|
|
121
120
|
assetLockProof: stateTransition.getAssetLockProof().toJSON(),
|
|
122
121
|
identityId: new Identifier(rawStateTransition.identityId).toString(),
|
|
123
122
|
signature: undefined,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const getIdentityTopUpTransitionFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityTopUpTransitionFixture');
|
|
2
|
-
|
|
3
1
|
const { convertSatoshiToCredits } = require('@dashevo/dpp/lib/identity/creditsConverter');
|
|
4
2
|
|
|
5
|
-
const
|
|
3
|
+
const getIdentityTopUpTransitionFixture = require('../../../../../lib/test/fixtures/getIdentityTopUpTransitionFixture');
|
|
4
|
+
|
|
5
|
+
const createStateRepositoryMock = require('../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
6
6
|
|
|
7
|
-
const { default: loadWasmDpp } = require('
|
|
7
|
+
const { default: loadWasmDpp } = require('../../../../..');
|
|
8
8
|
|
|
9
9
|
describe('applyIdentityTopUpTransitionFactory', () => {
|
|
10
10
|
let stateTransition;
|
|
@@ -13,14 +13,12 @@ describe('applyIdentityTopUpTransitionFactory', () => {
|
|
|
13
13
|
let executionContext;
|
|
14
14
|
|
|
15
15
|
let StateTransitionExecutionContext;
|
|
16
|
-
let IdentityTopUpTransition;
|
|
17
16
|
|
|
18
17
|
let applyIdentityTopUpTransitionDPP;
|
|
19
18
|
|
|
20
19
|
before(async () => {
|
|
21
20
|
({
|
|
22
21
|
StateTransitionExecutionContext,
|
|
23
|
-
IdentityTopUpTransition,
|
|
24
22
|
applyIdentityTopUpTransition: applyIdentityTopUpTransitionDPP,
|
|
25
23
|
} = await loadWasmDpp());
|
|
26
24
|
});
|
|
@@ -39,9 +37,7 @@ describe('applyIdentityTopUpTransitionFactory', () => {
|
|
|
39
37
|
height: 42,
|
|
40
38
|
});
|
|
41
39
|
|
|
42
|
-
stateTransition =
|
|
43
|
-
getIdentityTopUpTransitionFixture().toObject(),
|
|
44
|
-
);
|
|
40
|
+
stateTransition = await getIdentityTopUpTransitionFixture();
|
|
45
41
|
|
|
46
42
|
executionContext = new StateTransitionExecutionContext();
|
|
47
43
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const getIdentityTopUpTransitionFixture = require('
|
|
1
|
+
const getIdentityTopUpTransitionFixture = require('../../../../../../../lib/test/fixtures/getIdentityTopUpTransitionFixture');
|
|
2
2
|
|
|
3
|
-
const createStateRepositoryMock = require('
|
|
3
|
+
const createStateRepositoryMock = require('../../../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
4
4
|
const { default: loadWasmDpp } = require('../../../../../../../dist');
|
|
5
5
|
|
|
6
6
|
describe('validateIdentityTopUpTransitionStateFactory', () => {
|
|
@@ -8,22 +8,18 @@ describe('validateIdentityTopUpTransitionStateFactory', () => {
|
|
|
8
8
|
let stateTransition;
|
|
9
9
|
let stateRepositoryMock;
|
|
10
10
|
|
|
11
|
-
let IdentityTopUpTransition;
|
|
12
11
|
let IdentityTopUpTransitionStateValidator;
|
|
13
12
|
|
|
14
13
|
before(async () => {
|
|
15
14
|
({
|
|
16
|
-
IdentityTopUpTransition,
|
|
17
15
|
IdentityTopUpTransitionStateValidator,
|
|
18
16
|
} = await loadWasmDpp());
|
|
19
17
|
});
|
|
20
18
|
|
|
21
|
-
beforeEach(function () {
|
|
19
|
+
beforeEach(async function () {
|
|
22
20
|
stateRepositoryMock = createStateRepositoryMock(this.sinonSandbox);
|
|
23
21
|
|
|
24
|
-
stateTransition =
|
|
25
|
-
getIdentityTopUpTransitionFixture().toObject(),
|
|
26
|
-
);
|
|
22
|
+
stateTransition = await getIdentityTopUpTransitionFixture();
|
|
27
23
|
|
|
28
24
|
const validator = new IdentityTopUpTransitionStateValidator(stateRepositoryMock);
|
|
29
25
|
|