trac-msb 0.2.17 → 0.2.19
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/README.md +62 -2
- package/SECURITY.md +9 -6
- package/cli/commandHandler.js +272 -0
- package/cli/handlers.js +210 -0
- package/cli/interactive.js +182 -0
- package/msb.mjs +7 -8
- package/package.json +33 -11
- package/rpc/create_server.js +44 -44
- package/rpc/handlers.js +43 -56
- package/rpc/routes/index.js +8 -8
- package/rpc/rpc_server.js +6 -2
- package/rpc/utils/helpers.js +46 -66
- package/scripts/pear-runner.js +170 -0
- package/src/config/args.js +60 -13
- package/src/config/config.js +163 -14
- package/src/config/env.js +57 -25
- package/src/core/network/Network.js +121 -56
- package/src/core/network/protocols/LegacyProtocol.js +21 -11
- package/src/core/network/protocols/NetworkMessages.js +38 -17
- package/src/core/network/protocols/ProtocolInterface.js +15 -3
- package/src/core/network/protocols/ProtocolSession.js +144 -17
- package/src/core/network/protocols/V1Protocol.js +37 -18
- package/src/core/network/protocols/connectionPolicies.js +174 -0
- package/src/core/network/protocols/legacy/NetworkMessageRouter.js +26 -20
- package/src/core/network/protocols/{shared/handlers/base/BaseOperationHandler.js → legacy/handlers/BaseStateOperationHandler.js} +25 -14
- package/src/core/network/protocols/legacy/handlers/{GetRequestHandler.js → LegacyGetRequestHandler.js} +9 -9
- package/src/core/network/protocols/legacy/handlers/LegacyResponseHandler.js +23 -0
- package/src/core/network/protocols/{shared/handlers/RoleOperationHandler.js → legacy/handlers/LegacyRoleOperationHandler.js} +19 -12
- package/src/core/network/protocols/{shared/handlers/SubnetworkOperationHandler.js → legacy/handlers/LegacySubnetworkOperationHandler.js} +29 -18
- package/src/core/network/protocols/{shared/handlers/TransferOperationHandler.js → legacy/handlers/LegacyTransferOperationHandler.js} +18 -12
- package/src/core/network/protocols/legacy/validators/base/BaseResponse.js +7 -10
- package/src/core/network/protocols/shared/validators/{PartialBootstrapDeployment.js → PartialBootstrapDeploymentValidator.js} +9 -4
- package/src/core/network/protocols/shared/validators/{base/PartialOperation.js → PartialOperationValidator.js} +53 -31
- package/src/core/network/protocols/shared/validators/{PartialRoleAccess.js → PartialRoleAccessValidator.js} +51 -17
- package/src/core/network/protocols/shared/validators/{PartialTransaction.js → PartialTransactionValidator.js} +21 -7
- package/src/core/network/protocols/shared/validators/{PartialTransfer.js → PartialTransferValidator.js} +32 -14
- package/src/core/network/protocols/v1/NetworkMessageRouter.js +91 -7
- package/src/core/network/protocols/v1/V1ProtocolError.js +27 -0
- package/src/core/network/protocols/v1/handlers/V1BaseOperationHandler.js +66 -0
- package/src/core/network/protocols/v1/handlers/V1BroadcastTransactionOperationHandler.js +272 -0
- package/src/core/network/protocols/v1/handlers/V1LivenessOperationHandler.js +88 -0
- package/src/core/network/protocols/v1/handlers/broadcastTransaction/BroadcastTransactionErrorMapper.js +84 -0
- package/src/core/network/protocols/v1/handlers/broadcastTransaction/BroadcastTransactionOperationStrategies.js +128 -0
- package/src/core/network/protocols/v1/handlers/broadcastTransaction/BroadcastTransactionPayloadUtils.js +26 -0
- package/src/core/network/protocols/v1/validators/V1BaseOperation.js +212 -0
- package/src/core/network/protocols/v1/validators/V1BroadcastTransactionRequest.js +28 -0
- package/src/core/network/protocols/v1/validators/V1BroadcastTransactionResponse.js +260 -0
- package/src/core/network/protocols/v1/validators/V1LivenessRequest.js +15 -0
- package/src/core/network/protocols/v1/validators/V1LivenessResponse.js +17 -0
- package/src/core/network/protocols/v1/validators/V1ValidationSchema.js +210 -0
- package/src/core/network/services/ConnectionManager.js +149 -96
- package/src/core/network/services/MessageOrchestrator.js +197 -37
- package/src/core/network/services/PendingRequestService.js +175 -0
- package/src/core/network/services/TransactionCommitService.js +149 -0
- package/src/core/network/services/TransactionPoolService.js +129 -18
- package/src/core/network/services/TransactionRateLimiterService.js +57 -35
- package/src/core/network/services/ValidatorHealthCheckService.js +127 -0
- package/src/core/network/services/ValidatorObserverService.js +400 -121
- package/src/core/state/State.js +259 -156
- package/src/core/state/utils/address.js +4 -9
- package/src/core/state/utils/balance.js +7 -7
- package/src/core/state/utils/roles.js +1 -1
- package/src/index.js +320 -278
- package/src/messages/network/v1/NetworkMessageBuilder.js +71 -100
- package/src/messages/network/v1/NetworkMessageDirector.js +16 -50
- package/src/messages/network/v1/networkMessageFactory.js +1 -1
- package/src/messages/state/ApplyStateMessageBuilder.js +6 -6
- package/src/messages/state/applyStateMessageFactory.js +1 -1
- package/src/utils/Scheduler.js +0 -8
- package/src/utils/buffer.js +1 -1
- package/src/utils/check.js +12 -13
- package/src/utils/constants.js +78 -5
- package/src/utils/deepEqualApplyPayload.js +40 -0
- package/src/utils/errors.js +20 -0
- package/src/utils/fileUtils.js +12 -3
- package/src/utils/helpers.js +10 -1
- package/src/utils/logger.js +25 -0
- package/src/utils/migrationUtils.js +3 -3
- package/src/utils/normalizers.js +38 -0
- package/src/utils/protobuf/networkV1.generated.cjs +2460 -0
- package/src/utils/protobuf/operationHelpers.js +24 -3
- package/.dockerignore +0 -16
- package/.github/workflows/acceptance-tests.yml +0 -38
- package/.github/workflows/lint-pr-title.yml +0 -26
- package/.github/workflows/publish.yml +0 -33
- package/.github/workflows/unit-tests.yml +0 -34
- package/CODE_OF_CONDUCT.md +0 -128
- package/docker-compose.yml +0 -17
- package/dockerfile +0 -41
- package/docs/fee_distribution.md +0 -89
- package/docs/trac_network_http_api.openapi.yaml +0 -889
- package/migration/.gitkeep +0 -0
- package/proto/applyOperations.proto +0 -117
- package/proto/network.proto +0 -74
- package/rpc/rpc_services.js +0 -163
- package/scripts/generate-protobufs.js +0 -42
- package/src/core/network/identity/NetworkWalletFactory.js +0 -77
- package/src/core/network/protocols/legacy/handlers/ResponseHandler.js +0 -37
- package/src/utils/cli.js +0 -130
- package/src/utils/cliCommands.js +0 -280
- package/src/utils/protobuf/network.cjs +0 -840
- package/tests/acceptance/v1/account/account.test.mjs +0 -123
- package/tests/acceptance/v1/balance/balance.test.mjs +0 -54
- package/tests/acceptance/v1/broadcast-transaction/broadcast-transaction.test.mjs +0 -116
- package/tests/acceptance/v1/confirmed-length/confirmed-length.test.mjs +0 -19
- package/tests/acceptance/v1/fee/fee.test.mjs +0 -11
- package/tests/acceptance/v1/health/health.test.mjs +0 -33
- package/tests/acceptance/v1/rpc.test.mjs +0 -95
- package/tests/acceptance/v1/tx/tx.test.mjs +0 -111
- package/tests/acceptance/v1/tx-details/tx-details.test.mjs +0 -213
- package/tests/acceptance/v1/tx-hashes/tx-hashes.test.mjs +0 -72
- package/tests/acceptance/v1/tx-payloads-bulk/tx-payloads-bulk.test.mjs +0 -27
- package/tests/acceptance/v1/txv/txv.test.mjs +0 -11
- package/tests/acceptance/v1/unconfirmed-length/unconfirmed-length.test.mjs +0 -11
- package/tests/fixtures/apply.fixtures.js +0 -77
- package/tests/fixtures/assembleMessage.fixtures.js +0 -41
- package/tests/fixtures/check.fixtures.js +0 -428
- package/tests/fixtures/networkV1.fixtures.js +0 -85
- package/tests/fixtures/protobuf.fixtures.js +0 -388
- package/tests/helpers/StateNetworkFactory.js +0 -155
- package/tests/helpers/address.js +0 -6
- package/tests/helpers/autobaseTestHelpers.js +0 -419
- package/tests/helpers/config.js +0 -4
- package/tests/helpers/createTestSignature.js +0 -13
- package/tests/helpers/regexHelper.js +0 -3
- package/tests/helpers/setupApplyTests.js +0 -587
- package/tests/helpers/transactionPayloads.mjs +0 -92
- package/tests/helpers/wrapper.js +0 -28
- package/tests/unit/messages/messages.test.js +0 -12
- package/tests/unit/messages/network/NetworkMessageBuilder.test.js +0 -276
- package/tests/unit/messages/network/NetworkMessageDirector.test.js +0 -201
- package/tests/unit/messages/state/applyStateMessageBuilder.complete.test.js +0 -525
- package/tests/unit/messages/state/applyStateMessageBuilder.partial.test.js +0 -237
- package/tests/unit/network/ConnectionManager.test.js +0 -191
- package/tests/unit/network/NetworkWalletFactory.test.js +0 -156
- package/tests/unit/network/networkModule.test.js +0 -10
- package/tests/unit/state/State.test.js +0 -80
- package/tests/unit/state/apply/addAdmin/addAdminHappyPathScenario.js +0 -42
- package/tests/unit/state/apply/addAdmin/addAdminScenarioHelpers.js +0 -276
- package/tests/unit/state/apply/addAdmin/adminEntryEncodingFailureScenario.js +0 -30
- package/tests/unit/state/apply/addAdmin/adminEntryExistsScenario.js +0 -78
- package/tests/unit/state/apply/addAdmin/nodeEntryInitializationFailureScenario.js +0 -30
- package/tests/unit/state/apply/addAdmin/nonBootstrapNodeScenario.js +0 -68
- package/tests/unit/state/apply/addAdmin/state.apply.addAdmin.test.js +0 -159
- package/tests/unit/state/apply/addIndexer/addIndexerHappyPathScenario.js +0 -39
- package/tests/unit/state/apply/addIndexer/addIndexerMultipleIndexersInTheNetworkScenario.js +0 -167
- package/tests/unit/state/apply/addIndexer/addIndexerPretenderAlreadyIndexerScenario.js +0 -21
- package/tests/unit/state/apply/addIndexer/addIndexerPretenderNotWriterScenario.js +0 -21
- package/tests/unit/state/apply/addIndexer/addIndexerRemoveAndReAddScenario.js +0 -186
- package/tests/unit/state/apply/addIndexer/addIndexerScenarioHelpers.js +0 -443
- package/tests/unit/state/apply/addIndexer/addIndexerWriterKeyAlreadyRegisteredScenario.js +0 -32
- package/tests/unit/state/apply/addIndexer/state.apply.addIndexer.test.js +0 -297
- package/tests/unit/state/apply/addWriter/addWriterHappyPathScenario.js +0 -41
- package/tests/unit/state/apply/addWriter/addWriterInvalidValidatorSignatureScenario.js +0 -32
- package/tests/unit/state/apply/addWriter/addWriterNewWkScenario.js +0 -149
- package/tests/unit/state/apply/addWriter/addWriterRequesterAlreadyWriterScenario.js +0 -21
- package/tests/unit/state/apply/addWriter/addWriterRequesterBalanceInsufficientScenario.js +0 -21
- package/tests/unit/state/apply/addWriter/addWriterRequesterEntryDecodeFailureScenario.js +0 -19
- package/tests/unit/state/apply/addWriter/addWriterRequesterEntryMissingScenario.js +0 -19
- package/tests/unit/state/apply/addWriter/addWriterRequesterIndexerScenario.js +0 -21
- package/tests/unit/state/apply/addWriter/addWriterRequesterNotWhitelistedScenario.js +0 -21
- package/tests/unit/state/apply/addWriter/addWriterScenarioHelpers.js +0 -766
- package/tests/unit/state/apply/addWriter/addWriterStakeBalanceUpdateFailureScenario.js +0 -50
- package/tests/unit/state/apply/addWriter/addWriterStakeInsufficientBalanceScenario.js +0 -29
- package/tests/unit/state/apply/addWriter/addWriterStakeInvalidBalanceScenario.js +0 -29
- package/tests/unit/state/apply/addWriter/addWriterStakeInvalidEntryScenario.js +0 -21
- package/tests/unit/state/apply/addWriter/addWriterStakeStakedBalanceFailureScenario.js +0 -37
- package/tests/unit/state/apply/addWriter/addWriterStakeSubtractFailureScenario.js +0 -42
- package/tests/unit/state/apply/addWriter/addWriterValidatorRewardScenario.js +0 -106
- package/tests/unit/state/apply/addWriter/addWriterWriterKeyMismatchScenario.js +0 -54
- package/tests/unit/state/apply/addWriter/addWriterWriterKeyOwnershipScenario.js +0 -54
- package/tests/unit/state/apply/addWriter/addWriterZeroWriterKeyScenario.js +0 -29
- package/tests/unit/state/apply/addWriter/state.apply.addWriter.test.js +0 -309
- package/tests/unit/state/apply/adminRecovery/adminRecoveryHappyPathScenario.js +0 -30
- package/tests/unit/state/apply/adminRecovery/adminRecoveryScenarioHelpers.js +0 -881
- package/tests/unit/state/apply/adminRecovery/state.apply.adminRecovery.test.js +0 -435
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistBanAndReapplyScenario.js +0 -78
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistExistingReaderHappyPathScenario.js +0 -98
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistFeeAfterDisableScenario.js +0 -66
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistHappyPathScenario.js +0 -55
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistInsufficientAdminBalanceScenario.js +0 -103
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistNodeAlreadyWhitelistedScenario.js +0 -60
- package/tests/unit/state/apply/appendWhitelist/appendWhitelistScenarioHelpers.js +0 -189
- package/tests/unit/state/apply/appendWhitelist/state.apply.appendWhitelist.test.js +0 -220
- package/tests/unit/state/apply/balanceInitialization/balanceInitializationHappyPathScenario.js +0 -82
- package/tests/unit/state/apply/balanceInitialization/balanceInitializationScenarioHelpers.js +0 -111
- package/tests/unit/state/apply/balanceInitialization/invalidAmountScenario.js +0 -45
- package/tests/unit/state/apply/balanceInitialization/nodeEntryBalanceUpdateFailureScenario.js +0 -82
- package/tests/unit/state/apply/balanceInitialization/state.apply.balanceInitialization.test.js +0 -189
- package/tests/unit/state/apply/banValidator/banValidatorBanAndReWhitelistScenario.js +0 -156
- package/tests/unit/state/apply/banValidator/banValidatorHappyPathScenario.js +0 -36
- package/tests/unit/state/apply/banValidator/banValidatorScenarioHelpers.js +0 -531
- package/tests/unit/state/apply/banValidator/banValidatorSequentialBansScenario.js +0 -74
- package/tests/unit/state/apply/banValidator/banValidatorTargetDecodeFailureScenario.js +0 -19
- package/tests/unit/state/apply/banValidator/banValidatorTargetIndexerScenario.js +0 -32
- package/tests/unit/state/apply/banValidator/banValidatorTargetNodeEntryMissingScenario.js +0 -19
- package/tests/unit/state/apply/banValidator/banValidatorTargetRoleUpdateFailureScenario.js +0 -19
- package/tests/unit/state/apply/banValidator/banValidatorWhitelistedNonWriterScenario.js +0 -38
- package/tests/unit/state/apply/banValidator/banValidatorWhitelistedZeroBalanceScenario.js +0 -91
- package/tests/unit/state/apply/banValidator/banValidatorWithdrawFailureScenario.js +0 -19
- package/tests/unit/state/apply/banValidator/state.apply.banValidator.test.js +0 -266
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentDuplicateRegistrationScenario.js +0 -143
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentHappyPathScenario.js +0 -26
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentIncompleteOperationScenario.js +0 -94
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentInvalidDeploymentEntryScenario.js +0 -37
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentMultipleBootstrapScenario.js +0 -86
- package/tests/unit/state/apply/bootstrapDeployment/bootstrapDeploymentScenarioHelpers.js +0 -347
- package/tests/unit/state/apply/bootstrapDeployment/invalidValidatorNodeEntryScenario.js +0 -57
- package/tests/unit/state/apply/bootstrapDeployment/state.apply.bootstrapDeployment.test.js +0 -429
- package/tests/unit/state/apply/common/access-control/adminConsistencyMismatchScenario.js +0 -120
- package/tests/unit/state/apply/common/access-control/adminEntryDecodeFailureScenario.js +0 -130
- package/tests/unit/state/apply/common/access-control/adminEntryExistsScenario.js +0 -93
- package/tests/unit/state/apply/common/access-control/adminEntryMissingScenario.js +0 -108
- package/tests/unit/state/apply/common/access-control/adminOnlyGuardScenario.js +0 -126
- package/tests/unit/state/apply/common/access-control/adminPublicKeyDecodeFailureScenario.js +0 -121
- package/tests/unit/state/apply/common/access-control/roleAccessOperationValidationScenario.js +0 -50
- package/tests/unit/state/apply/common/adminControlOperationValidationScenario.js +0 -56
- package/tests/unit/state/apply/common/balances/adminEntryUpdateFailureScenario.js +0 -52
- package/tests/unit/state/apply/common/balances/base/requesterBalanceScenarioBase.js +0 -198
- package/tests/unit/state/apply/common/balances/feeDecodeFailureScenario.js +0 -52
- package/tests/unit/state/apply/common/balances/requesterBalanceDecodeFailureScenario.js +0 -15
- package/tests/unit/state/apply/common/balances/requesterBalanceFeeApplicationFailureScenario.js +0 -11
- package/tests/unit/state/apply/common/balances/requesterBalanceInsufficientScenario.js +0 -15
- package/tests/unit/state/apply/common/balances/requesterBalanceUpdateFailureScenario.js +0 -11
- package/tests/unit/state/apply/common/balances/validatorEntryRewardFailureScenario.js +0 -11
- package/tests/unit/state/apply/common/balances/validatorEntryUpdateFailureScenario.js +0 -11
- package/tests/unit/state/apply/common/balances/validatorNodeEntryDecodeFailureScenario.js +0 -40
- package/tests/unit/state/apply/common/base/OperationValidationScenarioBase.js +0 -114
- package/tests/unit/state/apply/common/commonScenarioHelper.js +0 -103
- package/tests/unit/state/apply/common/indexer/indexerNodeEntryDecodeFailureScenario.js +0 -36
- package/tests/unit/state/apply/common/indexer/indexerNodeEntryMissingScenario.js +0 -36
- package/tests/unit/state/apply/common/indexer/indexerRoleUpdateFailureScenario.js +0 -29
- package/tests/unit/state/apply/common/indexer/indexerSequenceStateInvalidScenario.js +0 -66
- package/tests/unit/state/apply/common/invalidMessageComponentValidationScenario.js +0 -84
- package/tests/unit/state/apply/common/nodeEntryInitializationFailureScenario.js +0 -47
- package/tests/unit/state/apply/common/operationAlreadyAppliedScenario.js +0 -85
- package/tests/unit/state/apply/common/payload-structure/addressWithInvalidPublicKeyScenario.js +0 -52
- package/tests/unit/state/apply/common/payload-structure/initializationDisabledScenario.js +0 -54
- package/tests/unit/state/apply/common/payload-structure/invalidAddressValidationScenario.js +0 -73
- package/tests/unit/state/apply/common/payload-structure/invalidHashValidationScenario.js +0 -71
- package/tests/unit/state/apply/common/payload-structure/invalidPayloadValidationScenario.js +0 -31
- package/tests/unit/state/apply/common/payload-structure/invalidSignatureValidationScenario.js +0 -142
- package/tests/unit/state/apply/common/payload-structure/partialOperationValidationScenario.js +0 -87
- package/tests/unit/state/apply/common/requester/requesterNodeEntryBufferMissingScenario.js +0 -71
- package/tests/unit/state/apply/common/requester/requesterNodeEntryDecodeFailureScenario.js +0 -73
- package/tests/unit/state/apply/common/requester/requesterNodeEntryMissingScenario.js +0 -36
- package/tests/unit/state/apply/common/requesterAddressValidationScenario.js +0 -44
- package/tests/unit/state/apply/common/requesterPublicKeyValidationScenario.js +0 -25
- package/tests/unit/state/apply/common/transactionValidityMismatchScenario.js +0 -98
- package/tests/unit/state/apply/common/validatorConsistency/base/validatorConsistencyScenarioBase.js +0 -202
- package/tests/unit/state/apply/common/validatorConsistency/validatorEntryDecodeFailureScenario.js +0 -17
- package/tests/unit/state/apply/common/validatorConsistency/validatorEntryMissingScenario.js +0 -44
- package/tests/unit/state/apply/common/validatorConsistency/validatorInactiveScenario.js +0 -19
- package/tests/unit/state/apply/common/validatorConsistency/validatorWriterKeyMismatchScenario.js +0 -18
- package/tests/unit/state/apply/common/validatorEntryValidation/base/validatorEntryValidationScenarioBase.js +0 -315
- package/tests/unit/state/apply/common/validatorEntryValidation/validatorEntryInvalidBalanceScenario.js +0 -18
- package/tests/unit/state/apply/common/writerKeyExistsValidationScenario.js +0 -43
- package/tests/unit/state/apply/disableInitialization/disableInitializationAlreadyDisabledScenario.js +0 -53
- package/tests/unit/state/apply/disableInitialization/disableInitializationHappyPathScenario.js +0 -24
- package/tests/unit/state/apply/disableInitialization/disableInitializationScenarioHelpers.js +0 -204
- package/tests/unit/state/apply/disableInitialization/state.apply.disableInitialization.test.js +0 -161
- package/tests/unit/state/apply/missing-tests.md +0 -18
- package/tests/unit/state/apply/removeIndexer/removeIndexerHappyPathScenario.js +0 -58
- package/tests/unit/state/apply/removeIndexer/removeIndexerReAddAndRemoveAgainScenario.js +0 -98
- package/tests/unit/state/apply/removeIndexer/removeIndexerRemoveMultipleIndexersScenario.js +0 -167
- package/tests/unit/state/apply/removeIndexer/removeIndexerScenarioHelpers.js +0 -429
- package/tests/unit/state/apply/removeIndexer/removeIndexerTargetNotIndexerScenario.js +0 -22
- package/tests/unit/state/apply/removeIndexer/removeIndexerWriterKeyMissingScenario.js +0 -20
- package/tests/unit/state/apply/removeIndexer/state.apply.removeIndexer.test.js +0 -291
- package/tests/unit/state/apply/removeWriter/removeWriterAndAddWriterAgainScenario.js +0 -87
- package/tests/unit/state/apply/removeWriter/removeWriterHappyPathScenario.js +0 -38
- package/tests/unit/state/apply/removeWriter/removeWriterInvalidValidatorSignatureScenario.js +0 -32
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterBalanceInsufficientScenario.js +0 -21
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterEntryDecodeFailureScenario.js +0 -19
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterEntryMissingScenario.js +0 -19
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterIndexerScenario.js +0 -21
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterNotWriterScenario.js +0 -21
- package/tests/unit/state/apply/removeWriter/removeWriterRequesterRoleUpdateFailureScenario.js +0 -19
- package/tests/unit/state/apply/removeWriter/removeWriterScenarioHelpers.js +0 -348
- package/tests/unit/state/apply/removeWriter/removeWriterThroughWriterValidatorScenario.js +0 -113
- package/tests/unit/state/apply/removeWriter/removeWriterUnstakeFailureScenario.js +0 -33
- package/tests/unit/state/apply/removeWriter/removeWriterWriterKeyMismatchScenario.js +0 -21
- package/tests/unit/state/apply/removeWriter/removeWriterWriterKeyOwnershipScenario.js +0 -26
- package/tests/unit/state/apply/removeWriter/removeWriterWriterKeyRegistryMissingScenario.js +0 -22
- package/tests/unit/state/apply/removeWriter/state.apply.removeWriter.test.js +0 -307
- package/tests/unit/state/apply/state.apply.test.js +0 -24
- package/tests/unit/state/apply/transfer/state.apply.transfer.test.js +0 -819
- package/tests/unit/state/apply/transfer/transferContractSchemaValidationScenario.js +0 -22
- package/tests/unit/state/apply/transfer/transferDoubleSpendAcrossValidatorsScenario.js +0 -146
- package/tests/unit/state/apply/transfer/transferDoubleSpendSameBatchScenario.js +0 -63
- package/tests/unit/state/apply/transfer/transferDoubleSpendSingleValidatorScenario.js +0 -67
- package/tests/unit/state/apply/transfer/transferExistingRecipientAmountScenario.js +0 -31
- package/tests/unit/state/apply/transfer/transferExistingRecipientZeroAmountScenario.js +0 -31
- package/tests/unit/state/apply/transfer/transferHandlerGuardScenarios.js +0 -22
- package/tests/unit/state/apply/transfer/transferHappyPathScenario.js +0 -8
- package/tests/unit/state/apply/transfer/transferInvalidIncomingDataScenario.js +0 -66
- package/tests/unit/state/apply/transfer/transferNewRecipientAmountScenario.js +0 -31
- package/tests/unit/state/apply/transfer/transferNewRecipientZeroAmountScenario.js +0 -31
- package/tests/unit/state/apply/transfer/transferScenarioHelpers.js +0 -1170
- package/tests/unit/state/apply/transfer/transferSelfTransferAmountScenario.js +0 -38
- package/tests/unit/state/apply/transfer/transferSelfTransferZeroAmountScenario.js +0 -38
- package/tests/unit/state/apply/transfer/transferValidatorRecipientAmountScenario.js +0 -38
- package/tests/unit/state/apply/transfer/transferValidatorRecipientZeroAmountScenario.js +0 -38
- package/tests/unit/state/apply/txOperation/state.apply.txOperation.test.js +0 -318
- package/tests/unit/state/apply/txOperation/txOperationBootstrapNotRegisteredScenario.js +0 -70
- package/tests/unit/state/apply/txOperation/txOperationDifferentValidatorCreatorHappyPathScenario.js +0 -23
- package/tests/unit/state/apply/txOperation/txOperationInvalidDeploymentEntryScenario.js +0 -48
- package/tests/unit/state/apply/txOperation/txOperationInvalidFeeAmountScenario.js +0 -39
- package/tests/unit/state/apply/txOperation/txOperationInvalidSubnetCreatorAddressScenario.js +0 -46
- package/tests/unit/state/apply/txOperation/txOperationRequesterCreatorHappyPathScenario.js +0 -21
- package/tests/unit/state/apply/txOperation/txOperationScenarioHelpers.js +0 -432
- package/tests/unit/state/apply/txOperation/txOperationStandardHappyPathScenario.js +0 -21
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeAddCreatorBalanceFailureScenario.js +0 -26
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeAddValidatorBalanceFailureScenario.js +0 -25
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeAddValidatorBonusFailureScenario.js +0 -27
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeDecodeCreatorEntryScenario.js +0 -18
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeDecodeRequesterEntryScenario.js +0 -17
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeDecodeValidatorEntryScenario.js +0 -31
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeGuardBypassScenario.js +0 -49
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeGuardScenarioFactory.js +0 -93
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInsufficientRequesterBalanceScenario.js +0 -28
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidCreatorBalanceScenario.js +0 -29
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidRequesterBalanceScenario.js +0 -28
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidRequesterEntryScenario.js +0 -17
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeInvalidValidatorBalanceScenario.js +0 -33
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeMissingCreatorEntryScenario.js +0 -18
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeSubtractFailureScenario.js +0 -25
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateCreatorBalanceFailureScenario.js +0 -26
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateFailureScenario.js +0 -25
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateValidatorBalanceFailureScenario.js +0 -26
- package/tests/unit/state/apply/txOperation/txOperationTransferFeeUpdateValidatorBonusFailureScenario.js +0 -27
- package/tests/unit/state/apply/txOperation/txOperationValidatorCreatorHappyPathScenario.js +0 -21
- package/tests/unit/state/stateModule.test.js +0 -23
- package/tests/unit/state/stateTestUtils.js +0 -32
- package/tests/unit/state/utils/address.test.js +0 -63
- package/tests/unit/state/utils/adminEntry.test.js +0 -52
- package/tests/unit/state/utils/balance.test.js +0 -320
- package/tests/unit/state/utils/lengthEntry.test.js +0 -54
- package/tests/unit/state/utils/nodeEntry.test.js +0 -298
- package/tests/unit/state/utils/roles.test.js +0 -44
- package/tests/unit/unit.test.js +0 -14
- package/tests/unit/utils/amountSerialization/amountSerialization.test.js +0 -237
- package/tests/unit/utils/buffer/buffer.test.js +0 -251
- package/tests/unit/utils/check/adminControlOperation.test.js +0 -156
- package/tests/unit/utils/check/balanceInitializationOperation.test.js +0 -54
- package/tests/unit/utils/check/bootstrapDeploymentOperation.test.js +0 -104
- package/tests/unit/utils/check/check.test.js +0 -17
- package/tests/unit/utils/check/common.test.js +0 -419
- package/tests/unit/utils/check/coreAdminOperation.test.js +0 -95
- package/tests/unit/utils/check/roleAccessOperation.test.js +0 -255
- package/tests/unit/utils/check/transactionOperation.test.js +0 -107
- package/tests/unit/utils/check/transferOperation.test.js +0 -102
- package/tests/unit/utils/fileUtils/readAddressesFromWhitelistFile.test.js +0 -95
- package/tests/unit/utils/fileUtils/readBalanceMigrationFile.test.js +0 -149
- package/tests/unit/utils/helpers/helpers.test.js +0 -11
- package/tests/unit/utils/helpers/isHexString.test.js +0 -12
- package/tests/unit/utils/helpers/normalizeHex.test.js +0 -82
- package/tests/unit/utils/migrationUtils/validateAddressFromIncomingFile.test.js +0 -100
- package/tests/unit/utils/normalizers/normalizers.test.js +0 -469
- package/tests/unit/utils/protobuf/applyOperations.test.js +0 -91
- package/tests/unit/utils/protobuf/operationHelpers.test.js +0 -305
- package/tests/unit/utils/protobuf/protobuf.test.js +0 -12
- package/tests/unit/utils/type/type.test.js +0 -25
- package/tests/unit/utils/utils.test.js +0 -20
- package/whitelist/.gitkeep +0 -0
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import test from 'brittle'
|
|
2
|
-
|
|
3
|
-
import Check from '../../../../src/utils/check.js';
|
|
4
|
-
import { RAO, not_allowed_data_types } from '../../../fixtures/check.fixtures.js';
|
|
5
|
-
import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest, partialTypeCommonTests } from './common.test.js';
|
|
6
|
-
import { config } from '../../../helpers/config.js';
|
|
7
|
-
|
|
8
|
-
const check = new Check(config)
|
|
9
|
-
|
|
10
|
-
test('validateRoleAccessOperation - happy-path case', t => {
|
|
11
|
-
// ADD_WRITER
|
|
12
|
-
t.ok(check.validateRoleAccessOperation(RAO.valid_partial_add_writer), 'Valid data for partial ADD_WRITER operation should pass the validation')
|
|
13
|
-
t.ok(check.validateRoleAccessOperation(RAO.valid_complete_add_writer), 'Valid data for complete ADD_WRITER operation should pass the validation')
|
|
14
|
-
|
|
15
|
-
// REMOVE_WRITER
|
|
16
|
-
t.ok(check.validateRoleAccessOperation(RAO.valid_partial_remove_writer), 'Valid data for partial REMOVE_WRITER operation should pass the validation')
|
|
17
|
-
t.ok(check.validateRoleAccessOperation(RAO.valid_complete_remove_writer), 'Valid data for complete REMOVE_WRITER operation should pass the validation')
|
|
18
|
-
|
|
19
|
-
// ADMIN_RECOVERY
|
|
20
|
-
t.ok(check.validateRoleAccessOperation(RAO.valid_partial_admin_recovery), 'Valid data for partial ADMIN_RECOVERY operation should pass the validation')
|
|
21
|
-
t.ok(check.validateRoleAccessOperation(RAO.valid_complete_admin_recovery), 'Valid data for complete ADMIN_RECOVERY operation should pass the validation')
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
test('validateRoleAccessOperation - type level validation (rao)', t => {
|
|
25
|
-
// ADD_WRITER complete
|
|
26
|
-
topLevelValidationTests(
|
|
27
|
-
t,
|
|
28
|
-
check.validateRoleAccessOperation.bind(check),
|
|
29
|
-
RAO.valid_complete_add_writer,
|
|
30
|
-
'rao',
|
|
31
|
-
not_allowed_data_types,
|
|
32
|
-
RAO.top_fields_role_access
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
// ADD_WRITER partial
|
|
36
|
-
topLevelValidationTests(
|
|
37
|
-
t,
|
|
38
|
-
check.validateRoleAccessOperation.bind(check),
|
|
39
|
-
RAO.valid_partial_add_writer,
|
|
40
|
-
'rao',
|
|
41
|
-
not_allowed_data_types,
|
|
42
|
-
RAO.top_fields_role_access
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
// REMOVE_WRITER complete
|
|
46
|
-
topLevelValidationTests(
|
|
47
|
-
t,
|
|
48
|
-
check.validateRoleAccessOperation.bind(check),
|
|
49
|
-
RAO.valid_complete_remove_writer,
|
|
50
|
-
'rao',
|
|
51
|
-
not_allowed_data_types,
|
|
52
|
-
RAO.top_fields_role_access
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
// REMOVE_WRITER partial
|
|
56
|
-
topLevelValidationTests(
|
|
57
|
-
t,
|
|
58
|
-
check.validateRoleAccessOperation.bind(check),
|
|
59
|
-
RAO.valid_partial_remove_writer,
|
|
60
|
-
'rao',
|
|
61
|
-
not_allowed_data_types,
|
|
62
|
-
RAO.top_fields_role_access
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
// ADMIN_RECOVERY complete
|
|
66
|
-
topLevelValidationTests(
|
|
67
|
-
t,
|
|
68
|
-
check.validateRoleAccessOperation.bind(check),
|
|
69
|
-
RAO.valid_complete_admin_recovery,
|
|
70
|
-
'rao',
|
|
71
|
-
not_allowed_data_types,
|
|
72
|
-
RAO.top_fields_role_access
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
// ADMIN_RECOVERY partial
|
|
76
|
-
topLevelValidationTests(
|
|
77
|
-
t,
|
|
78
|
-
check.validateRoleAccessOperation.bind(check),
|
|
79
|
-
RAO.valid_partial_admin_recovery,
|
|
80
|
-
'rao',
|
|
81
|
-
not_allowed_data_types,
|
|
82
|
-
RAO.top_fields_role_access
|
|
83
|
-
)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
test('validateRoleAccessOperation - value level validation (rao)', t => {
|
|
87
|
-
// ADD_WRITER complete
|
|
88
|
-
valueLevelValidationTest(
|
|
89
|
-
t,
|
|
90
|
-
check.validateRoleAccessOperation.bind(check),
|
|
91
|
-
RAO.valid_complete_add_writer,
|
|
92
|
-
'rao',
|
|
93
|
-
RAO.complete_role_access_value_fields,
|
|
94
|
-
not_allowed_data_types
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
// ADD_WRITER partial
|
|
98
|
-
valueLevelValidationTest(
|
|
99
|
-
t,
|
|
100
|
-
check.validateRoleAccessOperation.bind(check),
|
|
101
|
-
RAO.valid_partial_add_writer,
|
|
102
|
-
'rao',
|
|
103
|
-
RAO.partial_role_access_value_fields,
|
|
104
|
-
not_allowed_data_types
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
// REMOVE_WRITER complete
|
|
108
|
-
valueLevelValidationTest(
|
|
109
|
-
t,
|
|
110
|
-
check.validateRoleAccessOperation.bind(check),
|
|
111
|
-
RAO.valid_complete_remove_writer,
|
|
112
|
-
'rao',
|
|
113
|
-
RAO.complete_role_access_value_fields,
|
|
114
|
-
not_allowed_data_types
|
|
115
|
-
)
|
|
116
|
-
|
|
117
|
-
// REMOVE_WRITER partial
|
|
118
|
-
valueLevelValidationTest(
|
|
119
|
-
t,
|
|
120
|
-
check.validateRoleAccessOperation.bind(check),
|
|
121
|
-
RAO.valid_partial_remove_writer,
|
|
122
|
-
'rao',
|
|
123
|
-
RAO.partial_role_access_value_fields,
|
|
124
|
-
not_allowed_data_types
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
// ADMIN_RECOVERY complete
|
|
128
|
-
valueLevelValidationTest(
|
|
129
|
-
t,
|
|
130
|
-
check.validateRoleAccessOperation.bind(check),
|
|
131
|
-
RAO.valid_complete_admin_recovery,
|
|
132
|
-
'rao',
|
|
133
|
-
RAO.complete_role_access_value_fields,
|
|
134
|
-
not_allowed_data_types
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
// ADMIN_RECOVERY partial
|
|
138
|
-
valueLevelValidationTest(
|
|
139
|
-
t,
|
|
140
|
-
check.validateRoleAccessOperation.bind(check),
|
|
141
|
-
RAO.valid_partial_admin_recovery,
|
|
142
|
-
'rao',
|
|
143
|
-
RAO.partial_role_access_value_fields,
|
|
144
|
-
not_allowed_data_types
|
|
145
|
-
)
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
test('validateRoleAccessOperation - address buffer length validation - TOP LEVEL', t => {
|
|
149
|
-
// ADD_WRITER complete
|
|
150
|
-
addressBufferLengthTest(
|
|
151
|
-
t,
|
|
152
|
-
check.validateRoleAccessOperation.bind(check),
|
|
153
|
-
RAO.valid_complete_add_writer
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
// ADD_WRITER partial
|
|
157
|
-
addressBufferLengthTest(
|
|
158
|
-
t,
|
|
159
|
-
check.validateRoleAccessOperation.bind(check),
|
|
160
|
-
RAO.valid_partial_add_writer
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
// REMOVE_WRITER complete
|
|
164
|
-
addressBufferLengthTest(
|
|
165
|
-
t,
|
|
166
|
-
check.validateRoleAccessOperation.bind(check),
|
|
167
|
-
RAO.valid_complete_remove_writer
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
// REMOVE_WRITER partial
|
|
171
|
-
addressBufferLengthTest(
|
|
172
|
-
t,
|
|
173
|
-
check.validateRoleAccessOperation.bind(check),
|
|
174
|
-
RAO.valid_partial_remove_writer
|
|
175
|
-
)
|
|
176
|
-
|
|
177
|
-
// ADMIN_RECOVERY complete
|
|
178
|
-
addressBufferLengthTest(
|
|
179
|
-
t,
|
|
180
|
-
check.validateRoleAccessOperation.bind(check),
|
|
181
|
-
RAO.valid_complete_admin_recovery
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
// ADMIN_RECOVERY partial
|
|
185
|
-
addressBufferLengthTest(
|
|
186
|
-
t,
|
|
187
|
-
check.validateRoleAccessOperation.bind(check),
|
|
188
|
-
RAO.valid_partial_admin_recovery
|
|
189
|
-
)
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
test('validateRoleAccessOperation - fields buffer length validation - VALUE LEVEL (rao)', t => {
|
|
193
|
-
// ADD_WRITER complete
|
|
194
|
-
fieldsBufferLengthTest(
|
|
195
|
-
t,
|
|
196
|
-
check.validateRoleAccessOperation.bind(check),
|
|
197
|
-
RAO.valid_complete_add_writer,
|
|
198
|
-
'rao',
|
|
199
|
-
RAO.required_length_of_fields_for_complete_role_access
|
|
200
|
-
)
|
|
201
|
-
|
|
202
|
-
// ADD_WRITER partial
|
|
203
|
-
fieldsBufferLengthTest(
|
|
204
|
-
t,
|
|
205
|
-
check.validateRoleAccessOperation.bind(check),
|
|
206
|
-
RAO.valid_partial_add_writer,
|
|
207
|
-
'rao',
|
|
208
|
-
RAO.required_length_of_fields_for_partial_role_access
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
// REMOVE_WRITER complete
|
|
212
|
-
fieldsBufferLengthTest(
|
|
213
|
-
t,
|
|
214
|
-
check.validateRoleAccessOperation.bind(check),
|
|
215
|
-
RAO.valid_complete_remove_writer,
|
|
216
|
-
'rao',
|
|
217
|
-
RAO.required_length_of_fields_for_complete_role_access
|
|
218
|
-
)
|
|
219
|
-
|
|
220
|
-
// REMOVE_WRITER partial
|
|
221
|
-
fieldsBufferLengthTest(
|
|
222
|
-
t,
|
|
223
|
-
check.validateRoleAccessOperation.bind(check),
|
|
224
|
-
RAO.valid_partial_remove_writer,
|
|
225
|
-
'rao',
|
|
226
|
-
RAO.required_length_of_fields_for_partial_role_access
|
|
227
|
-
)
|
|
228
|
-
|
|
229
|
-
// ADMIN_RECOVERY complete
|
|
230
|
-
fieldsBufferLengthTest(
|
|
231
|
-
t,
|
|
232
|
-
check.validateRoleAccessOperation.bind(check),
|
|
233
|
-
RAO.valid_complete_admin_recovery,
|
|
234
|
-
'rao',
|
|
235
|
-
RAO.required_length_of_fields_for_complete_role_access
|
|
236
|
-
)
|
|
237
|
-
|
|
238
|
-
// ADMIN_RECOVERY partial
|
|
239
|
-
fieldsBufferLengthTest(
|
|
240
|
-
t,
|
|
241
|
-
check.validateRoleAccessOperation.bind(check),
|
|
242
|
-
RAO.valid_partial_admin_recovery,
|
|
243
|
-
'rao',
|
|
244
|
-
RAO.required_length_of_fields_for_partial_role_access
|
|
245
|
-
)
|
|
246
|
-
})
|
|
247
|
-
|
|
248
|
-
test('validateRoleAccessOperation - optional fields va, vn, vs', t => {
|
|
249
|
-
partialTypeCommonTests(
|
|
250
|
-
t,
|
|
251
|
-
check.validateRoleAccessOperation.bind(check),
|
|
252
|
-
RAO.valid_complete_add_writer,
|
|
253
|
-
'rao'
|
|
254
|
-
)
|
|
255
|
-
})
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import test from 'brittle'
|
|
2
|
-
import Check from '../../../../src/utils/check.js';
|
|
3
|
-
import { TXO, not_allowed_data_types } from '../../../fixtures/check.fixtures.js';
|
|
4
|
-
import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest, partialTypeCommonTests } from './common.test.js';
|
|
5
|
-
import { config } from '../../../helpers/config.js';
|
|
6
|
-
|
|
7
|
-
const check = new Check(config)
|
|
8
|
-
|
|
9
|
-
test('validateTransactionOperation - happy-path case', t => {
|
|
10
|
-
// ADD_WRITER
|
|
11
|
-
const partial_result = check.validateTransactionOperation(TXO.valid_partial_transaction_operation)
|
|
12
|
-
const complete_result = check.validateTransactionOperation(TXO.valid_complete_transaction_operation)
|
|
13
|
-
t.ok(partial_result, 'Valid data for partial transaction operation should pass the validation')
|
|
14
|
-
t.ok(complete_result, 'Valid data for complete transaction operation should pass the validation')
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test('validateTransactionOperation - optional fields va, vn, vs', t => {
|
|
18
|
-
partialTypeCommonTests(
|
|
19
|
-
t,
|
|
20
|
-
check.validateTransactionOperation.bind(check),
|
|
21
|
-
TXO.valid_complete_transaction_operation,
|
|
22
|
-
'txo'
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test('validateTransactionOperation - data type validation TOP LEVEL', t => {
|
|
28
|
-
//complete
|
|
29
|
-
topLevelValidationTests(
|
|
30
|
-
t,
|
|
31
|
-
check.validateTransactionOperation.bind(check),
|
|
32
|
-
TXO.valid_complete_transaction_operation,
|
|
33
|
-
'txo',
|
|
34
|
-
not_allowed_data_types,
|
|
35
|
-
TXO.top_fields_transaction_operation
|
|
36
|
-
);
|
|
37
|
-
//partial
|
|
38
|
-
topLevelValidationTests(
|
|
39
|
-
t,
|
|
40
|
-
check.validateTransactionOperation.bind(check),
|
|
41
|
-
TXO.valid_partial_transaction_operation,
|
|
42
|
-
'txo',
|
|
43
|
-
not_allowed_data_types,
|
|
44
|
-
TXO.top_fields_transaction_operation
|
|
45
|
-
);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
test('validateTransactionOperation - value level validation (txo)', t => {
|
|
50
|
-
//complete
|
|
51
|
-
valueLevelValidationTest(
|
|
52
|
-
t,
|
|
53
|
-
check.validateTransactionOperation.bind(check),
|
|
54
|
-
TXO.valid_complete_transaction_operation,
|
|
55
|
-
'txo',
|
|
56
|
-
TXO.complete_transaction_operation_value_fields,
|
|
57
|
-
not_allowed_data_types
|
|
58
|
-
);
|
|
59
|
-
// partial
|
|
60
|
-
valueLevelValidationTest(
|
|
61
|
-
t,
|
|
62
|
-
check.validateTransactionOperation.bind(check),
|
|
63
|
-
TXO.valid_partial_transaction_operation,
|
|
64
|
-
'txo',
|
|
65
|
-
TXO.partial_transaction_operation_value_fields,
|
|
66
|
-
not_allowed_data_types
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
test('validateTransactionOperation - address buffer length validation - TOP LEVEL', t => {
|
|
74
|
-
//complete
|
|
75
|
-
addressBufferLengthTest(
|
|
76
|
-
t,
|
|
77
|
-
check.validateTransactionOperation.bind(check),
|
|
78
|
-
TXO.valid_complete_transaction_operation,
|
|
79
|
-
);
|
|
80
|
-
//partial
|
|
81
|
-
addressBufferLengthTest(
|
|
82
|
-
t,
|
|
83
|
-
check.validateTransactionOperation.bind(check),
|
|
84
|
-
TXO.valid_partial_transaction_operation,
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
test('validateTransactionOperation - Buffer length validation - VALUE LEVEL (txo)', t => {
|
|
90
|
-
//complete
|
|
91
|
-
fieldsBufferLengthTest(
|
|
92
|
-
t,
|
|
93
|
-
check.validateTransactionOperation.bind(check),
|
|
94
|
-
TXO.valid_complete_transaction_operation,
|
|
95
|
-
'txo',
|
|
96
|
-
TXO.required_length_of_fields_for_complete_transaction_operation
|
|
97
|
-
);
|
|
98
|
-
//partial
|
|
99
|
-
fieldsBufferLengthTest(
|
|
100
|
-
t,
|
|
101
|
-
check.validateTransactionOperation.bind(check),
|
|
102
|
-
TXO.valid_partial_transaction_operation,
|
|
103
|
-
'txo',
|
|
104
|
-
TXO.required_length_of_fields_for_partial_transaction_operation
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
});
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import test from 'brittle'
|
|
2
|
-
import Check from '../../../../src/utils/check.js';
|
|
3
|
-
import { TRO, not_allowed_data_types } from '../../../fixtures/check.fixtures.js';
|
|
4
|
-
import { topLevelValidationTests, valueLevelValidationTest, addressBufferLengthTest, fieldsBufferLengthTest, partialTypeCommonTests } from './common.test.js';
|
|
5
|
-
import { config } from '../../../helpers/config.js';
|
|
6
|
-
|
|
7
|
-
const check = new Check(config)
|
|
8
|
-
|
|
9
|
-
test('validateTransferOperation - happy-path case', t => {
|
|
10
|
-
// ADD_WRITER
|
|
11
|
-
const partial_result = check.validateTransferOperation(TRO.valid_partial_transfer)
|
|
12
|
-
const complete_result = check.validateTransferOperation(TRO.valid_complete_transfer)
|
|
13
|
-
t.ok(partial_result, 'Valid data for partial transaction operation should pass the validation')
|
|
14
|
-
t.ok(complete_result, 'Valid data for complete transaction operation should pass the validation')
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
test('validateTransferOperation - optional fields va, vn, vs', t => {
|
|
18
|
-
partialTypeCommonTests(
|
|
19
|
-
t,
|
|
20
|
-
check.validateTransferOperation.bind(check),
|
|
21
|
-
TRO.valid_complete_transfer,
|
|
22
|
-
'tro'
|
|
23
|
-
)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test('validateTransferOperation - data type validation TOP LEVEL', t => {
|
|
27
|
-
//complete
|
|
28
|
-
topLevelValidationTests(
|
|
29
|
-
t,
|
|
30
|
-
check.validateTransferOperation.bind(check),
|
|
31
|
-
TRO.valid_complete_transfer,
|
|
32
|
-
'tro',
|
|
33
|
-
not_allowed_data_types,
|
|
34
|
-
TRO.top_fields_transfer
|
|
35
|
-
);
|
|
36
|
-
//partial
|
|
37
|
-
topLevelValidationTests(
|
|
38
|
-
t,
|
|
39
|
-
check.validateTransferOperation.bind(check),
|
|
40
|
-
TRO.valid_partial_transfer,
|
|
41
|
-
'tro',
|
|
42
|
-
not_allowed_data_types,
|
|
43
|
-
TRO.top_fields_transfer
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('validateTransferOperation - value level validation (tro)', t => {
|
|
48
|
-
//complete
|
|
49
|
-
valueLevelValidationTest(
|
|
50
|
-
t,
|
|
51
|
-
check.validateTransferOperation.bind(check),
|
|
52
|
-
TRO.valid_complete_transfer,
|
|
53
|
-
'tro',
|
|
54
|
-
TRO.complete_transfer_value_fields,
|
|
55
|
-
not_allowed_data_types
|
|
56
|
-
);
|
|
57
|
-
// partial
|
|
58
|
-
valueLevelValidationTest(
|
|
59
|
-
t,
|
|
60
|
-
check.validateTransferOperation.bind(check),
|
|
61
|
-
TRO.valid_partial_transfer,
|
|
62
|
-
'tro',
|
|
63
|
-
TRO.partial_transfer_value_fields,
|
|
64
|
-
not_allowed_data_types
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('validateTransferOperation - address buffer length validation - TOP LEVEL', t => {
|
|
70
|
-
//complete
|
|
71
|
-
addressBufferLengthTest(
|
|
72
|
-
t,
|
|
73
|
-
check.validateTransferOperation.bind(check),
|
|
74
|
-
TRO.valid_complete_transfer,
|
|
75
|
-
);
|
|
76
|
-
//partial
|
|
77
|
-
addressBufferLengthTest(
|
|
78
|
-
t,
|
|
79
|
-
check.validateTransferOperation.bind(check),
|
|
80
|
-
TRO.valid_partial_transfer,
|
|
81
|
-
);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('validateTransferOperation - Buffer length validation - VALUE LEVEL (tro)', t => {
|
|
85
|
-
//complete
|
|
86
|
-
fieldsBufferLengthTest(
|
|
87
|
-
t,
|
|
88
|
-
check.validateTransferOperation.bind(check),
|
|
89
|
-
TRO.valid_complete_transfer,
|
|
90
|
-
'tro',
|
|
91
|
-
TRO.required_length_of_fields_for_complete_transfer
|
|
92
|
-
);
|
|
93
|
-
//partial
|
|
94
|
-
fieldsBufferLengthTest(
|
|
95
|
-
t,
|
|
96
|
-
check.validateTransferOperation.bind(check),
|
|
97
|
-
TRO.valid_partial_transfer,
|
|
98
|
-
'tro',
|
|
99
|
-
TRO.required_length_of_fields_for_partial_transfer
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { test, hook } from 'brittle';
|
|
2
|
-
import fileUtils from '../../../../src/utils/fileUtils.js';
|
|
3
|
-
import { errorMessageIncludes } from "../../../helpers/regexHelper.js";
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import PeerWallet from 'trac-wallet';
|
|
6
|
-
import { config } from '../../../helpers/config.js';
|
|
7
|
-
import { asAddress } from '../../../helpers/address.js';
|
|
8
|
-
|
|
9
|
-
const DUMMY_PATH_OK = './dummy_whitelist_ok.csv';
|
|
10
|
-
const DUMMY_PATH_DUP = './dummy_whitelist_dup.csv';
|
|
11
|
-
const DUMMY_PATH_EMPTY = './dummy_whitelist_empty.csv';
|
|
12
|
-
const DUMMY_PATH_BLANK = './dummy_whitelist_blank.csv';
|
|
13
|
-
const DUMMY_PATH_BOM = './dummy_whitelist_bom.csv';
|
|
14
|
-
const DUMMY_PATH_LARGE = './dummy_whitelist_large.csv';
|
|
15
|
-
|
|
16
|
-
const ADDR1 = asAddress('6a38e14198866f0fdf4d4495b07e066cfd0a2e8cbe774d11af37d15f741ac984');
|
|
17
|
-
const ADDR2 = asAddress('544514242356432739de9af71deb8d526fb03d6c5c15e0a934d9a20b6710e2fe');
|
|
18
|
-
|
|
19
|
-
hook('Initialize dummy whitelist files', async t => {
|
|
20
|
-
// Happy path
|
|
21
|
-
fs.writeFileSync(DUMMY_PATH_OK, `${ADDR1}\n${ADDR2}\n`);
|
|
22
|
-
// Edge: duplicated address
|
|
23
|
-
fs.writeFileSync(DUMMY_PATH_DUP, `${ADDR1}\n${ADDR1}\n`);
|
|
24
|
-
// Edge: Empty file
|
|
25
|
-
fs.writeFileSync(DUMMY_PATH_EMPTY, '');
|
|
26
|
-
// Edge: blank lines and whitespace only
|
|
27
|
-
fs.writeFileSync(DUMMY_PATH_BLANK, `\n \n${ADDR1}\n`);
|
|
28
|
-
// Edge: file with BOM
|
|
29
|
-
fs.writeFileSync(DUMMY_PATH_BOM, '\uFEFF' + `${ADDR1}\n`);
|
|
30
|
-
// Edge: large file
|
|
31
|
-
let large = '';
|
|
32
|
-
const randomAddress = async () => {
|
|
33
|
-
const wallet = new PeerWallet({ derivationPath: config.derivationPath });
|
|
34
|
-
await wallet.ready;
|
|
35
|
-
await wallet.generateKeyPair(undefined, config.derivationPath);
|
|
36
|
-
return wallet.address;
|
|
37
|
-
};
|
|
38
|
-
for (let i = 0; i < 1000; i++) {
|
|
39
|
-
const rand = await randomAddress(config.addressPrefix);
|
|
40
|
-
large += `${rand}\n`;
|
|
41
|
-
}
|
|
42
|
-
fs.writeFileSync(DUMMY_PATH_LARGE, large);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('readAddressesFromWhitelistFile - valid file', async (t) => {
|
|
46
|
-
const addresses = await fileUtils.readAddressesFromWhitelistFile(DUMMY_PATH_OK);
|
|
47
|
-
t.is(addresses.length, 2);
|
|
48
|
-
t.ok(addresses.includes(ADDR1));
|
|
49
|
-
t.ok(addresses.includes(ADDR2));
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('readAddressesFromWhitelistFile - duplicate address', async (t) => {
|
|
53
|
-
await t.exception(() => fileUtils.readAddressesFromWhitelistFile(DUMMY_PATH_DUP),
|
|
54
|
-
errorMessageIncludes(`Duplicate addresses found in whitelist file: ${ADDR1}`));
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('readAddressesFromWhitelistFile - blank lines and whitespace', async (t) => {
|
|
58
|
-
const addresses = await fileUtils.readAddressesFromWhitelistFile(DUMMY_PATH_BLANK);
|
|
59
|
-
t.is(addresses.length, 1);
|
|
60
|
-
t.ok(addresses.includes(ADDR1));
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('readAddressesFromWhitelistFile - BOM at start', async (t) => {
|
|
64
|
-
const addresses = await fileUtils.readAddressesFromWhitelistFile(DUMMY_PATH_BOM);
|
|
65
|
-
t.is(addresses.length, 1);
|
|
66
|
-
t.ok(addresses.includes(ADDR1));
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('readAddressesFromWhitelistFile - large file', async (t) => {
|
|
70
|
-
const addresses = await fileUtils.readAddressesFromWhitelistFile(DUMMY_PATH_LARGE);
|
|
71
|
-
t.is(addresses.length, 1000);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test('readAddressesFromWhitelistFile - empty file', async (t) => {
|
|
75
|
-
await t.exception(() => fileUtils.readAddressesFromWhitelistFile(DUMMY_PATH_EMPTY),
|
|
76
|
-
errorMessageIncludes('The whitelist file is empty. File must contain at least one valid address.'));
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('readAddressesFromWhitelistFile - file does not exist', async (t) => {
|
|
80
|
-
const nonExistentPath = './non_existent_whitelist.csv';
|
|
81
|
-
await t.exception(() => fileUtils.readAddressesFromWhitelistFile(nonExistentPath),
|
|
82
|
-
errorMessageIncludes(`Whitelist file not found: ${nonExistentPath}`));
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('readAddressesFromWhitelistFile - invalid file extension', async (t) => {
|
|
86
|
-
const invalidExtensionPath = './dummy_whitelist.txt';
|
|
87
|
-
await t.exception(() => fileUtils.readAddressesFromWhitelistFile(invalidExtensionPath),
|
|
88
|
-
errorMessageIncludes(`Invalid file format: ${invalidExtensionPath}. Balance migration file must be a CSV file.`));
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
hook('Cleanup dummy whitelist files', async t => {
|
|
92
|
-
[DUMMY_PATH_OK, DUMMY_PATH_DUP, DUMMY_PATH_EMPTY, DUMMY_PATH_BLANK, DUMMY_PATH_BOM, DUMMY_PATH_LARGE].forEach(path => {
|
|
93
|
-
if (fs.existsSync(path)) fs.unlinkSync(path);
|
|
94
|
-
});
|
|
95
|
-
});
|