@dashevo/wasm-dpp 0.23.0-dev.15 → 0.24.0-dev.11
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/.eslintignore +1 -0
- package/Cargo.toml +25 -0
- package/README.md +21 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +8 -0
- package/dist/lib/patchIdentifier.d.ts +2 -0
- package/dist/wasm/wasm_dpp.d.ts +2850 -0
- package/index.ts +30 -0
- package/karma.conf.js +6 -3
- package/lib/patchIdentifier.ts +37 -0
- package/lib/test/.eslintrc +9 -0
- package/lib/test/bootstrap.js +27 -0
- package/lib/test/expect/expectError.js +34 -0
- package/lib/test/karma/loader.js +6 -0
- package/lib/test/utils/generateRandomIdentifierAsync.js +14 -0
- package/package.json +31 -55
- package/scripts/build.sh +69 -0
- package/scripts/clean.sh +4 -0
- package/src/bls_adapter.rs +71 -0
- package/src/buffer.rs +15 -0
- package/src/dash_platform_protocol.rs +26 -0
- package/src/data_contract/data_contract.rs +290 -0
- package/src/data_contract/errors/data_contract_already_exists.rs +1 -0
- package/src/data_contract/errors/invalid_data_contract.rs +29 -0
- package/src/data_contract/errors/invalid_document_type.rs +33 -0
- package/src/data_contract/errors/mod.rs +37 -0
- package/src/data_contract/index.rs +61 -0
- package/src/data_contract/mod.rs +10 -0
- package/src/data_contract/state_transition/data_contract_create_transition/apply.rs +44 -0
- package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +138 -0
- package/src/data_contract/state_transition/data_contract_create_transition/validation.rs +24 -0
- package/src/data_contract/state_transition/mod.rs +3 -0
- package/src/data_contract_factory/data_contract_factory.rs +155 -0
- package/src/data_contract_factory/mod.rs +1 -0
- package/src/document/errors/document_already_exists_error.rs +28 -0
- package/src/document/errors/document_not_provided_error.rs +28 -0
- package/src/document/errors/invalid_action_name_error.rs +24 -0
- package/src/document/errors/invalid_document_action_error.rs +28 -0
- package/src/document/errors/invalid_document_error.rs +32 -0
- package/src/document/errors/invalid_initial_revision_error.rs +25 -0
- package/src/document/errors/mismatch_owners_ids_error.rs +27 -0
- package/src/document/errors/mod.rs +55 -0
- package/src/document/errors/no_documents_supplied_error.rs +22 -0
- package/src/document/mod.rs +158 -0
- package/src/document/state_transition/document_batch_transition/document_transition/document_create_transition.rs +22 -0
- package/src/document/state_transition/document_batch_transition/document_transition/document_delete_transition.rs +22 -0
- package/src/document/state_transition/document_batch_transition/document_transition/document_update_transition.rs +22 -0
- package/src/document/state_transition/document_batch_transition/document_transition/mod.rs +24 -0
- package/src/document/state_transition/document_batch_transition/mod.rs +1 -0
- package/src/document/state_transition/mod.rs +1 -0
- package/src/errors/consensus/basic/data_contract/data_contract_have_new_unique_index_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/data_contract_immutable_properties_update_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/data_contract_invalid_index_definition_update_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/data_contract_max_depth_exceed_error.rs +26 -0
- package/src/errors/consensus/basic/data_contract/data_contract_unique_indices_changed_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/duplicate_index_name_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/incompatible_data_contract_schema_error.rs +66 -0
- package/src/errors/consensus/basic/data_contract/incompatible_re2_pattern_error.rs +43 -0
- package/src/errors/consensus/basic/data_contract/index_error/duplicate_index_error.rs +39 -0
- package/src/errors/consensus/basic/data_contract/index_error/invalid_compound_index_error.rs +39 -0
- package/src/errors/consensus/basic/data_contract/index_error/invalid_index_property_type_error.rs +59 -0
- package/src/errors/consensus/basic/data_contract/index_error/invalid_indexed_property_constraint_error.rs +67 -0
- package/src/errors/consensus/basic/data_contract/index_error/mod.rs +15 -0
- package/src/errors/consensus/basic/data_contract/index_error/system_property_index_already_present_error.rs +51 -0
- package/src/errors/consensus/basic/data_contract/index_error/undefined_index_property_error.rs +51 -0
- package/src/errors/consensus/basic/data_contract/index_error/unique_indices_limit_reached_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/invalid_data_contract_id_error.rs +37 -0
- package/src/errors/consensus/basic/data_contract/invalid_data_contract_version_error.rs +36 -0
- package/src/errors/consensus/basic/data_contract/invalid_json_schema_ref_error.rs +26 -0
- package/src/errors/consensus/basic/data_contract/mod.rs +25 -0
- package/src/errors/consensus/basic/decode/mod.rs +5 -0
- package/src/errors/consensus/basic/decode/protocol_version_parsing_error.rs +29 -0
- package/src/errors/consensus/basic/decode/serialized_object_parsing_error.rs +29 -0
- package/src/errors/consensus/basic/document/data_contract_not_present_error.rs +32 -0
- package/src/errors/consensus/basic/document/duplicate_document_transitions_with_ids_error.rs +36 -0
- package/src/errors/consensus/basic/document/inconsistent_compound_index_data_error.rs +40 -0
- package/src/errors/consensus/basic/document/invalid_document_transition_action_error.rs +26 -0
- package/src/errors/consensus/basic/document/invalid_document_transition_id_error.rs +38 -0
- package/src/errors/consensus/basic/document/invalid_document_type_error.rs +39 -0
- package/src/errors/consensus/basic/document/missing_data_contract_id_error.rs +20 -0
- package/src/errors/consensus/basic/document/missing_document_transition_action_error.rs +20 -0
- package/src/errors/consensus/basic/document/missing_document_type_error.rs +20 -0
- package/src/errors/consensus/basic/document/mod.rs +19 -0
- package/src/errors/consensus/basic/identity/duplicated_identity_public_key_error.rs +32 -0
- package/src/errors/consensus/basic/identity/duplicated_identity_public_key_id_error.rs +32 -0
- package/src/errors/consensus/basic/identity/identity_asset_lock_proof_locked_transaction_mismatch_error.rs +38 -0
- package/src/errors/consensus/basic/identity/identity_asset_lock_transaction_is_not_found_error.rs +31 -0
- package/src/errors/consensus/basic/identity/identity_asset_lock_transaction_out_point_already_exists_error.rs +37 -0
- package/src/errors/consensus/basic/identity/identity_asset_lock_transaction_output_not_found_error.rs +29 -0
- package/src/errors/consensus/basic/identity/identity_insufficient_balance_error.rs +33 -0
- package/src/errors/consensus/basic/identity/invalid_asset_lock_proof_core_chain_height_error.rs +34 -0
- package/src/errors/consensus/basic/identity/invalid_asset_lock_proof_transaction_height_error.rs +34 -0
- package/src/errors/consensus/basic/identity/invalid_asset_lock_transaction_output_return_size_error.rs +29 -0
- package/src/errors/consensus/basic/identity/invalid_identity_asset_lock_transaction_error.rs +60 -0
- package/src/errors/consensus/basic/identity/invalid_identity_asset_lock_transaction_output_error.rs +29 -0
- package/src/errors/consensus/basic/identity/invalid_identity_credit_withdrawal_transition_core_fee_error.rs +29 -0
- package/src/errors/consensus/basic/identity/invalid_identity_credit_withdrawal_transition_output_script_error.rs +32 -0
- package/src/errors/consensus/basic/identity/invalid_identity_key_signature_error.rs +29 -0
- package/src/errors/consensus/basic/identity/invalid_identity_public_key_data_error.rs +39 -0
- package/src/errors/consensus/basic/identity/invalid_identity_public_key_security_level_error.rs +42 -0
- package/src/errors/consensus/basic/identity/invalid_identity_public_key_type_error.rs +30 -0
- package/src/errors/consensus/basic/identity/invalid_instant_asset_lock_proof_error.rs +22 -0
- package/src/errors/consensus/basic/identity/invalid_instant_asset_lock_proof_signature_error.rs +24 -0
- package/src/errors/consensus/basic/identity/missing_master_public_key_error.rs +22 -0
- package/src/errors/consensus/basic/identity/missing_public_key_error.rs +29 -0
- package/src/errors/consensus/basic/identity/mod.rs +45 -0
- package/src/errors/consensus/basic/incompatible_protocol_version_error.rs +32 -0
- package/src/errors/consensus/basic/invalid_identifier_error.rs +36 -0
- package/src/errors/consensus/basic/invalid_signature_public_key_security_level_error.rs +41 -0
- package/src/errors/consensus/basic/invalid_state_transition_signature_error.rs +20 -0
- package/src/errors/consensus/basic/json_schema_compilation_error.rs +26 -0
- package/src/errors/consensus/basic/json_schema_error.rs +274 -0
- package/src/errors/consensus/basic/mod.rs +30 -0
- package/src/errors/consensus/basic/public_key_is_disabled_error.rs +30 -0
- package/src/errors/consensus/basic/public_key_security_level_not_met_error.rs +41 -0
- package/src/errors/consensus/basic/state_transition/invalid_state_transition_type_error.rs +29 -0
- package/src/errors/consensus/basic/state_transition/missing_state_transition_type_error.rs +20 -0
- package/src/errors/consensus/basic/state_transition/mod.rs +7 -0
- package/src/errors/consensus/basic/state_transition/state_transition_max_size_exceeded_error.rs +36 -0
- package/src/errors/consensus/basic/test_consensus_error.rs +21 -0
- package/src/errors/consensus/basic/unsupported_protocol_version_error.rs +32 -0
- package/src/errors/consensus/basic/wrong_public_key_purpose_error.rs +37 -0
- package/src/errors/consensus/fee/balance_is_not_enough_error.rs +32 -0
- package/src/errors/consensus/fee/mod.rs +3 -0
- package/src/errors/consensus/mod.rs +4 -0
- package/src/errors/consensus/signature/identity_not_found_error.rs +29 -0
- package/src/errors/consensus/signature/mod.rs +3 -0
- package/src/errors/consensus/state/data_contract/data_contract_already_present_error.rs +31 -0
- package/src/errors/consensus/state/data_contract/data_trigger/data_trigger_condition_error.rs +74 -0
- package/src/errors/consensus/state/data_contract/data_trigger/data_trigger_execution_error.rs +82 -0
- package/src/errors/consensus/state/data_contract/data_trigger/data_trigger_invalid_result_error.rs +66 -0
- package/src/errors/consensus/state/data_contract/data_trigger/mod.rs +7 -0
- package/src/errors/consensus/state/data_contract/mod.rs +4 -0
- package/src/errors/consensus/state/document/document_already_present_error.rs +28 -0
- package/src/errors/consensus/state/document/document_not_found_error.rs +28 -0
- package/src/errors/consensus/state/document/document_owner_id_mismatch_error.rs +50 -0
- package/src/errors/consensus/state/document/document_timestamp_window_violation_error.rs +72 -0
- package/src/errors/consensus/state/document/document_timestamps_mismatch_error.rs +28 -0
- package/src/errors/consensus/state/document/duplicate_unique_index_error.rs +42 -0
- package/src/errors/consensus/state/document/invalid_document_revision_error.rs +38 -0
- package/src/errors/consensus/state/document/mod.rs +15 -0
- package/src/errors/consensus/state/identity/identity_already_exists_error.rs +28 -0
- package/src/errors/consensus/state/identity/identity_public_key_disabled_at_window_violation_error.rs +49 -0
- package/src/errors/consensus/state/identity/identity_public_key_is_disabled_error.rs +31 -0
- package/src/errors/consensus/state/identity/identity_public_key_is_read_only_error.rs +28 -0
- package/src/errors/consensus/state/identity/invalid_identity_public_key_id_error.rs +28 -0
- package/src/errors/consensus/state/identity/invalid_identity_revision_error.rs +38 -0
- package/src/errors/consensus/state/identity/max_identity_public_key_limit_reached_error.rs +26 -0
- package/src/errors/consensus/state/identity/mod.rs +15 -0
- package/src/errors/consensus/state/mod.rs +3 -0
- package/src/errors/consensus_error.rs +612 -0
- package/src/errors/from.rs +24 -0
- package/src/errors/js_conversion.rs +63 -0
- package/src/errors/mod.rs +10 -0
- package/src/errors/public_key_validation_error.rs +23 -0
- package/src/identifier.rs +103 -0
- package/src/identity.rs +253 -0
- package/src/identity_facade.rs +55 -0
- package/src/identity_public_key/key_type.rs +22 -0
- package/src/identity_public_key/mod.rs +192 -0
- package/src/identity_public_key/public_keys_validator.rs +44 -0
- package/src/identity_public_key/purpose.rs +24 -0
- package/src/identity_public_key/security_level.rs +21 -0
- package/src/lib.rs +29 -0
- package/src/metadata.rs +54 -0
- package/src/state_repository.rs +229 -0
- package/src/state_transition/mod.rs +41 -0
- package/src/utils.rs +59 -0
- package/src/validation_result.rs +41 -0
- package/test/integration/DashPlatformProtocol.spec.js +4 -4
- package/test/integration/ajv/keywords/byteArray/addByteArrayKeyword.spec.js +2 -2
- package/test/integration/dataContract/DataContractFacade.spec.js +6 -6
- package/test/integration/dataContract/stateTransition/DataContractCreateTransition/validation/basic/validateDataContractCreateTransitionBasicFactory.spec.js +10 -10
- package/test/integration/dataContract/stateTransition/DataContractUpdateTransition/validation/basic/validateDataContractUpdateTransitionBasicFactory.spec.js +14 -14
- package/test/integration/dataContract/validation/validateDataContractFactory.spec.js +22 -22
- package/test/integration/document/Document.spec.js +10 -5
- package/test/integration/document/DocumentFacade.spec.js +11 -11
- package/test/integration/document/stateTransition/DocumentsBatchTransition/DocumentBatchTransition.spec.js +5 -5
- package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/basic/validateDocumentsBatchTransitionBasicFactory.spec.js +25 -25
- package/test/integration/document/stateTransition/DocumentsBatchTransition/validation/state/executeDataTriggersFactory.spec.js +15 -15
- package/test/integration/document/validation/validateDocumentFactory.spec.js +12 -12
- package/test/integration/error/consensus/createConsensusError.spec.js +3 -3
- package/test/integration/identity/IdentityFacade.spec.js +13 -13
- package/test/integration/identity/stateTransition/IdentityCreateTransition/validation/basic/validateIdentityCreateTransitionBasicFactory.spec.js +12 -12
- package/test/integration/identity/stateTransition/IdentityTopUpTransition/validation/basic/validateIdentityTopUpTransitionBasicFactory.spec.js +11 -11
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/basic/validateIdentityUpdateTransitionBasicFactory.spec.js +8 -8
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validateIdentityUpdateTransitionStateFactory.spec.js +24 -39
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validatePublicKeysState.spec.js +7 -7
- package/test/integration/identity/stateTransition/assetLockProof/chain/validateChainAssetLockProofStructureFactory.spec.js +29 -35
- package/test/integration/identity/stateTransition/assetLockProof/fetchAssetLockTransactionOutputFactory.spec.js +8 -8
- package/test/integration/identity/stateTransition/assetLockProof/instant/validateInstantAssetLockProofStructureFactory.spec.js +11 -11
- package/test/integration/identity/stateTransition/assetLockProof/validateAssetLockTransactionFactory.spec.js +10 -10
- package/test/integration/identity/stateTransition/validatePublicKeySignaturesFactory.spec.js +7 -7
- package/test/integration/identity/validation/validateIdentityFactory.spec.js +8 -8
- package/test/integration/identity/validation/validatePublicKeysFactory.spec.js +50 -24
- package/test/integration/stateTransition/AbstractStateTransitionIdentitySigned.spec.js +14 -14
- package/test/integration/stateTransition/StateTransitionFacade.spec.js +15 -19
- package/test/integration/stateTransition/calculateStateTransitionFee.spec.js +8 -11
- package/test/integration/util/generateEntropy.spec.js +1 -1
- package/test/integration/util/serializer.spec.js +2 -2
- package/test/unit/DashPlatformProtocol.spec.js +4 -4
- package/test/unit/Identifier.spec.js +2 -2
- package/test/unit/Metadata.spec.js +1 -1
- package/test/unit/dataContract/DataContract.spec.js +100 -159
- package/test/unit/dataContract/DataContractFactory.spec.js +55 -111
- package/test/unit/dataContract/createDataContract.spec.js +20 -10
- package/test/unit/dataContract/errors/InvalidDataContractError.spec.js +2 -2
- package/test/unit/dataContract/generateDataContractId.spec.js +23 -6
- package/test/unit/dataContract/getBinaryPropertiesFromSchema.spec.js +1 -1
- package/test/unit/dataContract/getPropertyDefinitionByPath.spec.js +1 -1
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +20 -67
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/applyDataContractCreateTransitionFactory.spec.js +29 -23
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/validation/state/validateDataContractCreateTransitionStateFactory.spec.js +48 -45
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +8 -8
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/applyDataContractUpdateTransitionFactory.spec.js +6 -6
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/basic/validateIndicesAreBackwardCompatible.spec.js +6 -6
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/state/validateDataContractUpdateTransitionStateFactory.spec.js +9 -9
- package/test/unit/dataContract/validation/validateDataContractMaxDepthFactory.spec.js +6 -6
- package/test/unit/dataContract/validation/validateDataContractPatternsFactory.spec.js +3 -3
- package/test/unit/dataTrigger/DataTrigger.spec.js +8 -8
- package/test/unit/dataTrigger/DataTriggerExecutionContext.spec.js +4 -4
- package/test/unit/dataTrigger/dashpayDataTriggers/createContactRequestDataTrigger.spec.js +13 -15
- package/test/unit/dataTrigger/dpnsTriggers/createDomainDataTrigger.spec.js +12 -12
- package/test/unit/dataTrigger/featureFlagDataTriggers/createFeatureFlagDataTrigger.spec.js +11 -13
- package/test/unit/dataTrigger/getDataTriggersFactory.spec.js +7 -7
- package/test/unit/dataTrigger/rejectDataTrigger.spec.js +8 -8
- package/test/unit/dataTrigger/rewardShareDataTriggers/createMasternodeRewardSharesDataTrigger.spec.js +9 -9
- package/test/unit/decodeProtocolEntityFactory.spec.js +4 -4
- package/test/unit/document/Document.spec.js +9 -9
- package/test/unit/document/DocumentFactory.spec.js +19 -19
- package/test/unit/document/errors/InvalidDocumentError.spec.js +2 -2
- package/test/unit/document/fetchAndValidateDataContractFactory.spec.js +8 -8
- package/test/unit/document/stateTransition/DocumetsBatchTransition/DocumentsBatchTransition.spec.js +8 -8
- package/test/unit/document/stateTransition/DocumetsBatchTransition/applyDocumentsBatchTransitionFactory.spec.js +16 -17
- package/test/unit/document/stateTransition/DocumetsBatchTransition/documentTransition/DocumentCreateTransition.spec.js +1 -1
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/findDuplicatesById.spec.js +2 -2
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/findDuplicatesByIndices.spec.js +6 -6
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/basic/validatePartialCompoundIndices.spec.js +7 -7
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/fetchDocumentsFactory.spec.js +6 -6
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsBatchTransitionStateFactory.spec.js +27 -34
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsUniquenessByIndicesFactory.spec.js +9 -9
- package/test/unit/errors/consensus/codes.spec.js +7 -7
- package/test/unit/identity/Identity.spec.js +98 -69
- package/test/unit/identity/IdentityFactory.spec.js +15 -15
- package/test/unit/identity/IdentityPublicKey.spec.js +53 -66
- package/test/unit/identity/creditsConverter.spec.js +1 -1
- package/test/unit/identity/errors/InvalidIdentityError.spec.js +2 -2
- package/test/unit/identity/stateTransition/IdentityCreateTransition/IdentityCreateTransition.spec.js +7 -7
- package/test/unit/identity/stateTransition/IdentityCreateTransition/applyIdentityCreateTransitionFactory.spec.js +8 -8
- package/test/unit/identity/stateTransition/IdentityCreateTransition/validation/state/validateIdentityCreateTransitionStateFactory.spec.js +6 -6
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/IdentityTopUpTransition.spec.js +4 -4
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/applyIdentityTopUpTransitionFactory.spec.js +7 -7
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/validation/state/validateIdentityTopUpTransitionStateFactory.spec.js +2 -2
- package/test/unit/identity/stateTransition/IdentityUpdateTransition/IdentityUpdateTransition.spec.js +6 -6
- package/test/unit/identity/stateTransition/IdentityUpdateTransition/applyIdentityUpdateTransitionFactory.spec.js +6 -6
- package/test/unit/identity/stateTransition/assetLockProof/createAssetLockProofInstance.spec.js +5 -5
- package/test/unit/identity/stateTransition/assetLockProof/fetchAssetLockPublicKeyHashFactory.spec.js +3 -3
- package/test/unit/identity/validation/validateRequiredPurposeAndSecurityLevelFactory.spec.js +5 -5
- package/test/unit/stateTransition/StateTransitionFactory.spec.js +8 -8
- package/test/unit/stateTransition/createStateTransitionFactory.spec.js +8 -8
- package/test/unit/stateTransition/errors/InvalidStateTransitionError.spec.js +3 -3
- package/test/unit/stateTransition/validation/validateStateTransitionBasicFactory.spec.js +12 -12
- package/test/unit/stateTransition/validation/validateStateTransitionFeeFactory.spec.js +15 -15
- package/test/unit/stateTransition/validation/validateStateTransitionIdentitySignatureFactory.spec.js +22 -22
- package/test/unit/stateTransition/validation/validateStateTransitionKeySignatureFactory.spec.js +6 -6
- package/test/unit/stateTransition/validation/validateStateTransitionStateFactory.spec.js +9 -9
- package/test/unit/version/validateProtocolVersionFactory.spec.js +7 -7
- package/tsconfig.json +18 -0
- package/wasm/wasm_dpp.d.ts +2850 -0
- package/wasm/wasm_dpp.js +7978 -0
- package/wasm/wasm_dpp_bg.js +1 -0
- package/wasm/wasm_dpp_bg.wasm +0 -0
- package/wasm/wasm_dpp_bg.wasm.d.ts +536 -0
- package/webpack.config.js +22 -19
- package/CHANGELOG.md +0 -397
|
@@ -1,32 +1,42 @@
|
|
|
1
|
-
const
|
|
1
|
+
const JSIdentityPublicKey = require('@dashevo/dpp/lib/identity/IdentityPublicKey');
|
|
2
|
+
const protocolVersion = require('@dashevo/dpp/lib/version/protocolVersion');
|
|
3
|
+
const JSIdentity = require('@dashevo/dpp/lib/identity/Identity');
|
|
2
4
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const Identity = require('../../../lib/identity/Identity');
|
|
8
|
-
const serializer = require('../../../lib/util/serializer');
|
|
9
|
-
const hash = require('../../../lib/util/hash');
|
|
5
|
+
const { hash: hashFunction } = require('@dashevo/dpp/lib/util/hash');
|
|
6
|
+
const { expect } = require('chai');
|
|
7
|
+
const generateRandomIdentifierAsync = require('../../../lib/test/utils/generateRandomIdentifierAsync');
|
|
8
|
+
const { default: loadWasmDpp } = require('../../../dist');
|
|
10
9
|
|
|
11
10
|
describe('Identity', () => {
|
|
12
11
|
let rawIdentity;
|
|
13
12
|
let identity;
|
|
14
|
-
let hashMock;
|
|
15
|
-
let encodeMock;
|
|
16
13
|
let metadataFixture;
|
|
14
|
+
let Identity;
|
|
15
|
+
let Metadata;
|
|
16
|
+
let IdentityPublicKey;
|
|
17
|
+
let KeyPurpose;
|
|
18
|
+
let KeyType;
|
|
19
|
+
let KeySecurityLevel;
|
|
20
|
+
|
|
21
|
+
before(async () => {
|
|
22
|
+
({
|
|
23
|
+
Identity, Metadata, IdentityPublicKey, KeyPurpose, KeyType, KeySecurityLevel,
|
|
24
|
+
} = await loadWasmDpp());
|
|
25
|
+
});
|
|
17
26
|
|
|
18
|
-
beforeEach(
|
|
27
|
+
beforeEach(async () => {
|
|
19
28
|
rawIdentity = {
|
|
20
29
|
protocolVersion: protocolVersion.latestVersion,
|
|
21
|
-
id:
|
|
30
|
+
id: await generateRandomIdentifierAsync(),
|
|
22
31
|
publicKeys: [
|
|
23
32
|
{
|
|
24
33
|
id: 0,
|
|
25
|
-
type:
|
|
34
|
+
type: KeyType.ECDSA_SECP256K1,
|
|
26
35
|
data: Buffer.alloc(36).fill('a'),
|
|
27
|
-
purpose:
|
|
28
|
-
securityLevel:
|
|
36
|
+
purpose: KeyPurpose.AUTHENTICATION,
|
|
37
|
+
securityLevel: KeySecurityLevel.MASTER,
|
|
29
38
|
readOnly: false,
|
|
39
|
+
signature: Buffer.alloc(36).fill('a'),
|
|
30
40
|
},
|
|
31
41
|
],
|
|
32
42
|
balance: 0,
|
|
@@ -39,45 +49,62 @@ describe('Identity', () => {
|
|
|
39
49
|
|
|
40
50
|
identity.setMetadata(metadataFixture);
|
|
41
51
|
|
|
42
|
-
|
|
43
|
-
hashMock = this.sinonSandbox.stub(hash, 'hash');
|
|
52
|
+
metadataFixture = new Metadata(42, 0);
|
|
44
53
|
});
|
|
45
54
|
|
|
46
55
|
afterEach(() => {
|
|
47
|
-
encodeMock.restore();
|
|
48
|
-
hashMock.restore();
|
|
49
56
|
});
|
|
50
57
|
|
|
51
58
|
describe('#constructor', () => {
|
|
52
59
|
it('should set variables from raw model', () => {
|
|
53
|
-
const instance =
|
|
60
|
+
const instance = identity;
|
|
54
61
|
|
|
55
|
-
expect(instance.
|
|
56
|
-
expect(
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
expect(instance.getId().toBuffer()).to.deep.equal(rawIdentity.id.toBuffer());
|
|
63
|
+
expect(
|
|
64
|
+
instance.getPublicKeys().map((pk) => pk.toObject()),
|
|
65
|
+
).to.deep.equal(
|
|
66
|
+
rawIdentity.publicKeys,
|
|
59
67
|
);
|
|
60
68
|
});
|
|
61
69
|
});
|
|
62
70
|
|
|
63
71
|
describe('#getId', () => {
|
|
64
72
|
it('should return set id', () => {
|
|
65
|
-
expect(identity.getId()).to.deep.equal(rawIdentity.id);
|
|
73
|
+
expect(identity.getId().toBuffer()).to.deep.equal(rawIdentity.id.toBuffer());
|
|
66
74
|
});
|
|
67
75
|
});
|
|
68
76
|
|
|
69
77
|
describe('#getPublicKeys', () => {
|
|
70
78
|
it('should return set public keys', () => {
|
|
71
|
-
expect(identity.getPublicKeys()).to.deep.equal(
|
|
72
|
-
rawIdentity.publicKeys
|
|
79
|
+
expect(identity.getPublicKeys().map((pk) => pk.toObject())).to.deep.equal(
|
|
80
|
+
rawIdentity.publicKeys,
|
|
73
81
|
);
|
|
74
82
|
});
|
|
75
83
|
});
|
|
76
84
|
|
|
77
85
|
describe('#setPublicKeys', () => {
|
|
86
|
+
it('should reject input which is not array of public keys', () => {
|
|
87
|
+
expect(() => { identity.setPublicKeys(42); })
|
|
88
|
+
.throws("Setting public keys failed. The input ('42') is invalid. You must use array of PublicKeys");
|
|
89
|
+
expect(identity.getPublicKeys()).length(1);
|
|
90
|
+
});
|
|
91
|
+
|
|
78
92
|
it('should set public keys', () => {
|
|
79
|
-
|
|
80
|
-
|
|
93
|
+
const rawKey = {
|
|
94
|
+
id: 2,
|
|
95
|
+
type: KeyType.ECDSA_SECP256K1,
|
|
96
|
+
data: Buffer.alloc(36).fill('a'),
|
|
97
|
+
purpose: KeyPurpose.AUTHENTICATION,
|
|
98
|
+
securityLevel: KeySecurityLevel.MASTER,
|
|
99
|
+
signature: Buffer.alloc(36).fill('a'),
|
|
100
|
+
readOnly: false,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const ipk = new JSIdentityPublicKey(rawKey);
|
|
104
|
+
|
|
105
|
+
identity.setPublicKeys([ipk]);
|
|
106
|
+
expect(identity.getPublicKeys()).length(1);
|
|
107
|
+
expect(identity.getPublicKeys()[0].toObject()).to.be.deep.equal(rawKey);
|
|
81
108
|
});
|
|
82
109
|
});
|
|
83
110
|
|
|
@@ -85,7 +112,11 @@ describe('Identity', () => {
|
|
|
85
112
|
it('should return a public key for a given id', () => {
|
|
86
113
|
const key = identity.getPublicKeyById(0);
|
|
87
114
|
|
|
88
|
-
expect(
|
|
115
|
+
expect(
|
|
116
|
+
key.toObject(),
|
|
117
|
+
).to.be.deep.equal(
|
|
118
|
+
rawIdentity.publicKeys[0],
|
|
119
|
+
);
|
|
89
120
|
});
|
|
90
121
|
|
|
91
122
|
it("should return undefined if there's no key with such id", () => {
|
|
@@ -95,30 +126,20 @@ describe('Identity', () => {
|
|
|
95
126
|
});
|
|
96
127
|
|
|
97
128
|
describe('#toBuffer', () => {
|
|
98
|
-
it('should return
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
129
|
+
it('should return the same buffer as JS Identity', () => {
|
|
130
|
+
// Due to browser polyfill, we got two different versions of buffers, and makes
|
|
131
|
+
// the compatibility test to fail in karma, so hence this hack here.
|
|
132
|
+
rawIdentity.id = Buffer.from(rawIdentity.id.toBuffer());
|
|
133
|
+
const oldIdentity = new JSIdentity(rawIdentity);
|
|
102
134
|
const result = identity.toBuffer();
|
|
103
135
|
|
|
104
|
-
|
|
105
|
-
delete identityDataToEncode.protocolVersion;
|
|
106
|
-
|
|
107
|
-
const protocolVersionUInt32 = Buffer.alloc(4);
|
|
108
|
-
protocolVersionUInt32.writeUInt32LE(identity.getProtocolVersion(), 0);
|
|
109
|
-
|
|
110
|
-
expect(encodeMock).to.have.been.calledOnceWith(identityDataToEncode);
|
|
111
|
-
expect(result).to.deep.equal(Buffer.concat([protocolVersionUInt32, encodeMockData]));
|
|
136
|
+
expect(result).to.deep.eq(oldIdentity.toBuffer());
|
|
112
137
|
});
|
|
113
138
|
});
|
|
114
139
|
|
|
115
140
|
describe('#hash', () => {
|
|
116
|
-
it('should return
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
encodeMock.returns(buffer);
|
|
120
|
-
hashMock.returns(buffer);
|
|
121
|
-
|
|
141
|
+
it('should return the same has as JS Identity', () => {
|
|
142
|
+
const expectedHash = hashFunction(identity.toBuffer());
|
|
122
143
|
const result = identity.hash();
|
|
123
144
|
|
|
124
145
|
const identityDataToEncode = identity.toObject();
|
|
@@ -127,15 +148,18 @@ describe('Identity', () => {
|
|
|
127
148
|
const protocolVersionUInt32 = Buffer.alloc(4);
|
|
128
149
|
protocolVersionUInt32.writeUInt32LE(identity.getProtocolVersion(), 0);
|
|
129
150
|
|
|
130
|
-
expect(
|
|
131
|
-
expect(hashMock).to.have.been.calledOnceWith(Buffer.concat([protocolVersionUInt32, buffer]));
|
|
132
|
-
expect(result).to.equal(buffer);
|
|
151
|
+
expect(result).to.deep.equal(expectedHash);
|
|
133
152
|
});
|
|
134
153
|
});
|
|
135
154
|
|
|
136
155
|
describe('#toObject', () => {
|
|
137
156
|
it('should return plain object representation', () => {
|
|
138
|
-
|
|
157
|
+
const identityObject = identity.toObject();
|
|
158
|
+
|
|
159
|
+
// We can't compare Identifier directly - it needs to be converted into a Buffer
|
|
160
|
+
rawIdentity.id = rawIdentity.id.toBuffer();
|
|
161
|
+
|
|
162
|
+
expect(identityObject).to.deep.equal(rawIdentity);
|
|
139
163
|
});
|
|
140
164
|
});
|
|
141
165
|
|
|
@@ -149,10 +173,11 @@ describe('Identity', () => {
|
|
|
149
173
|
publicKeys: [
|
|
150
174
|
{
|
|
151
175
|
id: 0,
|
|
152
|
-
type:
|
|
176
|
+
type: KeyType.ECDSA_SECP256K1,
|
|
153
177
|
data: rawIdentity.publicKeys[0].data.toString('base64'),
|
|
154
|
-
purpose:
|
|
155
|
-
securityLevel:
|
|
178
|
+
purpose: KeyPurpose.AUTHENTICATION,
|
|
179
|
+
securityLevel: KeySecurityLevel.MASTER,
|
|
180
|
+
signature: rawIdentity.publicKeys[0].signature.toString('base64'),
|
|
156
181
|
readOnly: false,
|
|
157
182
|
},
|
|
158
183
|
],
|
|
@@ -164,7 +189,7 @@ describe('Identity', () => {
|
|
|
164
189
|
|
|
165
190
|
describe('#getBalance', () => {
|
|
166
191
|
it('should return set identity balance', () => {
|
|
167
|
-
identity.
|
|
192
|
+
identity.setBalance(42);
|
|
168
193
|
expect(identity.getBalance()).to.equal(42);
|
|
169
194
|
});
|
|
170
195
|
});
|
|
@@ -172,7 +197,7 @@ describe('Identity', () => {
|
|
|
172
197
|
describe('#setBalance', () => {
|
|
173
198
|
it('should set identity balance', () => {
|
|
174
199
|
identity.setBalance(42);
|
|
175
|
-
expect(identity.
|
|
200
|
+
expect(identity.getBalance()).to.equal(42);
|
|
176
201
|
});
|
|
177
202
|
});
|
|
178
203
|
|
|
@@ -181,54 +206,57 @@ describe('Identity', () => {
|
|
|
181
206
|
const result = identity.increaseBalance(42);
|
|
182
207
|
|
|
183
208
|
expect(result).to.equal(42);
|
|
184
|
-
expect(identity.
|
|
209
|
+
expect(identity.getBalance()).to.equal(42);
|
|
185
210
|
});
|
|
186
211
|
});
|
|
187
212
|
|
|
188
213
|
describe('#reduceBalance', () => {
|
|
189
214
|
it('should reduce identity balance', () => {
|
|
190
|
-
identity.
|
|
215
|
+
identity.setBalance(42);
|
|
191
216
|
|
|
192
217
|
const result = identity.reduceBalance(2);
|
|
193
218
|
|
|
194
219
|
expect(result).to.equal(40);
|
|
195
|
-
expect(identity.
|
|
220
|
+
expect(identity.getBalance()).to.equal(40);
|
|
196
221
|
});
|
|
197
222
|
});
|
|
198
223
|
|
|
199
224
|
describe('#setMetadata', () => {
|
|
200
225
|
it('should set metadata', () => {
|
|
201
226
|
const otherMetadata = new Metadata(43, 1);
|
|
227
|
+
const expectedMetadata = new Metadata(43, 1);
|
|
202
228
|
|
|
203
229
|
identity.setMetadata(otherMetadata);
|
|
204
230
|
|
|
205
|
-
expect(identity.
|
|
231
|
+
expect(identity.getMetadata().toObject()).to.deep.equal(expectedMetadata.toObject());
|
|
206
232
|
});
|
|
207
233
|
});
|
|
208
234
|
|
|
209
235
|
describe('#getMetadata', () => {
|
|
210
236
|
it('should get metadata', () => {
|
|
211
|
-
expect(identity.getMetadata()).to.deep.equal(metadataFixture);
|
|
237
|
+
expect(identity.getMetadata().toObject()).to.deep.equal(metadataFixture.toObject());
|
|
212
238
|
});
|
|
213
239
|
});
|
|
214
240
|
|
|
215
241
|
describe('#getPublicKeyMaxId', () => {
|
|
216
242
|
it('should get the biggest public key ID', () => {
|
|
217
|
-
identity.
|
|
243
|
+
identity.addPublicKeys(
|
|
218
244
|
new IdentityPublicKey({
|
|
219
245
|
id: 99,
|
|
220
|
-
type:
|
|
246
|
+
type: KeyType.ECDSA_SECP256K1,
|
|
221
247
|
data: Buffer.alloc(36).fill('a'),
|
|
222
|
-
purpose:
|
|
223
|
-
securityLevel:
|
|
248
|
+
purpose: KeyPurpose.AUTHENTICATION,
|
|
249
|
+
securityLevel: KeySecurityLevel.MASTER,
|
|
250
|
+
signature: Buffer.alloc(36).fill('a'),
|
|
224
251
|
readOnly: false,
|
|
225
252
|
}),
|
|
226
253
|
new IdentityPublicKey({
|
|
227
254
|
id: 50,
|
|
228
|
-
type:
|
|
255
|
+
type: KeyType.ECDSA_SECP256K1,
|
|
229
256
|
data: Buffer.alloc(36).fill('a'),
|
|
230
|
-
purpose:
|
|
231
|
-
securityLevel:
|
|
257
|
+
purpose: KeyPurpose.AUTHENTICATION,
|
|
258
|
+
securityLevel: KeySecurityLevel.MASTER,
|
|
259
|
+
signature: Buffer.alloc(36).fill('a'),
|
|
232
260
|
readOnly: false,
|
|
233
261
|
}),
|
|
234
262
|
);
|
|
@@ -237,6 +265,7 @@ describe('Identity', () => {
|
|
|
237
265
|
|
|
238
266
|
const publicKeyIds = identity.getPublicKeys().map((publicKey) => publicKey.getId());
|
|
239
267
|
|
|
268
|
+
expect(Math.max(...publicKeyIds)).to.equal(99);
|
|
240
269
|
expect(Math.max(...publicKeyIds)).to.equal(maxId);
|
|
241
270
|
});
|
|
242
271
|
});
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
const { PublicKey } = require('@dashevo/dashcore-lib');
|
|
2
|
-
const Identity = require('
|
|
3
|
-
const IdentityCreateTransition = require('
|
|
4
|
-
const IdentityTopUpTransition = require('
|
|
2
|
+
const Identity = require('@dashevo/dpp/lib/identity/Identity');
|
|
3
|
+
const IdentityCreateTransition = require('@dashevo/dpp/lib/identity/stateTransition/IdentityCreateTransition/IdentityCreateTransition');
|
|
4
|
+
const IdentityTopUpTransition = require('@dashevo/dpp/lib/identity/stateTransition/IdentityTopUpTransition/IdentityTopUpTransition');
|
|
5
5
|
|
|
6
|
-
const getIdentityFixture = require('
|
|
6
|
+
const getIdentityFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityFixture');
|
|
7
7
|
|
|
8
|
-
const ValidationResult = require('
|
|
9
|
-
const SerializedObjectParsingError = require('
|
|
8
|
+
const ValidationResult = require('@dashevo/dpp/lib/validation/ValidationResult');
|
|
9
|
+
const SerializedObjectParsingError = require('@dashevo/dpp/lib/errors/consensus/basic/decode/SerializedObjectParsingError');
|
|
10
10
|
|
|
11
11
|
const InvalidIdentityError = require(
|
|
12
|
-
'
|
|
12
|
+
'@dashevo/dpp/lib/identity/errors/InvalidIdentityError',
|
|
13
13
|
);
|
|
14
|
-
const getInstantAssetLockProofFixture = require('
|
|
15
|
-
const InstantAssetLockProof = require('
|
|
16
|
-
const getChainAssetLockProofFixture = require('
|
|
17
|
-
const createDPPMock = require('
|
|
18
|
-
const SomeConsensusError = require('
|
|
19
|
-
const IdentityFactory = require('
|
|
20
|
-
const IdentityUpdateTransition = require('
|
|
21
|
-
const IdentityPublicKey = require('
|
|
14
|
+
const getInstantAssetLockProofFixture = require('@dashevo/dpp/lib/test/fixtures/getInstantAssetLockProofFixture');
|
|
15
|
+
const InstantAssetLockProof = require('@dashevo/dpp/lib/identity/stateTransition/assetLockProof/instant/InstantAssetLockProof');
|
|
16
|
+
const getChainAssetLockProofFixture = require('@dashevo/dpp/lib/test/fixtures/getChainAssetLockProofFixture');
|
|
17
|
+
const createDPPMock = require('@dashevo/dpp/lib/test/mocks/createDPPMock');
|
|
18
|
+
const SomeConsensusError = require('@dashevo/dpp/lib/test/mocks/SomeConsensusError');
|
|
19
|
+
const IdentityFactory = require('@dashevo/dpp/lib/identity/IdentityFactory');
|
|
20
|
+
const IdentityUpdateTransition = require('@dashevo/dpp/lib/identity/stateTransition/IdentityUpdateTransition/IdentityUpdateTransition');
|
|
21
|
+
const IdentityPublicKey = require('@dashevo/dpp/lib/identity/IdentityPublicKey');
|
|
22
22
|
|
|
23
23
|
describe('IdentityFactory', () => {
|
|
24
24
|
let factory;
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
const
|
|
2
|
-
const EmptyPublicKeyDataError = require('../../../lib/identity/errors/EmptyPublicKeyDataError');
|
|
1
|
+
const { default: loadWasmDpp } = require('@dashevo/wasm-dpp');
|
|
3
2
|
|
|
4
3
|
describe('IdentityPublicKey', () => {
|
|
5
4
|
let rawPublicKey;
|
|
6
5
|
let publicKey;
|
|
6
|
+
let IdentityPublicKey;
|
|
7
|
+
let KeyPurpose;
|
|
8
|
+
let KeyType;
|
|
9
|
+
let KeySecurityLevel;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
({
|
|
13
|
+
IdentityPublicKey, KeyPurpose, KeyType, KeySecurityLevel,
|
|
14
|
+
} = await loadWasmDpp());
|
|
7
15
|
|
|
8
|
-
beforeEach(() => {
|
|
9
16
|
rawPublicKey = {
|
|
10
17
|
id: 0,
|
|
11
|
-
type:
|
|
18
|
+
type: KeyType.ECDSA_SECP256K1,
|
|
12
19
|
data: Buffer.from('AkVuTKyF3YgKLAQlLEtaUL2HTditwGILfWUVqjzYnIgH', 'base64'),
|
|
13
|
-
purpose:
|
|
14
|
-
securityLevel:
|
|
20
|
+
purpose: KeyPurpose.AUTHENTICATION,
|
|
21
|
+
securityLevel: KeySecurityLevel.MASTER,
|
|
15
22
|
readOnly: false,
|
|
16
23
|
};
|
|
17
24
|
|
|
@@ -19,20 +26,12 @@ describe('IdentityPublicKey', () => {
|
|
|
19
26
|
});
|
|
20
27
|
|
|
21
28
|
describe('#constructor', () => {
|
|
22
|
-
it('should not set anything if nothing passed', () => {
|
|
23
|
-
const instance = new IdentityPublicKey();
|
|
24
|
-
|
|
25
|
-
expect(instance.id).to.be.undefined();
|
|
26
|
-
expect(instance.type).to.be.undefined();
|
|
27
|
-
expect(instance.data).to.be.undefined();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
29
|
it('should set variables from raw model', () => {
|
|
31
30
|
const instance = new IdentityPublicKey(rawPublicKey);
|
|
32
31
|
|
|
33
|
-
expect(instance.
|
|
34
|
-
expect(instance.
|
|
35
|
-
expect(instance.
|
|
32
|
+
expect(instance.getId()).to.equal(rawPublicKey.id);
|
|
33
|
+
expect(instance.getType()).to.equal(rawPublicKey.type);
|
|
34
|
+
expect(instance.getData()).to.deep.equal(rawPublicKey.data);
|
|
36
35
|
});
|
|
37
36
|
});
|
|
38
37
|
|
|
@@ -46,29 +45,29 @@ describe('IdentityPublicKey', () => {
|
|
|
46
45
|
it('should set id', () => {
|
|
47
46
|
publicKey.setId(42);
|
|
48
47
|
|
|
49
|
-
expect(publicKey.
|
|
48
|
+
expect(publicKey.getId()).to.equal(42);
|
|
50
49
|
});
|
|
51
50
|
});
|
|
52
51
|
|
|
53
52
|
describe('#getType', () => {
|
|
54
53
|
it('should return set type', () => {
|
|
55
|
-
publicKey.
|
|
54
|
+
publicKey.setType(3);
|
|
56
55
|
|
|
57
|
-
expect(publicKey.getType()).to.equal(
|
|
56
|
+
expect(publicKey.getType()).to.equal(3);
|
|
58
57
|
});
|
|
59
58
|
});
|
|
60
59
|
|
|
61
60
|
describe('#setType', () => {
|
|
62
61
|
it('should set type', () => {
|
|
63
|
-
publicKey.setType(
|
|
62
|
+
publicKey.setType(3);
|
|
64
63
|
|
|
65
|
-
expect(publicKey.
|
|
64
|
+
expect(publicKey.getType()).to.equal(3);
|
|
66
65
|
});
|
|
67
66
|
});
|
|
68
67
|
|
|
69
68
|
describe('#getData', () => {
|
|
70
69
|
it('should return set data', () => {
|
|
71
|
-
expect(publicKey.getData()).to.equal(rawPublicKey.data);
|
|
70
|
+
expect(publicKey.getData()).to.be.deep.equal(rawPublicKey.data);
|
|
72
71
|
});
|
|
73
72
|
});
|
|
74
73
|
|
|
@@ -78,7 +77,7 @@ describe('IdentityPublicKey', () => {
|
|
|
78
77
|
|
|
79
78
|
publicKey.setData(buffer);
|
|
80
79
|
|
|
81
|
-
expect(publicKey.
|
|
80
|
+
expect(publicKey.getData()).to.be.deep.equal(buffer);
|
|
82
81
|
});
|
|
83
82
|
});
|
|
84
83
|
|
|
@@ -90,9 +89,9 @@ describe('IdentityPublicKey', () => {
|
|
|
90
89
|
|
|
91
90
|
describe('#setPurpose', () => {
|
|
92
91
|
it('should set data', () => {
|
|
93
|
-
publicKey.setPurpose(
|
|
92
|
+
publicKey.setPurpose(KeyPurpose.DECRYPTION);
|
|
94
93
|
|
|
95
|
-
expect(publicKey.
|
|
94
|
+
expect(publicKey.getPurpose()).to.equal(KeyPurpose.DECRYPTION);
|
|
96
95
|
});
|
|
97
96
|
});
|
|
98
97
|
|
|
@@ -104,9 +103,9 @@ describe('IdentityPublicKey', () => {
|
|
|
104
103
|
|
|
105
104
|
describe('#setSecurityLevel', () => {
|
|
106
105
|
it('should set data', () => {
|
|
107
|
-
publicKey.setSecurityLevel(
|
|
106
|
+
publicKey.setSecurityLevel(KeySecurityLevel.MEDIUM);
|
|
108
107
|
|
|
109
|
-
expect(publicKey.
|
|
108
|
+
expect(publicKey.getSecurityLevel()).to.equal(KeySecurityLevel.MEDIUM);
|
|
110
109
|
});
|
|
111
110
|
});
|
|
112
111
|
|
|
@@ -120,7 +119,7 @@ describe('IdentityPublicKey', () => {
|
|
|
120
119
|
it('should set readOnly', () => {
|
|
121
120
|
publicKey.setReadOnly(true);
|
|
122
121
|
|
|
123
|
-
expect(publicKey.
|
|
122
|
+
expect(publicKey.isReadOnly()).to.equal(true);
|
|
124
123
|
});
|
|
125
124
|
});
|
|
126
125
|
|
|
@@ -128,13 +127,13 @@ describe('IdentityPublicKey', () => {
|
|
|
128
127
|
it('should set disabledAt', () => {
|
|
129
128
|
publicKey.setDisabledAt(123);
|
|
130
129
|
|
|
131
|
-
expect(publicKey.
|
|
130
|
+
expect(publicKey.getDisabledAt()).to.equal(123);
|
|
132
131
|
});
|
|
133
132
|
});
|
|
134
133
|
|
|
135
134
|
describe('#getDisabledAt', () => {
|
|
136
135
|
it('should return disabledAt', () => {
|
|
137
|
-
publicKey.
|
|
136
|
+
publicKey.setDisabledAt(42);
|
|
138
137
|
|
|
139
138
|
expect(publicKey.getDisabledAt()).to.equal(42);
|
|
140
139
|
});
|
|
@@ -152,10 +151,12 @@ describe('IdentityPublicKey', () => {
|
|
|
152
151
|
it('should return data in case ECDSA_HASH160', () => {
|
|
153
152
|
rawPublicKey = {
|
|
154
153
|
id: 0,
|
|
155
|
-
type:
|
|
154
|
+
type: KeyType.ECDSA_HASH160,
|
|
156
155
|
data: Buffer.from('AkVuTKyF3YgKLAQlLEtaUL2HTditwGILfWUVqjzYnIgH', 'base64'),
|
|
157
|
-
purpose:
|
|
158
|
-
securityLevel:
|
|
156
|
+
purpose: KeyPurpose.AUTHENTICATION,
|
|
157
|
+
securityLevel: KeySecurityLevel.MASTER,
|
|
158
|
+
readOnly: false,
|
|
159
|
+
disabledAt: 123,
|
|
159
160
|
};
|
|
160
161
|
|
|
161
162
|
publicKey = new IdentityPublicKey(rawPublicKey);
|
|
@@ -170,10 +171,12 @@ describe('IdentityPublicKey', () => {
|
|
|
170
171
|
it('should return original public key hash in case BLS12_381', () => {
|
|
171
172
|
rawPublicKey = {
|
|
172
173
|
id: 0,
|
|
173
|
-
type:
|
|
174
|
+
type: KeyType.BLS12_381,
|
|
174
175
|
data: Buffer.from('01fac99ca2c8f39c286717c213e190aba4b7af76db320ec43f479b7d9a2012313a0ae59ca576edf801444bc694686694', 'hex'),
|
|
175
|
-
purpose:
|
|
176
|
-
securityLevel:
|
|
176
|
+
purpose: KeyPurpose.AUTHENTICATION,
|
|
177
|
+
securityLevel: KeySecurityLevel.MASTER,
|
|
178
|
+
readOnly: false,
|
|
179
|
+
disabledAt: 123,
|
|
177
180
|
};
|
|
178
181
|
|
|
179
182
|
publicKey = new IdentityPublicKey(rawPublicKey);
|
|
@@ -188,10 +191,12 @@ describe('IdentityPublicKey', () => {
|
|
|
188
191
|
it('should return data in case BIP13_SCRIPT_HASH', () => {
|
|
189
192
|
rawPublicKey = {
|
|
190
193
|
id: 0,
|
|
191
|
-
type:
|
|
194
|
+
type: KeyType.BIP13_SCRIPT_HASH,
|
|
192
195
|
data: Buffer.from('54c557e07dde5bb6cb791c7a540e0a4796f5e97e', 'hex'),
|
|
193
|
-
purpose:
|
|
194
|
-
securityLevel:
|
|
196
|
+
purpose: KeyPurpose.AUTHENTICATION,
|
|
197
|
+
securityLevel: KeySecurityLevel.MASTER,
|
|
198
|
+
readOnly: false,
|
|
199
|
+
disabledAt: 123,
|
|
195
200
|
};
|
|
196
201
|
|
|
197
202
|
publicKey = new IdentityPublicKey(rawPublicKey);
|
|
@@ -202,24 +207,6 @@ describe('IdentityPublicKey', () => {
|
|
|
202
207
|
|
|
203
208
|
expect(result).to.deep.equal(expectedHash);
|
|
204
209
|
});
|
|
205
|
-
|
|
206
|
-
it('should throw invalid argument error if data was not originally provided', async () => {
|
|
207
|
-
publicKey = new IdentityPublicKey({
|
|
208
|
-
id: 0,
|
|
209
|
-
type: IdentityPublicKey.TYPES.ECDSA_SECP256K1,
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
try {
|
|
213
|
-
publicKey.hash();
|
|
214
|
-
|
|
215
|
-
expect.fail('Error was not thrown');
|
|
216
|
-
} catch (e) {
|
|
217
|
-
expect(e).to.be.an.instanceOf(EmptyPublicKeyDataError);
|
|
218
|
-
expect(e.message).to.equal(
|
|
219
|
-
'Public key data is not set',
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
210
|
});
|
|
224
211
|
|
|
225
212
|
describe('#toJSON', () => {
|
|
@@ -228,10 +215,10 @@ describe('IdentityPublicKey', () => {
|
|
|
228
215
|
|
|
229
216
|
expect(jsonPublicKey).to.deep.equal({
|
|
230
217
|
id: 0,
|
|
231
|
-
type:
|
|
218
|
+
type: KeyType.ECDSA_SECP256K1,
|
|
232
219
|
data: 'AkVuTKyF3YgKLAQlLEtaUL2HTditwGILfWUVqjzYnIgH',
|
|
233
|
-
purpose:
|
|
234
|
-
securityLevel:
|
|
220
|
+
purpose: KeyPurpose.AUTHENTICATION,
|
|
221
|
+
securityLevel: KeySecurityLevel.MASTER,
|
|
235
222
|
readOnly: false,
|
|
236
223
|
});
|
|
237
224
|
});
|
|
@@ -243,10 +230,10 @@ describe('IdentityPublicKey', () => {
|
|
|
243
230
|
|
|
244
231
|
expect(jsonPublicKey).to.deep.equal({
|
|
245
232
|
id: 0,
|
|
246
|
-
type:
|
|
233
|
+
type: KeyType.ECDSA_SECP256K1,
|
|
247
234
|
data: 'AkVuTKyF3YgKLAQlLEtaUL2HTditwGILfWUVqjzYnIgH',
|
|
248
|
-
purpose:
|
|
249
|
-
securityLevel:
|
|
235
|
+
purpose: KeyPurpose.AUTHENTICATION,
|
|
236
|
+
securityLevel: KeySecurityLevel.MASTER,
|
|
250
237
|
readOnly: false,
|
|
251
238
|
disabledAt: 42,
|
|
252
239
|
});
|
|
@@ -255,7 +242,7 @@ describe('IdentityPublicKey', () => {
|
|
|
255
242
|
|
|
256
243
|
describe('#isMaster', () => {
|
|
257
244
|
it('should return true when public key has MASTER security level', () => {
|
|
258
|
-
publicKey.
|
|
245
|
+
publicKey.setSecurityLevel(KeySecurityLevel.MASTER);
|
|
259
246
|
|
|
260
247
|
const result = publicKey.isMaster();
|
|
261
248
|
|
|
@@ -263,7 +250,7 @@ describe('IdentityPublicKey', () => {
|
|
|
263
250
|
});
|
|
264
251
|
|
|
265
252
|
it('should return false when public key doesn\'t have MASTER security level', () => {
|
|
266
|
-
publicKey.
|
|
253
|
+
publicKey.setSecurityLevel(KeySecurityLevel.HIGH);
|
|
267
254
|
|
|
268
255
|
const result = publicKey.isMaster();
|
|
269
256
|
|
|
@@ -2,7 +2,7 @@ const {
|
|
|
2
2
|
convertSatoshiToCredits,
|
|
3
3
|
convertCreditsToSatoshi,
|
|
4
4
|
RATIO,
|
|
5
|
-
} = require('
|
|
5
|
+
} = require('@dashevo/dpp/lib/identity/creditsConverter');
|
|
6
6
|
|
|
7
7
|
describe('creditsConverter', () => {
|
|
8
8
|
describe('convertSatoshiToCredits', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const InvalidIdentityError = require('
|
|
2
|
-
const getIdentityFixture = require('
|
|
1
|
+
const InvalidIdentityError = require('@dashevo/dpp/lib/identity/errors/InvalidIdentityError');
|
|
2
|
+
const getIdentityFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityFixture');
|
|
3
3
|
|
|
4
4
|
describe('InvalidIdentityError', () => {
|
|
5
5
|
let rawIdentity;
|
package/test/unit/identity/stateTransition/IdentityCreateTransition/IdentityCreateTransition.spec.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const IdentityPublicKey = require('
|
|
1
|
+
const IdentityPublicKey = require('@dashevo/dpp/lib/identity/IdentityPublicKey');
|
|
2
2
|
|
|
3
3
|
const stateTransitionTypes = require(
|
|
4
|
-
'
|
|
4
|
+
'@dashevo/dpp/lib/stateTransition/stateTransitionTypes',
|
|
5
5
|
);
|
|
6
6
|
|
|
7
|
-
const protocolVersion = require('
|
|
8
|
-
const IdentityCreateTransition = require('
|
|
9
|
-
const Identifier = require('
|
|
7
|
+
const protocolVersion = require('@dashevo/dpp/lib/version/protocolVersion');
|
|
8
|
+
const IdentityCreateTransition = require('@dashevo/dpp/lib/identity/stateTransition/IdentityCreateTransition/IdentityCreateTransition');
|
|
9
|
+
const Identifier = require('@dashevo/dpp/lib/identifier/Identifier');
|
|
10
10
|
|
|
11
|
-
const getIdentityCreateTransitionFixture = require('
|
|
12
|
-
const InstantAssetLockProof = require('
|
|
11
|
+
const getIdentityCreateTransitionFixture = require('@dashevo/dpp/lib/test/fixtures/getIdentityCreateTransitionFixture');
|
|
12
|
+
const InstantAssetLockProof = require('@dashevo/dpp/lib/identity/stateTransition/assetLockProof/instant/InstantAssetLockProof');
|
|
13
13
|
|
|
14
14
|
describe('IdentityCreateTransition', () => {
|
|
15
15
|
let rawStateTransition;
|