@dashevo/wasm-dpp 0.24.0-dev.33 → 0.24.0
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 +4 -4
- 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,9 +1,8 @@
|
|
|
1
1
|
const DashCoreLib = require('@dashevo/dashcore-lib');
|
|
2
|
-
|
|
3
|
-
const getInstantAssetLockFixture = require('@dashevo/dpp/lib/test/fixtures/getInstantAssetLockProofFixture');
|
|
4
|
-
const createStateRepositoryMock = require('@dashevo/dpp/lib/test/mocks/createStateRepositoryMock');
|
|
5
|
-
|
|
6
2
|
const { expect } = require('chai');
|
|
3
|
+
|
|
4
|
+
const getInstantAssetLockFixture = require('../../../../../../lib/test/fixtures/js/getInstantAssetLockProofFixture');
|
|
5
|
+
const createStateRepositoryMock = require('../../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
7
6
|
const { expectJsonSchemaError, expectValidationError } = require('../../../../../../lib/test/expect/expectError');
|
|
8
7
|
|
|
9
8
|
const { default: loadWasmDpp } = require('../../../../../../dist');
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const { Transaction, PrivateKey, Script } = require('@dashevo/dashcore-lib');
|
|
2
|
-
|
|
3
|
-
const createStateRepositoryMock = require('@dashevo/dpp/lib/test/mocks/createStateRepositoryMock');
|
|
4
|
-
|
|
5
2
|
const { expect } = require('chai');
|
|
3
|
+
|
|
4
|
+
const createStateRepositoryMock = require('../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
6
5
|
const { default: loadWasmDpp } = require('../../../../../dist');
|
|
7
6
|
const { expectValidationError } = require('../../../../../lib/test/expect/expectError');
|
|
8
7
|
|
package/test/integration/identity/stateTransition/validatePublicKeySignaturesFactory.spec.js
CHANGED
|
@@ -2,10 +2,10 @@ const { PrivateKey, crypto: { Hash } } = require('@dashevo/dashcore-lib');
|
|
|
2
2
|
|
|
3
3
|
const crypto = require('crypto');
|
|
4
4
|
|
|
5
|
-
const getIdentityCreateTransitionFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityCreateTransitionFixture');
|
|
6
5
|
const BlsSignatures = require('@dashevo/dpp/lib/bls/bls');
|
|
7
6
|
|
|
8
7
|
const { expect } = require('chai');
|
|
8
|
+
const getIdentityCreateTransitionFixture = require('../../../../lib/test/fixtures/getIdentityCreateTransitionFixture');
|
|
9
9
|
const { expectValidationError } = require('../../../../lib/test/expect/expectError');
|
|
10
10
|
const getBlsAdapterMock = require('../../../../lib/test/mocks/getBlsAdapterMock');
|
|
11
11
|
|
|
@@ -16,7 +16,6 @@ describe('validatePublicKeySignaturesFactory', () => {
|
|
|
16
16
|
let rawIdentityCreateTransition;
|
|
17
17
|
let validatePublicKeySignatures;
|
|
18
18
|
|
|
19
|
-
let IdentityCreateTransition;
|
|
20
19
|
let IdentityPublicKey;
|
|
21
20
|
let IdentityPublicKeyWithWitness;
|
|
22
21
|
let InvalidIdentityKeySignatureError;
|
|
@@ -26,7 +25,6 @@ describe('validatePublicKeySignaturesFactory', () => {
|
|
|
26
25
|
|
|
27
26
|
before(async () => {
|
|
28
27
|
({
|
|
29
|
-
IdentityCreateTransition,
|
|
30
28
|
IdentityPublicKey,
|
|
31
29
|
IdentityPublicKeyWithWitness,
|
|
32
30
|
InvalidIdentityKeySignatureError,
|
|
@@ -36,9 +34,7 @@ describe('validatePublicKeySignaturesFactory', () => {
|
|
|
36
34
|
});
|
|
37
35
|
|
|
38
36
|
beforeEach(async () => {
|
|
39
|
-
identityCreateTransition =
|
|
40
|
-
getIdentityCreateTransitionFixture().toObject(),
|
|
41
|
-
);
|
|
37
|
+
identityCreateTransition = await getIdentityCreateTransitionFixture();
|
|
42
38
|
|
|
43
39
|
const privateKey1 = new PrivateKey('17e0b1703e226204c557bce68b0871683ea409ae90c7a733b72a33f7c129c959');
|
|
44
40
|
const publicKey1 = privateKey1.toPublicKey();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const getIdentityFixture = require('
|
|
1
|
+
const getIdentityFixture = require('../../../../lib/test/fixtures/getIdentityFixture');
|
|
2
2
|
const { expectValidationError, expectJsonSchemaError } = require('../../../../lib/test/expect/expectError');
|
|
3
3
|
|
|
4
4
|
const { default: loadWasmDpp } = require('../../../../dist');
|
|
@@ -18,16 +18,17 @@ describe('validateIdentityFactory', () => {
|
|
|
18
18
|
({ IdentityValidator, Identity, UnsupportedProtocolVersionError } = await loadWasmDpp());
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
beforeEach(async ()
|
|
21
|
+
beforeEach(async function () {
|
|
22
|
+
this.timeout(20000);
|
|
22
23
|
const blsAdapter = await getBlsAdapterMock();
|
|
23
24
|
|
|
24
25
|
const validator = new IdentityValidator(blsAdapter);
|
|
25
26
|
|
|
26
27
|
validateIdentity = (value) => validator.validate(value);
|
|
27
28
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
identity = new Identity(
|
|
29
|
+
const identityObject = (await getIdentityFixture()).toObject();
|
|
30
|
+
identityObject.id = await generateRandomIdentifierAsync();
|
|
31
|
+
identity = new Identity(identityObject);
|
|
31
32
|
|
|
32
33
|
rawIdentity = identity.toObject();
|
|
33
34
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const crypto = require('crypto');
|
|
2
2
|
|
|
3
|
-
const getIdentityFixture = require('
|
|
4
|
-
|
|
5
|
-
const BlsSignatures = require('@dashevo/dpp/lib/bls/bls');
|
|
3
|
+
const getIdentityFixture = require('../../../../lib/test/fixtures/getIdentityFixture');
|
|
4
|
+
const getBlsMock = require('../../../../lib/test/mocks/getBlsAdapterMock');
|
|
6
5
|
|
|
7
6
|
const {
|
|
8
7
|
expectValidationError,
|
|
@@ -16,7 +15,6 @@ describe('validatePublicKeysFactory', function main() {
|
|
|
16
15
|
|
|
17
16
|
let rawPublicKeys;
|
|
18
17
|
let validatePublicKeys;
|
|
19
|
-
let bls;
|
|
20
18
|
let publicKeysValidator;
|
|
21
19
|
|
|
22
20
|
let PublicKeysValidator;
|
|
@@ -28,7 +26,7 @@ describe('validatePublicKeysFactory', function main() {
|
|
|
28
26
|
let InvalidIdentityPublicKeySecurityLevelError;
|
|
29
27
|
|
|
30
28
|
beforeEach(async () => {
|
|
31
|
-
({ publicKeys: rawPublicKeys } = getIdentityFixture().toObject());
|
|
29
|
+
({ publicKeys: rawPublicKeys } = (await getIdentityFixture()).toObject());
|
|
32
30
|
|
|
33
31
|
({
|
|
34
32
|
PublicKeysValidator, IdentityPublicKey,
|
|
@@ -37,25 +35,7 @@ describe('validatePublicKeysFactory', function main() {
|
|
|
37
35
|
InvalidIdentityPublicKeyDataError, InvalidIdentityPublicKeySecurityLevelError,
|
|
38
36
|
} = await loadWasmDpp());
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const blsAdapter = {
|
|
43
|
-
validatePublicKey(publicKeyBuffer) {
|
|
44
|
-
let pk;
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
pk = bls.G1Element.fromBytes(publicKeyBuffer);
|
|
48
|
-
} catch (e) {
|
|
49
|
-
return false;
|
|
50
|
-
} finally {
|
|
51
|
-
if (pk) {
|
|
52
|
-
pk.delete();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return Boolean(pk);
|
|
57
|
-
},
|
|
58
|
-
};
|
|
38
|
+
const blsAdapter = await getBlsMock();
|
|
59
39
|
|
|
60
40
|
publicKeysValidator = new PublicKeysValidator(blsAdapter);
|
|
61
41
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const { PrivateKey } = require('@dashevo/dashcore-lib');
|
|
2
2
|
const crypto = require('crypto');
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const createStateRepositoryMock = require('../../../lib/test/mocks/createStateRepositoryMock');
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const getIdentityFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityFixture');
|
|
6
|
+
const getIdentityFixture = require('../../../lib/test/fixtures/getIdentityFixture');
|
|
7
|
+
const getIdentityCreateTransitionFixture = require('../../../lib/test/fixtures/getIdentityCreateTransitionFixture');
|
|
9
8
|
const getDocumentsFixture = require('../../../lib/test/fixtures/getDocumentsFixture');
|
|
10
9
|
const getDataContractFixture = require('../../../lib/test/fixtures/getDataContractFixture');
|
|
11
10
|
|
|
@@ -32,7 +31,6 @@ describe('StateTransitionFacade', () => {
|
|
|
32
31
|
let DocumentFactory;
|
|
33
32
|
let DocumentValidator;
|
|
34
33
|
let ProtocolVersionValidator;
|
|
35
|
-
let IdentityCreateTransition;
|
|
36
34
|
let UnsupportedProtocolVersionError;
|
|
37
35
|
let InvalidStateTransitionSignatureError;
|
|
38
36
|
let DataContractAlreadyPresentError;
|
|
@@ -50,7 +48,6 @@ describe('StateTransitionFacade', () => {
|
|
|
50
48
|
DocumentFactory,
|
|
51
49
|
DocumentValidator,
|
|
52
50
|
ProtocolVersionValidator,
|
|
53
|
-
IdentityCreateTransition,
|
|
54
51
|
UnsupportedProtocolVersionError,
|
|
55
52
|
InvalidStateTransitionSignatureError,
|
|
56
53
|
DataContractAlreadyPresentError,
|
|
@@ -59,11 +56,14 @@ describe('StateTransitionFacade', () => {
|
|
|
59
56
|
});
|
|
60
57
|
|
|
61
58
|
beforeEach(async function beforeEach() {
|
|
59
|
+
this.timeout(20000);
|
|
62
60
|
const privateKeyModel = new PrivateKey();
|
|
63
61
|
const privateKey = privateKeyModel.toBuffer();
|
|
64
62
|
const publicKey = privateKeyModel.toPublicKey().toBuffer();
|
|
65
63
|
const publicKeyId = 1;
|
|
66
64
|
|
|
65
|
+
stateRepositoryMock = createStateRepositoryMock(this.sinonSandbox);
|
|
66
|
+
|
|
67
67
|
identityPublicKey = new IdentityPublicKey({
|
|
68
68
|
id: publicKeyId,
|
|
69
69
|
type: IdentityPublicKey.TYPES.ECDSA_SECP256K1,
|
|
@@ -94,15 +94,14 @@ describe('StateTransitionFacade', () => {
|
|
|
94
94
|
});
|
|
95
95
|
await documentsBatchTransition.sign(identityPublicKey, privateKey);
|
|
96
96
|
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
identity = new Identity(
|
|
97
|
+
const identityObject = (await getIdentityFixture()).toObject();
|
|
98
|
+
identityObject.id = await generateRandomIdentifierAsync();
|
|
99
|
+
identityObject.balance = 10000000;
|
|
100
|
+
identity = new Identity(identityObject);
|
|
101
101
|
identity.setPublicKeys([identityPublicKey]);
|
|
102
102
|
|
|
103
103
|
const blockTime = Date.now();
|
|
104
104
|
|
|
105
|
-
stateRepositoryMock = createStateRepositoryMock(this.sinonSandbox);
|
|
106
105
|
stateRepositoryMock.fetchIdentity.resolves(identity);
|
|
107
106
|
stateRepositoryMock.fetchIdentityBalance.resolves(identity.getBalance());
|
|
108
107
|
stateRepositoryMock.fetchLatestPlatformBlockTime.resolves(blockTime);
|
|
@@ -243,10 +242,7 @@ describe('StateTransitionFacade', () => {
|
|
|
243
242
|
'af432c476f65211f45f48f1d42c9c0b497e56696aa1736b40544ef1a496af837',
|
|
244
243
|
);
|
|
245
244
|
|
|
246
|
-
const
|
|
247
|
-
const identityCreateTransition = new IdentityCreateTransition(
|
|
248
|
-
identityCreateTransitionJS.toObject(),
|
|
249
|
-
);
|
|
245
|
+
const identityCreateTransition = await getIdentityCreateTransitionFixture(oneTimePrivateKey);
|
|
250
246
|
|
|
251
247
|
await identityCreateTransition.signByPrivateKey(
|
|
252
248
|
oneTimePrivateKey.toBuffer(),
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
const crypto = require('crypto');
|
|
2
|
-
const protocolVersion = require('@dashevo/dpp/lib/version/protocolVersion');
|
|
3
2
|
|
|
4
3
|
const createStateRepositoryMock = require('../../lib/test/mocks/createStateRepositoryMock');
|
|
5
4
|
const getBlsAdapterMock = require('../../lib/test/mocks/getBlsAdapterMock');
|
|
6
|
-
|
|
5
|
+
const { DashPlatformProtocol, getLatestProtocolVersion } = require('../..');
|
|
7
6
|
const { default: loadWasmDpp } = require('../..');
|
|
8
7
|
|
|
9
8
|
describe('DashPlatformProtocol', () => {
|
|
@@ -11,14 +10,14 @@ describe('DashPlatformProtocol', () => {
|
|
|
11
10
|
let stateRepositoryMock;
|
|
12
11
|
|
|
13
12
|
beforeEach(async function beforeEach() {
|
|
14
|
-
|
|
13
|
+
await loadWasmDpp();
|
|
15
14
|
stateRepositoryMock = createStateRepositoryMock(this.sinonSandbox);
|
|
16
15
|
|
|
17
16
|
dpp = new DashPlatformProtocol(
|
|
18
17
|
getBlsAdapterMock(),
|
|
19
18
|
stateRepositoryMock,
|
|
20
19
|
{ generate: () => crypto.randomBytes(32) },
|
|
21
|
-
|
|
20
|
+
getLatestProtocolVersion(),
|
|
22
21
|
);
|
|
23
22
|
});
|
|
24
23
|
|
|
@@ -26,7 +25,7 @@ describe('DashPlatformProtocol', () => {
|
|
|
26
25
|
it('should set default protocol version', () => {
|
|
27
26
|
dpp = new DashPlatformProtocol();
|
|
28
27
|
|
|
29
|
-
expect(dpp.protocolVersion).to.equal(
|
|
28
|
+
expect(dpp.protocolVersion).to.equal(getLatestProtocolVersion());
|
|
30
29
|
});
|
|
31
30
|
});
|
|
32
31
|
|
|
@@ -40,7 +39,7 @@ describe('DashPlatformProtocol', () => {
|
|
|
40
39
|
|
|
41
40
|
describe('setProtocolVersion', () => {
|
|
42
41
|
it('should set protocol version', () => {
|
|
43
|
-
expect(dpp.protocolVersion).to.equal(
|
|
42
|
+
expect(dpp.protocolVersion).to.equal(getLatestProtocolVersion());
|
|
44
43
|
|
|
45
44
|
dpp.setProtocolVersion(42);
|
|
46
45
|
|
|
@@ -50,7 +49,7 @@ describe('DashPlatformProtocol', () => {
|
|
|
50
49
|
|
|
51
50
|
describe('getProtocolVersion', () => {
|
|
52
51
|
it('should get protocol version', () => {
|
|
53
|
-
expect(dpp.protocolVersion).to.equal(
|
|
52
|
+
expect(dpp.protocolVersion).to.equal(getLatestProtocolVersion());
|
|
54
53
|
|
|
55
54
|
dpp.setProtocolVersion(42);
|
|
56
55
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const bs58 = require('bs58');
|
|
2
2
|
|
|
3
|
-
const generateRandomIdentifier = require('@dashevo/dpp/lib/test/utils/generateRandomIdentifier');
|
|
4
3
|
const JsDataContract = require('@dashevo/dpp/lib/dataContract/DataContract');
|
|
5
4
|
|
|
5
|
+
const generateRandomIdentifier = require('../../../lib/test/utils/generateRandomIdentifierAsync');
|
|
6
|
+
|
|
6
7
|
const { default: loadWasmDpp } = require('../../../dist');
|
|
7
8
|
|
|
8
9
|
describe('DataContract', () => {
|
|
@@ -27,7 +28,7 @@ describe('DataContract', () => {
|
|
|
27
28
|
} = await loadWasmDpp());
|
|
28
29
|
});
|
|
29
30
|
|
|
30
|
-
beforeEach(() => {
|
|
31
|
+
beforeEach(async () => {
|
|
31
32
|
documentType = 'niceDocument';
|
|
32
33
|
|
|
33
34
|
documentSchema = {
|
|
@@ -46,9 +47,9 @@ describe('DataContract', () => {
|
|
|
46
47
|
[documentType]: documentSchema,
|
|
47
48
|
};
|
|
48
49
|
|
|
49
|
-
ownerId = generateRandomIdentifier();
|
|
50
|
+
ownerId = (await generateRandomIdentifier()).toBuffer();
|
|
50
51
|
entropy = Buffer.alloc(32, 420);
|
|
51
|
-
contractId = generateRandomIdentifier();
|
|
52
|
+
contractId = (await generateRandomIdentifier()).toBuffer();
|
|
52
53
|
|
|
53
54
|
defs = { something: { type: 'string' } };
|
|
54
55
|
|
|
@@ -74,8 +75,8 @@ describe('DataContract', () => {
|
|
|
74
75
|
});
|
|
75
76
|
|
|
76
77
|
describe('constructor', () => {
|
|
77
|
-
it('should create new DataContract', () => {
|
|
78
|
-
const id = generateRandomIdentifier();
|
|
78
|
+
it('should create new DataContract', async () => {
|
|
79
|
+
const id = (await generateRandomIdentifier()).toBuffer();
|
|
79
80
|
|
|
80
81
|
dataContract = new DataContract({
|
|
81
82
|
$schema: DataContractDefaults.SCHEMA,
|
|
@@ -87,8 +88,8 @@ describe('DataContract', () => {
|
|
|
87
88
|
$defs: defs,
|
|
88
89
|
});
|
|
89
90
|
|
|
90
|
-
expect(dataContract.getId().toBuffer()).to.deep.equal(id
|
|
91
|
-
expect(dataContract.getOwnerId().toBuffer()).to.deep.equal(ownerId
|
|
91
|
+
expect(dataContract.getId().toBuffer()).to.deep.equal(id);
|
|
92
|
+
expect(dataContract.getOwnerId().toBuffer()).to.deep.equal(ownerId);
|
|
92
93
|
expect(dataContract.getJsonMetaSchema()).to.deep.equal(DataContractDefaults.SCHEMA);
|
|
93
94
|
expect(dataContract.getDocuments()).to.deep.equal(documents);
|
|
94
95
|
expect(dataContract.getDefinitions()).to.deep.equal(defs);
|
|
@@ -99,7 +100,7 @@ describe('DataContract', () => {
|
|
|
99
100
|
it('should return DataContract Identifier', () => {
|
|
100
101
|
const result = dataContract.getId();
|
|
101
102
|
|
|
102
|
-
expect(result.toBuffer()).to.deep.equal(contractId
|
|
103
|
+
expect(result.toBuffer()).to.deep.equal(contractId);
|
|
103
104
|
expect(result).to.be.instanceof(Identifier);
|
|
104
105
|
});
|
|
105
106
|
});
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
const getDataContractFixture = require('
|
|
1
|
+
const getDataContractFixture = require('../../../lib/test/fixtures/js/getDataContractFixture');
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const { default: loadWasmDpp } = require('../../../dist');
|
|
3
|
+
const { default: loadWasmDpp } = require('../../..');
|
|
4
|
+
const { getLatestProtocolVersion } = require('../../..');
|
|
6
5
|
|
|
7
6
|
describe('DataContractFactory', () => {
|
|
8
7
|
let DataContractFactory;
|
|
@@ -121,7 +120,7 @@ describe('DataContractFactory', () => {
|
|
|
121
120
|
|
|
122
121
|
const result = await factory.createDataContractCreateTransition(dataContract);
|
|
123
122
|
|
|
124
|
-
expect(result.getProtocolVersion()).to.equal(
|
|
123
|
+
expect(result.getProtocolVersion()).to.equal(getLatestProtocolVersion());
|
|
125
124
|
expect(result.getEntropy()).to.deep.equal(jsDataContract.getEntropy());
|
|
126
125
|
expect(result.getDataContract().toObject()).to.deep.equal(jsDataContract.toObject());
|
|
127
126
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const generateRandomIdentifier = require('
|
|
1
|
+
const generateRandomIdentifier = require('../../../lib/test/utils/generateRandomIdentifierAsync');
|
|
2
2
|
|
|
3
|
-
const { default: loadWasmDpp } = require('
|
|
3
|
+
const { default: loadWasmDpp } = require('../../..');
|
|
4
4
|
|
|
5
5
|
describe('createDataContract', () => {
|
|
6
6
|
let rawDataContract;
|
|
@@ -12,10 +12,10 @@ describe('createDataContract', () => {
|
|
|
12
12
|
} = await loadWasmDpp());
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
beforeEach(() => {
|
|
15
|
+
beforeEach(async () => {
|
|
16
16
|
rawDataContract = {
|
|
17
|
-
$id: generateRandomIdentifier().toBuffer(),
|
|
18
|
-
ownerId: generateRandomIdentifier().toBuffer(),
|
|
17
|
+
$id: (await generateRandomIdentifier()).toBuffer(),
|
|
18
|
+
ownerId: (await generateRandomIdentifier()).toBuffer(),
|
|
19
19
|
protocolVersion: 4,
|
|
20
20
|
version: 20,
|
|
21
21
|
$schema: 'http://test.com/schema',
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
const varint = require('varint');
|
|
2
|
-
const getDataContractFixture = require('@dashevo/dpp/lib/test/fixtures/getDataContractFixture');
|
|
3
|
-
const stateTransitionTypes = require('@dashevo/dpp/lib/stateTransition/stateTransitionTypes');
|
|
4
2
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const {
|
|
3
|
+
const getDataContractFixture = require('../../../../../lib/test/fixtures/getDataContractFixture');
|
|
4
|
+
const { default: loadWasmDpp } = require('../../../../..');
|
|
5
|
+
const { getLatestProtocolVersion, StateTransitionTypes } = require('../../../../..');
|
|
8
6
|
|
|
9
7
|
describe('DataContractCreateTransition', () => {
|
|
10
8
|
let stateTransition;
|
|
@@ -18,11 +16,11 @@ describe('DataContractCreateTransition', () => {
|
|
|
18
16
|
} = await loadWasmDpp());
|
|
19
17
|
});
|
|
20
18
|
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
dataContract = getDataContractFixture();
|
|
19
|
+
beforeEach(async () => {
|
|
20
|
+
dataContract = await getDataContractFixture();
|
|
23
21
|
|
|
24
22
|
stateTransition = new DataContractCreateTransition({
|
|
25
|
-
protocolVersion:
|
|
23
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
26
24
|
dataContract: dataContract.toObject(),
|
|
27
25
|
entropy: dataContract.getEntropy(),
|
|
28
26
|
});
|
|
@@ -32,7 +30,7 @@ describe('DataContractCreateTransition', () => {
|
|
|
32
30
|
it('should return the current protocol version', () => {
|
|
33
31
|
const result = stateTransition.getProtocolVersion();
|
|
34
32
|
|
|
35
|
-
expect(result).to.equal(
|
|
33
|
+
expect(result).to.equal(getLatestProtocolVersion());
|
|
36
34
|
});
|
|
37
35
|
});
|
|
38
36
|
|
|
@@ -40,7 +38,7 @@ describe('DataContractCreateTransition', () => {
|
|
|
40
38
|
it('should return State Transition type', () => {
|
|
41
39
|
const result = stateTransition.getType();
|
|
42
40
|
|
|
43
|
-
expect(result).to.equal(
|
|
41
|
+
expect(result).to.equal(StateTransitionTypes.DataContractCreate);
|
|
44
42
|
});
|
|
45
43
|
});
|
|
46
44
|
|
|
@@ -54,10 +52,13 @@ describe('DataContractCreateTransition', () => {
|
|
|
54
52
|
|
|
55
53
|
describe('#toJSON', () => {
|
|
56
54
|
it('should return State Transition as plain JS object', () => {
|
|
55
|
+
const dc = dataContract.toJSON();
|
|
56
|
+
delete dc.$defs;
|
|
57
|
+
|
|
57
58
|
expect(stateTransition.toJSON(true)).to.deep.equal({
|
|
58
|
-
protocolVersion:
|
|
59
|
-
type:
|
|
60
|
-
dataContract:
|
|
59
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
60
|
+
type: StateTransitionTypes.DataContractCreate,
|
|
61
|
+
dataContract: dc,
|
|
61
62
|
entropy: dataContract.getEntropy().toString('base64'),
|
|
62
63
|
});
|
|
63
64
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
const getDataContractFixture = require('
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const { default: loadWasmDpp } = require('../../../../../dist');
|
|
1
|
+
const getDataContractFixture = require('../../../../../lib/test/fixtures/getDataContractFixture');
|
|
2
|
+
const { default: loadWasmDpp } = require('../../../../..');
|
|
3
|
+
const { getLatestProtocolVersion } = require('../../../../..');
|
|
6
4
|
|
|
7
5
|
describe('applyDataContractCreateTransitionFactory', () => {
|
|
8
6
|
let stateTransition;
|
|
@@ -23,11 +21,11 @@ describe('applyDataContractCreateTransitionFactory', () => {
|
|
|
23
21
|
} = await loadWasmDpp());
|
|
24
22
|
});
|
|
25
23
|
|
|
26
|
-
beforeEach(() => {
|
|
27
|
-
dataContract = getDataContractFixture();
|
|
24
|
+
beforeEach(async () => {
|
|
25
|
+
dataContract = await getDataContractFixture();
|
|
28
26
|
|
|
29
27
|
stateTransition = new DataContractCreateTransition({
|
|
30
|
-
protocolVersion:
|
|
28
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
31
29
|
dataContract: dataContract.toObject(),
|
|
32
30
|
entropy: Buffer.alloc(32),
|
|
33
31
|
});
|
|
@@ -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('validateDataContractCreateTransitionStateFactory', () => {
|
|
7
7
|
let validateDataContractCreateTransitionState;
|
|
@@ -27,10 +27,10 @@ describe('validateDataContractCreateTransitionStateFactory', () => {
|
|
|
27
27
|
} = await loadWasmDpp());
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
beforeEach(() => {
|
|
31
|
-
dataContract = getDataContractFixture();
|
|
30
|
+
beforeEach(async () => {
|
|
31
|
+
dataContract = await getDataContractFixture();
|
|
32
32
|
stateTransition = new DataContractCreateTransition({
|
|
33
|
-
protocolVersion:
|
|
33
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
34
34
|
dataContract: dataContract.toObject(),
|
|
35
35
|
entropy: dataContract.getEntropy(),
|
|
36
36
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
const varint = require('varint');
|
|
2
|
-
const getDataContractFixture = require('@dashevo/dpp/lib/test/fixtures/getDataContractFixture');
|
|
3
|
-
const stateTransitionTypes = require('@dashevo/dpp/lib/stateTransition/stateTransitionTypes');
|
|
4
|
-
const protocolVersion = require('@dashevo/dpp/lib/version/protocolVersion');
|
|
5
2
|
const JsDataContractUpdateTransition = require('@dashevo/dpp/lib/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition');
|
|
6
3
|
|
|
7
|
-
const
|
|
4
|
+
const getDataContractFixture = require('../../../../../lib/test/fixtures/getDataContractFixture');
|
|
5
|
+
const { default: loadWasmDpp } = require('../../../../..');
|
|
6
|
+
const { getLatestProtocolVersion, StateTransitionTypes } = require('../../../../..');
|
|
8
7
|
|
|
9
8
|
describe('DataContractUpdateTransition', () => {
|
|
10
9
|
let stateTransition;
|
|
@@ -18,11 +17,11 @@ describe('DataContractUpdateTransition', () => {
|
|
|
18
17
|
} = await loadWasmDpp());
|
|
19
18
|
});
|
|
20
19
|
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
dataContract = getDataContractFixture();
|
|
20
|
+
beforeEach(async () => {
|
|
21
|
+
dataContract = await getDataContractFixture();
|
|
23
22
|
|
|
24
23
|
stateTransition = new DataContractUpdateTransition({
|
|
25
|
-
protocolVersion:
|
|
24
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
26
25
|
dataContract: dataContract.toObject(),
|
|
27
26
|
});
|
|
28
27
|
});
|
|
@@ -31,7 +30,7 @@ describe('DataContractUpdateTransition', () => {
|
|
|
31
30
|
it('should return the current protocol version', () => {
|
|
32
31
|
const result = stateTransition.getProtocolVersion();
|
|
33
32
|
|
|
34
|
-
expect(result).to.equal(
|
|
33
|
+
expect(result).to.equal(getLatestProtocolVersion());
|
|
35
34
|
});
|
|
36
35
|
});
|
|
37
36
|
|
|
@@ -39,7 +38,7 @@ describe('DataContractUpdateTransition', () => {
|
|
|
39
38
|
it('should return State Transition type', () => {
|
|
40
39
|
const result = stateTransition.getType();
|
|
41
40
|
|
|
42
|
-
expect(result).to.equal(
|
|
41
|
+
expect(result).to.equal(StateTransitionTypes.DataContractUpdate);
|
|
43
42
|
});
|
|
44
43
|
});
|
|
45
44
|
|
|
@@ -53,10 +52,13 @@ describe('DataContractUpdateTransition', () => {
|
|
|
53
52
|
|
|
54
53
|
describe('#toJSON', () => {
|
|
55
54
|
it('should return State Transition as plain JS object', () => {
|
|
55
|
+
const dc = dataContract.toJSON();
|
|
56
|
+
delete dc.$defs;
|
|
57
|
+
|
|
56
58
|
expect(stateTransition.toJSON(true)).to.deep.equal({
|
|
57
|
-
protocolVersion:
|
|
58
|
-
type:
|
|
59
|
-
dataContract:
|
|
59
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
60
|
+
type: StateTransitionTypes.DataContractUpdate,
|
|
61
|
+
dataContract: dc,
|
|
60
62
|
});
|
|
61
63
|
});
|
|
62
64
|
});
|
|
@@ -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('applyDataContractUpdateTransitionFactory', () => {
|
|
7
7
|
let stateTransition;
|
|
@@ -21,12 +21,12 @@ describe('applyDataContractUpdateTransitionFactory', () => {
|
|
|
21
21
|
} = await loadWasmDpp());
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
dataContract = getDataContractFixture();
|
|
24
|
+
beforeEach(async () => {
|
|
25
|
+
dataContract = await getDataContractFixture();
|
|
26
26
|
|
|
27
27
|
stateTransition = new DataContractUpdateTransition({
|
|
28
28
|
dataContract: dataContract.toObject(),
|
|
29
|
-
protocolVersion:
|
|
29
|
+
protocolVersion: getLatestProtocolVersion(),
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
executionContext = new StateTransitionExecutionContext();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const getDataContractFixture = require('
|
|
1
|
+
const getDataContractFixture = require('../../../../../../../lib/test/fixtures/getDataContractFixture');
|
|
2
2
|
|
|
3
3
|
const { default: loadWasmDpp } = require('../../../../../../../dist');
|
|
4
4
|
|
|
@@ -19,9 +19,9 @@ describe('validateIndicesAreBackwardCompatible', () => {
|
|
|
19
19
|
} = await loadWasmDpp());
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
const oldDataContract = getDataContractFixture();
|
|
24
|
-
const newDataContract = getDataContractFixture();
|
|
22
|
+
beforeEach(async () => {
|
|
23
|
+
const oldDataContract = await getDataContractFixture();
|
|
24
|
+
const newDataContract = await getDataContractFixture();
|
|
25
25
|
|
|
26
26
|
oldDocumentsSchema = oldDataContract.getDocuments();
|
|
27
27
|
newDocumentsSchema = newDataContract.getDocuments();
|