@dashevo/wasm-dpp 0.25.8 → 0.25.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +3 -2
- package/README.md +1 -1
- package/dist/wasm/wasm_dpp.d.ts +808 -712
- package/dist/wasm/wasm_dpp.js +853 -452
- package/dist/wasm/wasm_dpp_bg.js +1 -1
- package/lib/bls/bls.js +48 -0
- package/lib/test/fixtures/getChainAssetLockProofFixture.js +20 -1
- package/lib/test/fixtures/getDataContractFixture.js +4 -6
- package/lib/test/fixtures/getDocumentTransitionsFixture.js +31 -1
- package/lib/test/fixtures/getInstantAssetLockProofFixture.js +32 -12
- package/lib/test/mocks/getBlsAdapterMock.js +1 -1
- package/lib/utils/creditsConverter.js +14 -0
- package/lib/utils/hash.js +18 -0
- package/lib/wasm/wasm_dpp.d.ts +808 -712
- package/package.json +3 -5
- package/src/dash_platform_protocol.rs +5 -5
- package/src/document/errors/invalid_document_error.rs +5 -0
- package/src/document/extended_document.rs +15 -0
- package/src/document/state_transition/document_batch_transition/document_transition/document_create_transition.rs +219 -214
- package/src/document/state_transition/document_batch_transition/document_transition/mod.rs +1 -1
- package/src/errors/consensus/basic/identity/identity_insufficient_balance_error.rs +4 -2
- package/src/errors/consensus/basic/json_schema_error.rs +35 -5
- package/src/identity/identity_facade.rs +7 -5
- package/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs +32 -17
- package/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs +22 -13
- package/src/identity/state_transition/asset_lock_proof/mod.rs +12 -11
- package/src/identity/state_transition/identity_create_transition/identity_create_transition.rs +1 -0
- package/src/identity/state_transition/identity_create_transition/to_object.rs +1 -0
- package/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs +1 -0
- package/src/identity/state_transition/identity_topup_transition/to_object.rs +1 -0
- package/src/lib.rs +1 -1
- package/src/validation/mod.rs +2 -2
- package/src/validation/validation_result.rs +16 -15
- package/test/integration/document/DocumentFacade.spec.js +11 -27
- package/test/integration/document/stateTransition/DocumentsBatchTransition/DocumentBatchTransition.spec.js +9 -19
- package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/basic/validateDocumentsBatchTransitionBasicFactory.spec.js +2 -2
- package/test/integration/document/validation/validateDocumentFactory.spec.js +2 -2
- package/test/integration/identity/IdentityFacade.spec.js +1 -2
- package/test/integration/identity/stateTransition/assetLockProof/instant/validateInstantAssetLockProofStructureFactory.spec.js +2 -2
- package/test/integration/identity/stateTransition/validatePublicKeySignaturesFactory.spec.js +2 -2
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +6 -8
- package/test/unit/document/Document.spec.js +30 -52
- package/test/unit/document/DocumentFactory.spec.js +2 -2
- package/test/unit/document/errors/InvalidDocumentError.spec.js +9 -9
- package/test/unit/document/stateTransition/DocumetsBatchTransition/DocumentsBatchTransition.spec.js +158 -155
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/findDuplicatesByIndices.spec.js +132 -134
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/validatePartialCompoundIndices.spec.js +3 -3
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsBatchTransitionStateFactory.spec.js +568 -591
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsUniquenessByIndicesFactory.spec.js +5 -13
- package/test/unit/identity/Identity.spec.js +2 -2
- package/test/unit/identity/stateTransition/assetLockProof/ChainAssetLockProof.spec.js +9 -28
- package/test/unit/identity/stateTransition/assetLockProof/InstantAssetLockProof.spec.js +19 -27
- package/lib/test/fixtures/getDashPayContractFixture.js +0 -1
- package/lib/test/fixtures/getDashPayDocumentFixture.js +0 -1
- package/lib/test/fixtures/getDpnsContractFixture.js +0 -1
- package/lib/test/fixtures/getDpnsDocumentFixture.js +0 -1
- package/lib/test/fixtures/getFeatureFlagsContractFixture.js +0 -1
- package/lib/test/fixtures/getFeatureFlagsDocumentsFixture.js +0 -1
- package/lib/test/fixtures/getIdentityTopUpTransitionFixtureJs.js +0 -1
- package/lib/test/fixtures/getMasternodeRewardShareDocumentsFixture.js +0 -1
- package/lib/test/fixtures/getMasternodeRewardSharesContractFixture.js +0 -1
- package/lib/test/fixtures/getPreorderDocumentFixture.js +0 -1
- package/lib/test/fixtures/getRawTransactionFixture.js +0 -1
- package/lib/test/fixtures/js/generateRandomIdentifier.js +0 -1
- package/lib/test/fixtures/js/getChainAssetLockProofFixture.js +0 -1
- package/lib/test/fixtures/js/getDataContractFixture.js +0 -1
- package/lib/test/fixtures/js/getDocumentTransitionsFixture.js +0 -1
- package/lib/test/fixtures/js/getDocumentsFixture.js +0 -1
- package/lib/test/fixtures/js/getInstantAssetLockProofFixture.js +0 -1
- package/test/integration/DashPlatformProtocol.spec.js +0 -53
- package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/state/executeDataTriggersFactory.spec.js +0 -195
- package/test/integration/stateTransition/AbstractStateTransitionIdentitySigned.spec.js +0 -500
- package/test/integration/stateTransition/calculateStateTransitionFeeFromOperationsFactory.spec.js +0 -53
- package/test/unit/dataContract/getBinaryPropertiesFromSchema.spec.js +0 -103
- package/test/unit/dataContract/getPropertyDefinitionByPath.spec.js +0 -84
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/applyDataContractCreateTransitionFactory.spec.js +0 -45
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/applyDataContractUpdateTransitionFactory.spec.js +0 -49
- package/test/unit/dataTrigger/DataTrigger.spec.js +0 -132
- package/test/unit/dataTrigger/DataTriggerExecutionContext.spec.js +0 -29
- package/test/unit/dataTrigger/dashpayDataTriggers/createContactRequestDataTrigger.spec.js +0 -107
- package/test/unit/dataTrigger/dpnsTriggers/createDomainDataTrigger.spec.js +0 -382
- package/test/unit/dataTrigger/featureFlagDataTriggers/createFeatureFlagDataTrigger.spec.js +0 -99
- package/test/unit/dataTrigger/getDataTriggersFactory.spec.js +0 -113
- package/test/unit/dataTrigger/rejectDataTrigger.spec.js +0 -51
- package/test/unit/dataTrigger/rewardShareDataTriggers/createMasternodeRewardSharesDataTrigger.spec.js +0 -202
- package/test/unit/document/stateTransition/DocumetsBatchTransition/applyDocumentsBatchTransitionFactory.spec.js +0 -256
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/fetchDocumentsFactory.spec.js +0 -94
- package/test/unit/errors/consensus/codes.spec.js +0 -102
- package/test/unit/identity/creditsConverter.spec.js +0 -34
- package/test/unit/identity/stateTransition/IdentityCreateTransition/applyIdentityCreateTransitionFactory.spec.js +0 -83
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/applyIdentityTopUpTransitionFactory.spec.js +0 -138
- package/test/unit/identity/stateTransition/IdentityUpdateTransition/applyIdentityUpdateTransitionFactory.spec.js +0 -100
- package/test/unit/identity/stateTransition/assetLockProof/createAssetLockProofInstance.spec.js +0 -36
- package/test/unit/identity/stateTransition/assetLockProof/fetchAssetLockPublicKeyHashFactory.spec.js +0 -63
- package/test/unit/identity/validation/validateRequiredPurposeAndSecurityLevelFactory.spec.js +0 -47
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
const { convertSatoshiToCredits } = require('@dashevo/dpp/lib/identity/creditsConverter');
|
|
2
|
-
|
|
3
|
-
const getIdentityCreateTransitionFixture = require('../../../../../lib/test/fixtures/getIdentityCreateTransitionFixture');
|
|
4
|
-
const createStateRepositoryMock = require('../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
5
|
-
|
|
6
|
-
const { default: loadWasmDpp } = require('../../../../..');
|
|
7
|
-
const { getLatestProtocolVersion } = require('../../../../..');
|
|
8
|
-
|
|
9
|
-
describe.skip('applyIdentityCreateTransitionFactory', () => {
|
|
10
|
-
let stateTransition;
|
|
11
|
-
let applyIdentityCreateTransition;
|
|
12
|
-
let stateRepositoryMock;
|
|
13
|
-
let output;
|
|
14
|
-
let executionContext;
|
|
15
|
-
|
|
16
|
-
let StateTransitionExecutionContext;
|
|
17
|
-
let Identity;
|
|
18
|
-
|
|
19
|
-
let applyIdentityCreateTransitionDPP;
|
|
20
|
-
|
|
21
|
-
before(async () => {
|
|
22
|
-
({
|
|
23
|
-
StateTransitionExecutionContext,
|
|
24
|
-
applyIdentityCreateTransition: applyIdentityCreateTransitionDPP,
|
|
25
|
-
Identity,
|
|
26
|
-
} = await loadWasmDpp());
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
beforeEach(async function beforeEach() {
|
|
30
|
-
stateRepositoryMock = createStateRepositoryMock(this.sinonSandbox);
|
|
31
|
-
stateRepositoryMock.createIdentity.resolves();
|
|
32
|
-
stateRepositoryMock.addToSystemCredits.resolves();
|
|
33
|
-
stateRepositoryMock.markAssetLockTransactionOutPointAsUsed.resolves();
|
|
34
|
-
|
|
35
|
-
stateTransition = await getIdentityCreateTransitionFixture();
|
|
36
|
-
|
|
37
|
-
executionContext = new StateTransitionExecutionContext();
|
|
38
|
-
|
|
39
|
-
output = stateTransition.getAssetLockProof().getOutput();
|
|
40
|
-
|
|
41
|
-
applyIdentityCreateTransition = (st) => applyIdentityCreateTransitionDPP(
|
|
42
|
-
stateRepositoryMock,
|
|
43
|
-
st,
|
|
44
|
-
executionContext,
|
|
45
|
-
);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('should store identity created from state transition', async function beforeEach() {
|
|
49
|
-
await applyIdentityCreateTransition(stateTransition);
|
|
50
|
-
|
|
51
|
-
const balance = convertSatoshiToCredits(
|
|
52
|
-
output.satoshis,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
const identity = new Identity({
|
|
56
|
-
protocolVersion: getLatestProtocolVersion(),
|
|
57
|
-
id: stateTransition.getIdentityId(),
|
|
58
|
-
publicKeys: stateTransition.getPublicKeys()
|
|
59
|
-
.map((key) => key.toObject({ skipSignature: true })),
|
|
60
|
-
balance,
|
|
61
|
-
revision: 0,
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
const { match } = this.sinonSandbox;
|
|
65
|
-
|
|
66
|
-
expect(stateRepositoryMock.createIdentity).to.have.been.calledOnceWithExactly(
|
|
67
|
-
match((arg) => expect(arg.toObject()).to.deep.equal(identity.toObject())),
|
|
68
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
expect(stateRepositoryMock.addToSystemCredits).to.have.been.calledOnceWithExactly(
|
|
72
|
-
balance,
|
|
73
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
const outPoint = stateTransition.getAssetLockProof().getOutPoint();
|
|
77
|
-
expect(stateRepositoryMock.markAssetLockTransactionOutPointAsUsed).to.have.been
|
|
78
|
-
.calledOnceWithExactly(
|
|
79
|
-
match((arg) => Buffer.from(arg).equals(outPoint)),
|
|
80
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
81
|
-
);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
const { convertSatoshiToCredits } = require('@dashevo/dpp/lib/identity/creditsConverter');
|
|
2
|
-
|
|
3
|
-
const getIdentityTopUpTransitionFixture = require('../../../../../lib/test/fixtures/getIdentityTopUpTransitionFixture');
|
|
4
|
-
|
|
5
|
-
const createStateRepositoryMock = require('../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
6
|
-
|
|
7
|
-
const { default: loadWasmDpp } = require('../../../../..');
|
|
8
|
-
|
|
9
|
-
describe.skip('applyIdentityTopUpTransitionFactory', () => {
|
|
10
|
-
let stateTransition;
|
|
11
|
-
let applyIdentityTopUpTransition;
|
|
12
|
-
let stateRepositoryMock;
|
|
13
|
-
let executionContext;
|
|
14
|
-
|
|
15
|
-
let StateTransitionExecutionContext;
|
|
16
|
-
|
|
17
|
-
let applyIdentityTopUpTransitionDPP;
|
|
18
|
-
|
|
19
|
-
before(async () => {
|
|
20
|
-
({
|
|
21
|
-
StateTransitionExecutionContext,
|
|
22
|
-
applyIdentityTopUpTransition: applyIdentityTopUpTransitionDPP,
|
|
23
|
-
} = await loadWasmDpp());
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
beforeEach(async function beforeEach() {
|
|
27
|
-
stateRepositoryMock = createStateRepositoryMock(this.sinonSandbox);
|
|
28
|
-
stateRepositoryMock.fetchIdentityBalanceWithDebt.resolves(0);
|
|
29
|
-
stateRepositoryMock.addToIdentityBalance.resolves();
|
|
30
|
-
stateRepositoryMock.addToSystemCredits.resolves();
|
|
31
|
-
stateRepositoryMock.markAssetLockTransactionOutPointAsUsed.resolves();
|
|
32
|
-
|
|
33
|
-
const rawTransaction = '030000000137feb5676d0851337ea3c9a992496aab7a0b3eee60aeeb9774000b7f4bababa5000000006b483045022100d91557de37645c641b948c6cd03b4ae3791a63a650db3e2fee1dcf5185d1b10402200e8bd410bf516ca61715867666d31e44495428ce5c1090bf2294a829ebcfa4ef0121025c3cc7fbfc52f710c941497fd01876c189171ea227458f501afcb38a297d65b4ffffffff021027000000000000166a14152073ca2300a86b510fa2f123d3ea7da3af68dcf77cb0090a0000001976a914152073ca2300a86b510fa2f123d3ea7da3af68dc88ac00000000';
|
|
34
|
-
|
|
35
|
-
stateRepositoryMock.fetchTransaction.resolves({
|
|
36
|
-
data: Buffer.from(rawTransaction, 'hex'),
|
|
37
|
-
height: 42,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
stateTransition = await getIdentityTopUpTransitionFixture();
|
|
41
|
-
|
|
42
|
-
executionContext = new StateTransitionExecutionContext();
|
|
43
|
-
|
|
44
|
-
applyIdentityTopUpTransition = (st) => applyIdentityTopUpTransitionDPP(
|
|
45
|
-
stateRepositoryMock,
|
|
46
|
-
st,
|
|
47
|
-
executionContext,
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should add topup amount to identity balance', async function shouldAdd() {
|
|
52
|
-
const balanceToTopUp = convertSatoshiToCredits(
|
|
53
|
-
stateTransition.getAssetLockProof().getOutput().satoshis,
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
await applyIdentityTopUpTransition(stateTransition);
|
|
57
|
-
|
|
58
|
-
const { match } = this.sinonSandbox;
|
|
59
|
-
|
|
60
|
-
expect(stateRepositoryMock.addToIdentityBalance).to.have.been.calledOnceWithExactly(
|
|
61
|
-
match((arg) => arg.toBuffer().equals(stateTransition.getOwnerId().toBuffer())),
|
|
62
|
-
balanceToTopUp,
|
|
63
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
expect(stateRepositoryMock.addToSystemCredits).to.have.been.calledOnceWithExactly(
|
|
67
|
-
balanceToTopUp,
|
|
68
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const outPoint = stateTransition.getAssetLockProof().getOutPoint();
|
|
72
|
-
|
|
73
|
-
expect(stateRepositoryMock.markAssetLockTransactionOutPointAsUsed).to.have.been
|
|
74
|
-
.calledOnceWithExactly(
|
|
75
|
-
match((arg) => Buffer.from(arg).equals(outPoint)),
|
|
76
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
77
|
-
);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('should ignore balance debt for system credits', async function shouldIgnore() {
|
|
81
|
-
stateRepositoryMock.fetchIdentityBalanceWithDebt.resolves(-5);
|
|
82
|
-
|
|
83
|
-
const balanceToTopUp = convertSatoshiToCredits(
|
|
84
|
-
stateTransition.getAssetLockProof().getOutput().satoshis,
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
await applyIdentityTopUpTransition(stateTransition);
|
|
88
|
-
|
|
89
|
-
const { match } = this.sinonSandbox;
|
|
90
|
-
|
|
91
|
-
expect(stateRepositoryMock.addToIdentityBalance).to.have.been.calledOnceWithExactly(
|
|
92
|
-
match((arg) => arg.toBuffer().equals(stateTransition.getOwnerId().toBuffer())),
|
|
93
|
-
balanceToTopUp,
|
|
94
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
expect(stateRepositoryMock.addToSystemCredits).to.have.been.calledOnceWithExactly(
|
|
98
|
-
balanceToTopUp - 5,
|
|
99
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
const outPoint = stateTransition.getAssetLockProof().getOutPoint();
|
|
103
|
-
|
|
104
|
-
expect(stateRepositoryMock.markAssetLockTransactionOutPointAsUsed).to.have.been
|
|
105
|
-
.calledOnceWithExactly(
|
|
106
|
-
match((arg) => Buffer.from(arg).equals(outPoint)),
|
|
107
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
108
|
-
);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('should add topup amount to identity balance on dry run', async function shouldAddTopup() {
|
|
112
|
-
const { match } = this.sinonSandbox;
|
|
113
|
-
|
|
114
|
-
const balanceToTopUp = convertSatoshiToCredits(
|
|
115
|
-
stateTransition.getAssetLockProof().getOutput().satoshis,
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
executionContext.enableDryRun();
|
|
119
|
-
|
|
120
|
-
await applyIdentityTopUpTransition(stateTransition);
|
|
121
|
-
|
|
122
|
-
executionContext.disableDryRun();
|
|
123
|
-
|
|
124
|
-
expect(stateRepositoryMock.addToIdentityBalance).to.have.been.calledOnceWithExactly(
|
|
125
|
-
match((arg) => arg.toBuffer().equals(stateTransition.getOwnerId().toBuffer())),
|
|
126
|
-
balanceToTopUp,
|
|
127
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const outPoint = stateTransition.getAssetLockProof().getOutPoint();
|
|
131
|
-
|
|
132
|
-
expect(stateRepositoryMock.markAssetLockTransactionOutPointAsUsed).to.have.been
|
|
133
|
-
.calledOnceWithExactly(
|
|
134
|
-
match((arg) => Buffer.from(arg).equals(outPoint)),
|
|
135
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
136
|
-
);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
const createStateRepositoryMock = require('../../../../../lib/test/mocks/createStateRepositoryMock');
|
|
2
|
-
const getIdentityUpdateTransitionFixture = require('../../../../../lib/test/fixtures/getIdentityUpdateTransitionFixture');
|
|
3
|
-
|
|
4
|
-
const { default: loadWasmDpp } = require('../../../../../dist');
|
|
5
|
-
|
|
6
|
-
describe.skip('applyIdentityUpdateTransition', () => {
|
|
7
|
-
let applyIdentityUpdateTransition;
|
|
8
|
-
let stateRepositoryMock;
|
|
9
|
-
let stateTransition;
|
|
10
|
-
let executionContext;
|
|
11
|
-
|
|
12
|
-
let StateTransitionExecutionContext;
|
|
13
|
-
|
|
14
|
-
let applyIdentityUpdateTransitionDPP;
|
|
15
|
-
|
|
16
|
-
before(async () => {
|
|
17
|
-
({
|
|
18
|
-
StateTransitionExecutionContext,
|
|
19
|
-
applyIdentityUpdateTransition: applyIdentityUpdateTransitionDPP,
|
|
20
|
-
} = await loadWasmDpp());
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
beforeEach(async function beforeEach() {
|
|
24
|
-
stateTransition = await getIdentityUpdateTransitionFixture();
|
|
25
|
-
stateTransition.setRevision(stateTransition.getRevision() + 1);
|
|
26
|
-
|
|
27
|
-
executionContext = new StateTransitionExecutionContext();
|
|
28
|
-
|
|
29
|
-
stateRepositoryMock = createStateRepositoryMock(this.sinonSandbox);
|
|
30
|
-
stateRepositoryMock.updateIdentityRevision.resolves();
|
|
31
|
-
stateRepositoryMock.disableIdentityKeys.resolves();
|
|
32
|
-
stateRepositoryMock.addKeysToIdentity.resolves();
|
|
33
|
-
|
|
34
|
-
applyIdentityUpdateTransition = (st) => applyIdentityUpdateTransitionDPP(
|
|
35
|
-
stateRepositoryMock,
|
|
36
|
-
st,
|
|
37
|
-
executionContext,
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should add and disable public keys', async function shouldAdd() {
|
|
42
|
-
await applyIdentityUpdateTransition(stateTransition);
|
|
43
|
-
|
|
44
|
-
const { match } = this.sinonSandbox;
|
|
45
|
-
|
|
46
|
-
expect(stateRepositoryMock.updateIdentityRevision).to.be.calledOnceWithExactly(
|
|
47
|
-
match((id) => id.toBuffer().equals(stateTransition.getOwnerId().toBuffer())),
|
|
48
|
-
stateTransition.getRevision(),
|
|
49
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
expect(stateRepositoryMock.disableIdentityKeys).to.be.calledOnceWithExactly(
|
|
53
|
-
match((id) => id.toBuffer().equals(stateTransition.getOwnerId().toBuffer())),
|
|
54
|
-
stateTransition.getPublicKeyIdsToDisable(),
|
|
55
|
-
stateTransition.getPublicKeysDisabledAt().getTime(),
|
|
56
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
const publicKeysToAdd = stateTransition.getPublicKeysToAdd()
|
|
60
|
-
.map((publicKey) => publicKey.toObject({ skipSignature: true }));
|
|
61
|
-
|
|
62
|
-
expect(stateRepositoryMock.addKeysToIdentity).to.be.calledOnceWithExactly(
|
|
63
|
-
match((id) => id.toBuffer().equals(stateTransition.getOwnerId().toBuffer())),
|
|
64
|
-
match((args) => expect(args.map((k) => k.toObject())).to.deep.equals(publicKeysToAdd)),
|
|
65
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('should add and disable public keys on dry run', async function shouldDisable() {
|
|
70
|
-
const { match } = this.sinonSandbox;
|
|
71
|
-
|
|
72
|
-
executionContext.enableDryRun();
|
|
73
|
-
|
|
74
|
-
await applyIdentityUpdateTransition(stateTransition);
|
|
75
|
-
|
|
76
|
-
executionContext.disableDryRun();
|
|
77
|
-
|
|
78
|
-
expect(stateRepositoryMock.updateIdentityRevision).to.be.calledOnceWithExactly(
|
|
79
|
-
match((id) => id.toBuffer().equals(stateTransition.getOwnerId().toBuffer())),
|
|
80
|
-
stateTransition.getRevision(),
|
|
81
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
expect(stateRepositoryMock.disableIdentityKeys).to.be.calledOnceWithExactly(
|
|
85
|
-
match((id) => id.toBuffer().equals(stateTransition.getOwnerId().toBuffer())),
|
|
86
|
-
stateTransition.getPublicKeyIdsToDisable(),
|
|
87
|
-
stateTransition.getPublicKeysDisabledAt().getTime(),
|
|
88
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const publicKeysToAdd = stateTransition.getPublicKeysToAdd()
|
|
92
|
-
.map((publicKey) => publicKey.toObject({ skipSignature: true }));
|
|
93
|
-
|
|
94
|
-
expect(stateRepositoryMock.addKeysToIdentity).to.be.calledOnceWithExactly(
|
|
95
|
-
match((id) => id.toBuffer().equals(stateTransition.getOwnerId().toBuffer())),
|
|
96
|
-
match((args) => expect(args.map((k) => k.toObject())).to.deep.equals(publicKeysToAdd)),
|
|
97
|
-
match.instanceOf(StateTransitionExecutionContext),
|
|
98
|
-
);
|
|
99
|
-
});
|
|
100
|
-
});
|
package/test/unit/identity/stateTransition/assetLockProof/createAssetLockProofInstance.spec.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const createAssetLockProofInstanceJS = require('@dashevo/dpp/lib/identity/stateTransition/assetLockProof/createAssetLockProofInstance');
|
|
2
|
-
const getChainAssetLockFixture = require('@dashevo/dpp/lib/test/fixtures/getChainAssetLockProofFixture');
|
|
3
|
-
const getInstantAssetLockProofFixture = require('@dashevo/dpp/lib/test/fixtures/getInstantAssetLockProofFixture');
|
|
4
|
-
const { default: loadWasmDpp } = require('../../../../../dist');
|
|
5
|
-
|
|
6
|
-
describe('createAssetLockProofInstance', () => {
|
|
7
|
-
let createAssetLockProofInstance;
|
|
8
|
-
let InstantAssetLockProof;
|
|
9
|
-
let ChainAssetLockProof;
|
|
10
|
-
|
|
11
|
-
before(async () => {
|
|
12
|
-
({
|
|
13
|
-
createAssetLockProofInstance,
|
|
14
|
-
InstantAssetLockProof,
|
|
15
|
-
ChainAssetLockProof,
|
|
16
|
-
} = await loadWasmDpp());
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('should create an instance of InstantAssetLockProof', () => {
|
|
20
|
-
const assetLockProofFixture = getInstantAssetLockProofFixture();
|
|
21
|
-
const instance = createAssetLockProofInstance(assetLockProofFixture.toObject());
|
|
22
|
-
const instanceJS = createAssetLockProofInstanceJS(assetLockProofFixture.toObject());
|
|
23
|
-
|
|
24
|
-
expect(instance.toObject()).to.deep.equal(instanceJS.toObject());
|
|
25
|
-
expect(instance).to.be.an.instanceOf(InstantAssetLockProof);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should create an instance of ChainAssetLockProof', () => {
|
|
29
|
-
const assetLockProofFixture = getChainAssetLockFixture();
|
|
30
|
-
const instance = createAssetLockProofInstance(assetLockProofFixture.toObject());
|
|
31
|
-
const instanceJS = createAssetLockProofInstanceJS(assetLockProofFixture.toObject());
|
|
32
|
-
|
|
33
|
-
expect(instance.toObject()).to.deep.equal(instanceJS.toObject());
|
|
34
|
-
expect(instance).to.be.an.instanceOf(ChainAssetLockProof);
|
|
35
|
-
});
|
|
36
|
-
});
|
package/test/unit/identity/stateTransition/assetLockProof/fetchAssetLockPublicKeyHashFactory.spec.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const { Script } = require('@dashevo/dashcore-lib');
|
|
2
|
-
|
|
3
|
-
const getInstantAssetLockProofFixture = require('@dashevo/dpp/lib/test/fixtures/getInstantAssetLockProofFixture');
|
|
4
|
-
|
|
5
|
-
const createStateRepositoryMock = require('@dashevo/dpp/lib/test/mocks/createStateRepositoryMock');
|
|
6
|
-
const { default: loadWasmpDpp } = require('../../../../../dist');
|
|
7
|
-
|
|
8
|
-
describe.skip('fetchAssetLockPublicKeyHashFactory', () => {
|
|
9
|
-
let fetchAssetLockPublicKeyHash;
|
|
10
|
-
let stateRepositoryMock;
|
|
11
|
-
let executionContext;
|
|
12
|
-
|
|
13
|
-
let StateTransitionExecutionContext;
|
|
14
|
-
let InstantAssetLockProof;
|
|
15
|
-
let AssetLockOutputNotFoundError;
|
|
16
|
-
let fetchAssetLockPublicKeyHashDPP;
|
|
17
|
-
|
|
18
|
-
before(async () => {
|
|
19
|
-
({
|
|
20
|
-
StateTransitionExecutionContext,
|
|
21
|
-
InstantAssetLockProof,
|
|
22
|
-
AssetLockOutputNotFoundError,
|
|
23
|
-
fetchAssetLockPublicKeyHash: fetchAssetLockPublicKeyHashDPP,
|
|
24
|
-
} = await loadWasmpDpp());
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
beforeEach(function beforeEach() {
|
|
28
|
-
stateRepositoryMock = createStateRepositoryMock(this.sinonSandbox);
|
|
29
|
-
|
|
30
|
-
executionContext = new StateTransitionExecutionContext();
|
|
31
|
-
|
|
32
|
-
fetchAssetLockPublicKeyHash = (proof) => fetchAssetLockPublicKeyHashDPP(
|
|
33
|
-
stateRepositoryMock,
|
|
34
|
-
proof,
|
|
35
|
-
executionContext,
|
|
36
|
-
);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should return public key hash for specified asset lock proof', async () => {
|
|
40
|
-
const assetLockProof = new InstantAssetLockProof(
|
|
41
|
-
getInstantAssetLockProofFixture().toObject(),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const result = await fetchAssetLockPublicKeyHash(assetLockProof);
|
|
45
|
-
|
|
46
|
-
expect(result).to
|
|
47
|
-
.deep.equal(new Script(assetLockProof.getOutput().script).getData());
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('should throw AssetLockOutputNotFoundError if output is not found', async () => {
|
|
51
|
-
try {
|
|
52
|
-
const assetLockProofJS = getInstantAssetLockProofFixture();
|
|
53
|
-
// Mess up TX outputs
|
|
54
|
-
assetLockProofJS.transaction.outputs = [];
|
|
55
|
-
|
|
56
|
-
const assetLockProof = new InstantAssetLockProof(assetLockProofJS.toObject());
|
|
57
|
-
await fetchAssetLockPublicKeyHash(assetLockProof);
|
|
58
|
-
expect.fail('should throw AssetLockOutputNotFoundError');
|
|
59
|
-
} catch (e) {
|
|
60
|
-
expect(e).to.be.an.instanceOf(AssetLockOutputNotFoundError);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
package/test/unit/identity/validation/validateRequiredPurposeAndSecurityLevelFactory.spec.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const IdentityPublicKey = require('@dashevo/dpp/lib/identity/IdentityPublicKey');
|
|
2
|
-
|
|
3
|
-
const validateRequiredPurposeAndSecurityLevelFactory = require('@dashevo/dpp/lib/identity/validation/validateRequiredPurposeAndSecurityLevelFactory');
|
|
4
|
-
|
|
5
|
-
const { expectValidationError } = require('@dashevo/dpp/lib/test/expect/expectError');
|
|
6
|
-
|
|
7
|
-
const ValidationResult = require('@dashevo/dpp/lib/validation/ValidationResult');
|
|
8
|
-
|
|
9
|
-
const MissingMasterPublicKeyError = require('@dashevo/dpp/lib/errors/consensus/basic/identity/MissingMasterPublicKeyError');
|
|
10
|
-
|
|
11
|
-
describe('validateRequiredPurposeAndSecurityLevel', () => {
|
|
12
|
-
let validateRequiredPurposeAndSecurityLevel;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
validateRequiredPurposeAndSecurityLevel = (
|
|
16
|
-
validateRequiredPurposeAndSecurityLevelFactory()
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should return invalid result if the state transition does not contain master key', async () => {
|
|
21
|
-
const result = await validateRequiredPurposeAndSecurityLevel([{
|
|
22
|
-
purpose: IdentityPublicKey.PURPOSES.AUTHENTICATION,
|
|
23
|
-
securityLevel: IdentityPublicKey.SECURITY_LEVELS.CRITICAL,
|
|
24
|
-
}, {
|
|
25
|
-
// this key must be filtered out
|
|
26
|
-
purpose: IdentityPublicKey.PURPOSES.AUTHENTICATION,
|
|
27
|
-
securityLevel: IdentityPublicKey.SECURITY_LEVELS.MASTER,
|
|
28
|
-
disabledAt: 42,
|
|
29
|
-
}]);
|
|
30
|
-
|
|
31
|
-
expectValidationError(result, MissingMasterPublicKeyError);
|
|
32
|
-
|
|
33
|
-
const [error] = result.getErrors();
|
|
34
|
-
|
|
35
|
-
expect(error.getCode()).to.equal(1046);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should return valid result', async () => {
|
|
39
|
-
const result = await validateRequiredPurposeAndSecurityLevel([{
|
|
40
|
-
purpose: IdentityPublicKey.PURPOSES.AUTHENTICATION,
|
|
41
|
-
securityLevel: IdentityPublicKey.SECURITY_LEVELS.MASTER,
|
|
42
|
-
}]);
|
|
43
|
-
|
|
44
|
-
expect(result).to.be.an.instanceOf(ValidationResult);
|
|
45
|
-
expect(result.isValid()).to.be.true();
|
|
46
|
-
});
|
|
47
|
-
});
|