@dashevo/wasm-dpp 0.25.0-dev.11 → 0.25.0-dev.13
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 +6 -5
- package/dist/wasm/wasm_dpp.d.ts +685 -639
- package/dist/wasm/wasm_dpp.js +64 -50
- 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 +685 -639
- package/package.json +4 -4
- package/scripts/build-wasm.sh +26 -29
- package/src/data_contract/data_contract.rs +99 -54
- package/src/data_contract/data_contract_facade.rs +5 -2
- package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +0 -5
- package/src/data_contract_factory/data_contract_factory.rs +5 -1
- package/src/document/mod.rs +4 -4
- package/src/errors/consensus/consensus_error.rs +5 -0
- package/src/errors/consensus/state/document/document_timestamps_are_equal_error.rs +42 -0
- package/src/errors/consensus/state/document/mod.rs +2 -0
- package/src/errors/value_error.rs +5 -0
- package/src/identity/identity_public_key/mod.rs +1 -1
- package/src/identity/mod.rs +8 -1
- package/src/identity/state_transition/mod.rs +1 -0
- package/src/identity/state_transition/transition_types.rs +30 -0
- package/src/lib.rs +1 -2
- 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 +6 -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 +5 -5
- 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 +9 -9
- package/test/unit/dataContract/DataContractFactory.spec.js +3 -3
- package/test/unit/dataContract/createDataContract.spec.js +5 -5
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +14 -14
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/applyDataContractCreateTransitionFactory.spec.js +6 -8
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/validation/state/validateDataContractCreateTransitionStateFactory.spec.js +3 -3
- 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 +5 -5
- 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 +14 -6
- package/test/unit/identity/IdentityFactory.spec.js +11 -11
- package/test/unit/identity/IdentityPublicKey.spec.js +2 -2
- 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/src/decode_protocol_entity.rs +0 -25
- 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/decodeProtocolEntityFactory.spec.js +0 -72
- package/test/unit/identity/errors/InvalidIdentityError.spec.js +0 -46
- package/test/unit/stateTransition/errors/InvalidStateTransitionError.spec.js +0 -51
|
@@ -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]);
|
|
@@ -221,7 +220,7 @@ describe('applyDocumentsBatchTransitionFactory', () => {
|
|
|
221
220
|
});
|
|
222
221
|
|
|
223
222
|
stateTransition = new DocumentsBatchTransition({
|
|
224
|
-
protocolVersion:
|
|
223
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
225
224
|
ownerId,
|
|
226
225
|
transitions: documentTransitionsJs.map((t) => t.toObject()),
|
|
227
226
|
}, [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;
|
|
@@ -263,7 +263,7 @@ describe('validateDocumentsBatchTransitionStateFactory', () => {
|
|
|
263
263
|
replaceDocument.setRevision(1);
|
|
264
264
|
|
|
265
265
|
const fetchedDocument = new ExtendedDocument(documentsJs[0].toObject(), dataContract);
|
|
266
|
-
fetchedDocument.setOwnerId(Identifier.from(generateRandomIdentifier().toBuffer()));
|
|
266
|
+
fetchedDocument.setOwnerId(Identifier.from((await generateRandomIdentifier()).toBuffer()));
|
|
267
267
|
|
|
268
268
|
documentTransitionsJs = getDocumentTransitionsFixture({
|
|
269
269
|
create: [],
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const varint = require('varint');
|
|
2
|
-
const JSIdentityPublicKey = require('@dashevo/dpp/lib/identity/IdentityPublicKey');
|
|
3
|
-
const protocolVersion = require('@dashevo/dpp/lib/version/protocolVersion');
|
|
4
2
|
|
|
5
3
|
const { hash: hashFunction } = require('@dashevo/dpp/lib/util/hash');
|
|
6
4
|
const { expect } = require('chai');
|
|
7
5
|
const generateRandomIdentifierAsync = require('../../../lib/test/utils/generateRandomIdentifierAsync');
|
|
8
|
-
const { default: loadWasmDpp } = require('
|
|
6
|
+
const { default: loadWasmDpp } = require('../../..');
|
|
7
|
+
const { getLatestProtocolVersion } = require('../../..');
|
|
9
8
|
|
|
10
9
|
describe('Identity', () => {
|
|
11
10
|
let rawIdentity;
|
|
@@ -26,7 +25,7 @@ describe('Identity', () => {
|
|
|
26
25
|
|
|
27
26
|
beforeEach(async () => {
|
|
28
27
|
rawIdentity = {
|
|
29
|
-
protocolVersion:
|
|
28
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
30
29
|
id: await generateRandomIdentifierAsync(),
|
|
31
30
|
publicKeys: [
|
|
32
31
|
{
|
|
@@ -108,7 +107,7 @@ describe('Identity', () => {
|
|
|
108
107
|
readOnly: false,
|
|
109
108
|
};
|
|
110
109
|
|
|
111
|
-
const ipk = new
|
|
110
|
+
const ipk = new IdentityPublicKey(rawKey);
|
|
112
111
|
|
|
113
112
|
identity.setPublicKeys([ipk]);
|
|
114
113
|
expect(identity.getPublicKeys()).length(1);
|
|
@@ -141,6 +140,15 @@ describe('Identity', () => {
|
|
|
141
140
|
});
|
|
142
141
|
});
|
|
143
142
|
|
|
143
|
+
describe('#fromBuffer', () => {
|
|
144
|
+
it('should re-create identity from buffer', () => {
|
|
145
|
+
const buffer = identity.toBuffer();
|
|
146
|
+
const recoveredIdentity = Identity.fromBuffer(buffer);
|
|
147
|
+
expect(recoveredIdentity.toObject())
|
|
148
|
+
.to.be.deep.equal(identity.toObject());
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
144
152
|
describe('#hash', () => {
|
|
145
153
|
it('should return the same has as JS Identity', () => {
|
|
146
154
|
const expectedHash = hashFunction(identity.toBuffer());
|
|
@@ -171,7 +179,7 @@ describe('Identity', () => {
|
|
|
171
179
|
const jsonIdentity = identity.toJSON();
|
|
172
180
|
|
|
173
181
|
expect(jsonIdentity).to.deep.equal({
|
|
174
|
-
protocolVersion:
|
|
182
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
175
183
|
id: rawIdentity.id.toString(),
|
|
176
184
|
publicKeys: [
|
|
177
185
|
{
|
|
@@ -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
|
|
4
|
+
const { default: loadWasmDpp } = require('../../..');
|
|
5
|
+
const { IdentityPublicKey, SerializedObjectParsingError } = require('../../..');
|
|
6
6
|
const getBlsAdapterMock = require('../../../lib/test/mocks/getBlsAdapterMock');
|
|
7
7
|
|
|
8
8
|
describe('IdentityFactory', () => {
|
|
@@ -34,10 +34,10 @@ describe('IdentityFactory', () => {
|
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
beforeEach(async function () {
|
|
37
|
-
const instantAssetLockProofJS =
|
|
38
|
-
const chainAssetLockProofJS =
|
|
39
|
-
instantAssetLockProof =
|
|
40
|
-
chainAssetLockProof = new ChainAssetLockProof(
|
|
37
|
+
// const instantAssetLockProofJS = ;
|
|
38
|
+
// const chainAssetLockProofJS = ;
|
|
39
|
+
instantAssetLockProof = await getInstantAssetLockProofFixture();
|
|
40
|
+
chainAssetLockProof = new ChainAssetLockProof(getChainAssetLockProofFixture().toObject());
|
|
41
41
|
|
|
42
42
|
const blsAdapter = await getBlsAdapterMock();
|
|
43
43
|
|
|
@@ -48,7 +48,7 @@ describe('IdentityFactory', () => {
|
|
|
48
48
|
identityValidator,
|
|
49
49
|
);
|
|
50
50
|
|
|
51
|
-
const identityObject = getIdentityFixture().toObject();
|
|
51
|
+
const identityObject = (await getIdentityFixture()).toObject();
|
|
52
52
|
identityObject.id = instantAssetLockProof.createIdentifier();
|
|
53
53
|
|
|
54
54
|
identity = new Identity(identityObject);
|
|
@@ -190,8 +190,8 @@ describe('IdentityFactory', () => {
|
|
|
190
190
|
});
|
|
191
191
|
|
|
192
192
|
describe('createChainAssetLockProof', () => {
|
|
193
|
-
it('should create IdentityCreateTransition from Identity model', () => {
|
|
194
|
-
const identityObject = getIdentityFixture().toObject();
|
|
193
|
+
it('should create IdentityCreateTransition from Identity model', async () => {
|
|
194
|
+
const identityObject = (await getIdentityFixture()).toObject();
|
|
195
195
|
identityObject.id = chainAssetLockProof.createIdentifier();
|
|
196
196
|
identity = new Identity(identityObject);
|
|
197
197
|
identity.setAssetLockProof(chainAssetLockProof);
|
|
@@ -148,7 +148,7 @@ describe('IdentityPublicKey', () => {
|
|
|
148
148
|
rawPublicKey = {
|
|
149
149
|
id: 0,
|
|
150
150
|
type: IdentityPublicKey.TYPES.ECDSA_HASH160,
|
|
151
|
-
data: Buffer.from('
|
|
151
|
+
data: Buffer.from('AkVuTKyF3YgKLAQlLEtaUL2HTdi', 'base64'),
|
|
152
152
|
purpose: IdentityPublicKey.PURPOSES.AUTHENTICATION,
|
|
153
153
|
securityLevel: IdentityPublicKey.SECURITY_LEVELS.MASTER,
|
|
154
154
|
readOnly: false,
|
|
@@ -159,7 +159,7 @@ describe('IdentityPublicKey', () => {
|
|
|
159
159
|
|
|
160
160
|
const result = publicKey.hash();
|
|
161
161
|
|
|
162
|
-
const expectedHash = Buffer.from('
|
|
162
|
+
const expectedHash = Buffer.from('AkVuTKyF3YgKLAQlLEtaUL2HTdg=', 'base64');
|
|
163
163
|
|
|
164
164
|
expect(result).to.deep.equal(expectedHash);
|
|
165
165
|
});
|
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
|
|
|
@@ -59,7 +53,7 @@ describe('applyIdentityCreateTransitionFactory', () => {
|
|
|
59
53
|
);
|
|
60
54
|
|
|
61
55
|
const identity = new Identity({
|
|
62
|
-
protocolVersion:
|
|
56
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
63
57
|
id: stateTransition.getIdentityId(),
|
|
64
58
|
publicKeys: stateTransition.getPublicKeys()
|
|
65
59
|
.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');
|
|
@@ -11,7 +11,6 @@ describe('validateIdentityCreateTransitionStateFactory', () => {
|
|
|
11
11
|
let stateRepositoryMock;
|
|
12
12
|
let executionContext;
|
|
13
13
|
|
|
14
|
-
let IdentityCreateTransition;
|
|
15
14
|
let IdentityPublicKey;
|
|
16
15
|
let IdentityAlreadyExistsError;
|
|
17
16
|
let IdentityCreateTransitionStateValidator;
|
|
@@ -19,7 +18,6 @@ describe('validateIdentityCreateTransitionStateFactory', () => {
|
|
|
19
18
|
|
|
20
19
|
before(async () => {
|
|
21
20
|
({
|
|
22
|
-
IdentityCreateTransition,
|
|
23
21
|
IdentityAlreadyExistsError,
|
|
24
22
|
IdentityPublicKey,
|
|
25
23
|
IdentityCreateTransitionStateValidator,
|
|
@@ -35,9 +33,7 @@ describe('validateIdentityCreateTransitionStateFactory', () => {
|
|
|
35
33
|
const validator = new IdentityCreateTransitionStateValidator(stateRepositoryMock);
|
|
36
34
|
validateIdentityCreateTransitionState = (st) => validator.validate(st, executionContext);
|
|
37
35
|
|
|
38
|
-
stateTransition =
|
|
39
|
-
getIdentityCreateTransitionFixture().toObject(),
|
|
40
|
-
);
|
|
36
|
+
stateTransition = await getIdentityCreateTransitionFixture();
|
|
41
37
|
|
|
42
38
|
await stateTransition.signByPrivateKey(privateKey, IdentityPublicKey.TYPES.ECDSA_SECP256K1);
|
|
43
39
|
|
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', () => {
|
|
@@ -9,24 +9,20 @@ describe('validateIdentityTopUpTransitionStateFactory', () => {
|
|
|
9
9
|
let stateRepositoryMock;
|
|
10
10
|
let executionContext;
|
|
11
11
|
|
|
12
|
-
let IdentityTopUpTransition;
|
|
13
12
|
let IdentityTopUpTransitionStateValidator;
|
|
14
13
|
let StateTransitionExecutionContext;
|
|
15
14
|
|
|
16
15
|
before(async () => {
|
|
17
16
|
({
|
|
18
|
-
IdentityTopUpTransition,
|
|
19
17
|
IdentityTopUpTransitionStateValidator,
|
|
20
18
|
StateTransitionExecutionContext,
|
|
21
19
|
} = await loadWasmDpp());
|
|
22
20
|
});
|
|
23
21
|
|
|
24
|
-
beforeEach(function () {
|
|
22
|
+
beforeEach(async function () {
|
|
25
23
|
stateRepositoryMock = createStateRepositoryMock(this.sinonSandbox);
|
|
26
24
|
|
|
27
|
-
stateTransition =
|
|
28
|
-
getIdentityTopUpTransitionFixture().toObject(),
|
|
29
|
-
);
|
|
25
|
+
stateTransition = await getIdentityTopUpTransitionFixture();
|
|
30
26
|
|
|
31
27
|
const validator = new IdentityTopUpTransitionStateValidator(stateRepositoryMock);
|
|
32
28
|
|
package/test/unit/identity/stateTransition/IdentityUpdateTransition/IdentityUpdateTransition.spec.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
const stateTransitionTypes = require(
|
|
2
|
-
'@dashevo/dpp/lib/stateTransition/stateTransitionTypes',
|
|
3
|
-
);
|
|
4
|
-
|
|
5
|
-
const protocolVersion = require('@dashevo/dpp/lib/version/protocolVersion');
|
|
6
|
-
|
|
7
1
|
const getIdentityUpdateTransitionFixture = require('../../../../../lib/test/fixtures/getIdentityUpdateTransitionFixture');
|
|
8
2
|
|
|
9
|
-
const { default: loadWasmDpp } = require('
|
|
3
|
+
const { default: loadWasmDpp } = require('../../../../..');
|
|
4
|
+
const { getLatestProtocolVersion, StateTransitionTypes } = require('../../../../..');
|
|
10
5
|
const generateRandomIdentifierAsync = require('../../../../../lib/test/utils/generateRandomIdentifierAsync');
|
|
11
6
|
|
|
12
7
|
describe('IdentityUpdateTransition', () => {
|
|
@@ -32,7 +27,7 @@ describe('IdentityUpdateTransition', () => {
|
|
|
32
27
|
|
|
33
28
|
describe('#getType', () => {
|
|
34
29
|
it('should return IDENTITY_UPDATE type', () => {
|
|
35
|
-
expect(stateTransition.getType()).to.equal(
|
|
30
|
+
expect(stateTransition.getType()).to.equal(StateTransitionTypes.IdentityUpdate);
|
|
36
31
|
});
|
|
37
32
|
});
|
|
38
33
|
|
|
@@ -143,8 +138,8 @@ describe('IdentityUpdateTransition', () => {
|
|
|
143
138
|
rawStateTransition = stateTransition.toObject();
|
|
144
139
|
|
|
145
140
|
expect(rawStateTransition).to.deep.equal({
|
|
146
|
-
protocolVersion:
|
|
147
|
-
type:
|
|
141
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
142
|
+
type: StateTransitionTypes.IdentityUpdate,
|
|
148
143
|
signature: undefined,
|
|
149
144
|
identityId: rawStateTransition.identityId,
|
|
150
145
|
revision: rawStateTransition.revision,
|
|
@@ -159,8 +154,8 @@ describe('IdentityUpdateTransition', () => {
|
|
|
159
154
|
rawStateTransition = stateTransition.toObject({ skipSignature: true });
|
|
160
155
|
|
|
161
156
|
expect(rawStateTransition).to.deep.equal({
|
|
162
|
-
protocolVersion:
|
|
163
|
-
type:
|
|
157
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
158
|
+
type: StateTransitionTypes.IdentityUpdate,
|
|
164
159
|
identityId: rawStateTransition.identityId,
|
|
165
160
|
revision: rawStateTransition.revision,
|
|
166
161
|
publicKeysDisabledAt: rawStateTransition.publicKeysDisabledAt,
|
|
@@ -177,8 +172,8 @@ describe('IdentityUpdateTransition', () => {
|
|
|
177
172
|
rawStateTransition = stateTransition.toObject();
|
|
178
173
|
|
|
179
174
|
expect(rawStateTransition).to.deep.equal({
|
|
180
|
-
protocolVersion:
|
|
181
|
-
type:
|
|
175
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
176
|
+
type: StateTransitionTypes.IdentityUpdate,
|
|
182
177
|
signature: undefined,
|
|
183
178
|
identityId: rawStateTransition.identityId,
|
|
184
179
|
revision: rawStateTransition.revision,
|
|
@@ -192,8 +187,8 @@ describe('IdentityUpdateTransition', () => {
|
|
|
192
187
|
const jsonStateTransition = stateTransition.toJSON();
|
|
193
188
|
|
|
194
189
|
expect(jsonStateTransition).to.deep.equal({
|
|
195
|
-
protocolVersion:
|
|
196
|
-
type:
|
|
190
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
191
|
+
type: StateTransitionTypes.IdentityUpdate,
|
|
197
192
|
signature: undefined,
|
|
198
193
|
identityId: stateTransition.getIdentityId().toString(),
|
|
199
194
|
revision: rawStateTransition.revision,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const createStateRepositoryMock = require('
|
|
1
|
+
const createStateRepositoryMock = require('../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
2
2
|
const getIdentityUpdateTransitionFixture = require('../../../../../lib/test/fixtures/getIdentityUpdateTransitionFixture');
|
|
3
3
|
|
|
4
4
|
const { default: loadWasmDpp } = require('../../../../../dist');
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const getDataContractFixture = require('../../../lib/test/fixtures/getDataContractFixture');
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const createStateRepositoryMock = require('../../../lib/test/mocks/createStateRepositoryMock');
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const { default: loadWasmDpp } = require('../../../dist');
|
|
5
|
+
const { default: loadWasmDpp } = require('../../..');
|
|
6
|
+
const { getLatestProtocolVersion } = require('../../..');
|
|
8
7
|
const getBlsAdapterMock = require('../../../lib/test/mocks/getBlsAdapterMock');
|
|
9
8
|
|
|
10
9
|
describe('StateTransitionFactory', function main() {
|
|
@@ -29,12 +28,12 @@ describe('StateTransitionFactory', function main() {
|
|
|
29
28
|
});
|
|
30
29
|
|
|
31
30
|
beforeEach(async function beforeEach() {
|
|
32
|
-
const dataContract = getDataContractFixture();
|
|
31
|
+
const dataContract = await getDataContractFixture();
|
|
33
32
|
|
|
34
33
|
const rawDataContract = dataContract.toObject();
|
|
35
34
|
|
|
36
35
|
stateTransition = new DataContractCreateTransition({
|
|
37
|
-
protocolVersion:
|
|
36
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
38
37
|
dataContract: rawDataContract,
|
|
39
38
|
entropy: dataContract.getEntropy(),
|
|
40
39
|
signature: Buffer.alloc(65),
|