trac-msb 0.2.18 → 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 +25 -8
- 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 +138 -10
- package/src/config/env.js +36 -18
- package/src/core/network/Network.js +52 -24
- package/src/core/network/protocols/ProtocolInterface.js +5 -5
- package/src/core/network/protocols/connectionPolicies.js +86 -0
- package/src/core/network/protocols/legacy/NetworkMessageRouter.js +1 -1
- package/src/core/network/protocols/legacy/handlers/BaseStateOperationHandler.js +2 -2
- package/src/core/network/protocols/legacy/handlers/LegacyGetRequestHandler.js +3 -3
- package/src/core/network/protocols/legacy/handlers/LegacyRoleOperationHandler.js +1 -1
- package/src/core/network/protocols/legacy/handlers/LegacySubnetworkOperationHandler.js +1 -1
- package/src/core/network/protocols/legacy/handlers/LegacyTransferOperationHandler.js +1 -1
- package/src/core/network/protocols/legacy/validators/base/BaseResponse.js +7 -10
- package/src/core/network/protocols/shared/validators/PartialBootstrapDeploymentValidator.js +2 -2
- package/src/core/network/protocols/shared/validators/PartialOperationValidator.js +23 -23
- package/src/core/network/protocols/shared/validators/PartialRoleAccessValidator.js +14 -14
- package/src/core/network/protocols/shared/validators/PartialTransactionValidator.js +5 -5
- package/src/core/network/protocols/shared/validators/PartialTransferValidator.js +12 -11
- package/src/core/network/protocols/v1/V1ProtocolError.js +5 -69
- package/src/core/network/protocols/v1/handlers/V1BaseOperationHandler.js +3 -2
- package/src/core/network/protocols/v1/handlers/V1BroadcastTransactionOperationHandler.js +130 -247
- package/src/core/network/protocols/v1/handlers/V1LivenessOperationHandler.js +6 -5
- 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 +32 -31
- package/src/core/network/protocols/v1/validators/V1BroadcastTransactionRequest.js +5 -3
- package/src/core/network/protocols/v1/validators/V1BroadcastTransactionResponse.js +34 -50
- package/src/core/network/protocols/v1/validators/V1ValidationSchema.js +1 -1
- package/src/core/network/services/ConnectionManager.js +11 -10
- package/src/core/network/services/MessageOrchestrator.js +53 -17
- package/src/core/network/services/PendingRequestService.js +22 -19
- package/src/core/network/services/TransactionCommitService.js +36 -36
- package/src/core/network/services/TransactionPoolService.js +39 -39
- package/src/core/network/services/TransactionRateLimiterService.js +8 -4
- package/src/core/network/services/ValidatorObserverService.js +397 -110
- package/src/core/state/State.js +190 -138
- 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 +316 -275
- package/src/messages/network/v1/NetworkMessageBuilder.js +12 -21
- 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/buffer.js +1 -1
- package/src/utils/check.js +12 -13
- package/src/utils/constants.js +7 -0
- package/src/utils/errors.js +20 -0
- package/src/utils/fileUtils.js +12 -3
- package/src/utils/helpers.js +2 -2
- package/src/utils/migrationUtils.js +3 -3
- package/.dockerignore +0 -16
- 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/v1/enums/message_type.proto +0 -16
- package/proto/network/v1/enums/result_code.proto +0 -84
- package/proto/network/v1/messages/broadcast_transaction_request.proto +0 -9
- package/proto/network/v1/messages/broadcast_transaction_response.proto +0 -13
- package/proto/network/v1/messages/liveness_request.proto +0 -8
- package/proto/network/v1/messages/liveness_response.proto +0 -11
- package/proto/network/v1/network_message.proto +0 -22
- package/rpc/rpc_services.js +0 -181
- package/scripts/generate-protobufs.js +0 -67
- package/src/core/network/identity/NetworkWalletFactory.js +0 -77
- package/src/core/network/protocols/shared/errors/SharedValidatorRejectionError.js +0 -27
- package/src/utils/cli.js +0 -130
- package/src/utils/cliCommands.js +0 -280
- package/tests/acceptance/v1/account/account.test.mjs +0 -129
- 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 -133
- package/tests/acceptance/v1/tx-details/tx-details.test.mjs +0 -241
- 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 -59
- 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 -436
- package/tests/unit/messages/network/NetworkMessageDirector.test.js +0 -347
- 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/LegacyNetworkMessageRouter.test.js +0 -54
- package/tests/unit/network/NetworkWalletFactory.test.js +0 -156
- package/tests/unit/network/ProtocolSession.test.js +0 -127
- package/tests/unit/network/networkModule.test.js +0 -13
- package/tests/unit/network/services/ConnectionManager.test.js +0 -450
- package/tests/unit/network/services/MessageOrchestrator.test.js +0 -445
- package/tests/unit/network/services/PendingRequestService.test.js +0 -431
- package/tests/unit/network/services/TransactionCommitService.test.js +0 -246
- package/tests/unit/network/services/TransactionPoolService.test.js +0 -489
- package/tests/unit/network/services/TransactionRateLimiterService.test.js +0 -139
- package/tests/unit/network/services/ValidatorHealthCheckService.test.js +0 -115
- package/tests/unit/network/services/services.test.js +0 -17
- package/tests/unit/network/utils/v1TestUtils.js +0 -153
- package/tests/unit/network/v1/NetworkMessageRouterV1.test.js +0 -151
- package/tests/unit/network/v1/V1BaseOperation.test.js +0 -356
- package/tests/unit/network/v1/V1BroadcastTransactionOperationHandler.test.js +0 -129
- package/tests/unit/network/v1/V1BroadcastTransactionRequest.test.js +0 -53
- package/tests/unit/network/v1/V1BroadcastTransactionResponse.test.js +0 -512
- package/tests/unit/network/v1/V1LivenessRequest.test.js +0 -32
- package/tests/unit/network/v1/V1LivenessResponse.test.js +0 -45
- package/tests/unit/network/v1/V1ResultCode.test.js +0 -84
- package/tests/unit/network/v1/V1ValidationSchema.test.js +0 -13
- package/tests/unit/network/v1/connectionPolicies.test.js +0 -49
- package/tests/unit/network/v1/handlers/V1BaseOperationHandler.test.js +0 -284
- package/tests/unit/network/v1/handlers/V1BroadcastTransactionOperationHandler.test.js +0 -794
- package/tests/unit/network/v1/handlers/V1LivenessOperationHandler.test.js +0 -193
- package/tests/unit/network/v1/v1.handlers.test.js +0 -15
- package/tests/unit/network/v1/v1.test.js +0 -19
- package/tests/unit/network/v1/v1ValidationSchema/broadcastTransactionRequest.test.js +0 -119
- package/tests/unit/network/v1/v1ValidationSchema/broadcastTransactionResponse.test.js +0 -136
- package/tests/unit/network/v1/v1ValidationSchema/common.test.js +0 -308
- package/tests/unit/network/v1/v1ValidationSchema/livenessRequest.test.js +0 -90
- package/tests/unit/network/v1/v1ValidationSchema/livenessResponse.test.js +0 -133
- 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/deepEqualApplyPayload/deepEqualApplyPayload.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 -303
- 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 -21
- 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,102 +0,0 @@
|
|
|
1
|
-
import test from 'brittle';
|
|
2
|
-
import b4a from 'b4a';
|
|
3
|
-
|
|
4
|
-
import fixtures from '../../../fixtures/protobuf.fixtures.js';
|
|
5
|
-
import { isDeepEqualApplyPayload } from '../../../../src/utils/deepEqualApplyPayload.js';
|
|
6
|
-
|
|
7
|
-
const applyPayloads = new Map([
|
|
8
|
-
['txComplete', fixtures.validTransactionOperation],
|
|
9
|
-
['txPartial', fixtures.validPartialTransactionOperation],
|
|
10
|
-
['addIndexer', fixtures.validAddIndexer],
|
|
11
|
-
['removeIndexer', fixtures.validRemoveIndexer],
|
|
12
|
-
['appendWhitelist', fixtures.validAppendWhitelist],
|
|
13
|
-
['banValidator', fixtures.validBanValidator],
|
|
14
|
-
['addAdmin', fixtures.validAddAdmin],
|
|
15
|
-
['addWriterComplete', fixtures.validCompleteAddWriter],
|
|
16
|
-
['addWriterPartial', fixtures.validPartialAddWriter],
|
|
17
|
-
['removeWriterComplete', fixtures.validCompleteRemoveWriter],
|
|
18
|
-
['removeWriterPartial', fixtures.validPartialRemoveWriter],
|
|
19
|
-
['adminRecoveryComplete', fixtures.validCompleteAdminRecovery],
|
|
20
|
-
['adminRecoveryPartial', fixtures.validPartialAdminRecovery],
|
|
21
|
-
['bootstrapDeploymentComplete', fixtures.validCompleteBootstrapDeployment],
|
|
22
|
-
['bootstrapDeploymentPartial', fixtures.validPartialBootstrapDeployment],
|
|
23
|
-
['transferComplete', fixtures.validTransferOperation],
|
|
24
|
-
['transferPartial', fixtures.validPartialTransferOperation],
|
|
25
|
-
['balanceInitialization', fixtures.validBalanceInitOperation],
|
|
26
|
-
['disableInitialization', fixtures.validDisableInitialization],
|
|
27
|
-
]);
|
|
28
|
-
|
|
29
|
-
const cloneDeep = (value) => {
|
|
30
|
-
if (b4a.isBuffer(value)) return b4a.from(value);
|
|
31
|
-
|
|
32
|
-
if (Array.isArray(value)) {
|
|
33
|
-
return value.map(cloneDeep);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (value && typeof value === 'object') {
|
|
37
|
-
const clone = {};
|
|
38
|
-
for (const key of Object.keys(value)) {
|
|
39
|
-
clone[key] = cloneDeep(value[key]);
|
|
40
|
-
}
|
|
41
|
-
return clone;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return value;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const mutateFirstBuffer = (value) => {
|
|
48
|
-
if (!value || typeof value !== 'object') return false;
|
|
49
|
-
|
|
50
|
-
if (Array.isArray(value)) {
|
|
51
|
-
for (let i = 0; i < value.length; i++) {
|
|
52
|
-
if (mutateFirstBuffer(value[i])) return true;
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
for (const key of Object.keys(value)) {
|
|
58
|
-
const current = value[key];
|
|
59
|
-
|
|
60
|
-
if (b4a.isBuffer(current)) {
|
|
61
|
-
if (current.length === 0) {
|
|
62
|
-
value[key] = b4a.from([0x01]);
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
current[0] = current[0] ^ 0xff;
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (current && typeof current === 'object') {
|
|
71
|
-
if (mutateFirstBuffer(current)) return true;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return false;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
test('isDeepEqualApplyPayload returns true for deep-equal apply payload fixtures', t => {
|
|
79
|
-
for (const [name, payload] of applyPayloads) {
|
|
80
|
-
const cloned = cloneDeep(payload);
|
|
81
|
-
t.ok(isDeepEqualApplyPayload(payload, cloned), `${name} should be deep-equal`);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('isDeepEqualApplyPayload returns false when payload content differs', t => {
|
|
86
|
-
for (const [name, payload] of applyPayloads) {
|
|
87
|
-
const mutated = cloneDeep(payload);
|
|
88
|
-
const didMutate = mutateFirstBuffer(mutated);
|
|
89
|
-
|
|
90
|
-
t.ok(didMutate, `${name} mutation should modify at least one buffer`);
|
|
91
|
-
t.absent(isDeepEqualApplyPayload(payload, mutated), `${name} should not be deep-equal after mutation`);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test('isDeepEqualApplyPayload handles primitive and structural mismatches', t => {
|
|
96
|
-
t.ok(isDeepEqualApplyPayload(null, null), 'null equals null');
|
|
97
|
-
t.absent(isDeepEqualApplyPayload(null, undefined), 'null and undefined differ');
|
|
98
|
-
t.absent(isDeepEqualApplyPayload(1, '1'), 'number and string differ');
|
|
99
|
-
t.absent(isDeepEqualApplyPayload([], {}), 'array and object differ');
|
|
100
|
-
t.absent(isDeepEqualApplyPayload({ type: 1 }, { type: 1, extra: true }), 'missing/extra keys differ');
|
|
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
|
-
});
|