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,213 +0,0 @@
|
|
|
1
|
-
import request from "supertest"
|
|
2
|
-
import { buildRpcSelfTransferPayload, waitForConnection } from "../../../helpers/transactionPayloads.mjs"
|
|
3
|
-
|
|
4
|
-
export const registerTxDetailsTests = (context) => {
|
|
5
|
-
describe("GET /v1/tx/details", () => {
|
|
6
|
-
it("returns 200 for broadcasted hash (confirmed and unconfirmed)", async () => {
|
|
7
|
-
const { payload, txHashHex } = await buildRpcSelfTransferPayload(
|
|
8
|
-
context,
|
|
9
|
-
context.rpcMsb.state,
|
|
10
|
-
1n
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
await waitForConnection(context.rpcMsb)
|
|
14
|
-
const broadcastRes = await request(context.server)
|
|
15
|
-
.post("/v1/broadcast-transaction")
|
|
16
|
-
.set("Accept", "application/json")
|
|
17
|
-
.send(JSON.stringify({ payload }))
|
|
18
|
-
expect(broadcastRes.statusCode).toBe(200)
|
|
19
|
-
|
|
20
|
-
const resConfirmed = await request(context.server)
|
|
21
|
-
.get(`/v1/tx/details/${txHashHex}?confirmed=true`)
|
|
22
|
-
expect(resConfirmed.statusCode).toBe(200)
|
|
23
|
-
|
|
24
|
-
expect(resConfirmed.body).toMatchObject({
|
|
25
|
-
txDetails: expect.any(Object),
|
|
26
|
-
confirmed_length: expect.any(Number),
|
|
27
|
-
fee: expect.any(String)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const resUnconfirmed = await request(context.server)
|
|
31
|
-
.get(`/v1/tx/details/${txHashHex}?confirmed=false`)
|
|
32
|
-
expect(resUnconfirmed.statusCode).toBe(200)
|
|
33
|
-
|
|
34
|
-
expect(resUnconfirmed.body).toMatchObject({
|
|
35
|
-
txDetails: expect.any(Object),
|
|
36
|
-
confirmed_length: expect.any(Number),
|
|
37
|
-
fee: expect.any(String)
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it("handles null confirmed_length for unconfirmed transaction", async () => {
|
|
42
|
-
const { payload, txHashHex } = await buildRpcSelfTransferPayload(
|
|
43
|
-
context,
|
|
44
|
-
context.rpcMsb.state,
|
|
45
|
-
1n
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const originalGetConfirmedLength = context.rpcMsb.state.getTransactionConfirmedLength
|
|
49
|
-
context.rpcMsb.state.getTransactionConfirmedLength = async () => null
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
|
|
53
|
-
await waitForConnection(context.rpcMsb)
|
|
54
|
-
const broadcastRes = await request(context.server)
|
|
55
|
-
.post("/v1/broadcast-transaction")
|
|
56
|
-
.set("Accept", "application/json")
|
|
57
|
-
.send(JSON.stringify({ payload }))
|
|
58
|
-
expect(broadcastRes.statusCode).toBe(200)
|
|
59
|
-
|
|
60
|
-
const res = await request(context.server)
|
|
61
|
-
.get(`/v1/tx/details/${txHashHex}?confirmed=false`)
|
|
62
|
-
expect(res.statusCode).toBe(200)
|
|
63
|
-
|
|
64
|
-
expect(res.body).toMatchObject({
|
|
65
|
-
txDetails: expect.any(Object),
|
|
66
|
-
confirmed_length: 0,
|
|
67
|
-
fee: '0'
|
|
68
|
-
})
|
|
69
|
-
} finally {
|
|
70
|
-
context.rpcMsb.state.getTransactionConfirmedLength = originalGetConfirmedLength
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it("returns 404 for non-existent transaction hash", async () => {
|
|
75
|
-
const nonExistentHash = "0b4d1c1dac48af13212f616601d7399457476a0b644850875b7f4b79df6ff89c"
|
|
76
|
-
const res = await request(context.server)
|
|
77
|
-
.get(`/v1/tx/details/${nonExistentHash}`)
|
|
78
|
-
|
|
79
|
-
expect(res.statusCode).toBe(404)
|
|
80
|
-
expect(res.body).toEqual({
|
|
81
|
-
error: `No payload found for tx hash: ${nonExistentHash}`
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
it("returns 400 for invalid hash format (too short)", async () => {
|
|
86
|
-
const invalidHash = '0'.repeat(63)
|
|
87
|
-
const res = await request(context.server)
|
|
88
|
-
.get(`/v1/tx/details/${invalidHash}`)
|
|
89
|
-
|
|
90
|
-
expect(res.statusCode).toBe(400)
|
|
91
|
-
expect(res.body).toEqual({
|
|
92
|
-
error: "Invalid transaction hash format"
|
|
93
|
-
})
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it("returns 400 for invalid hash format (non-hex)", async () => {
|
|
97
|
-
const invalidHash = 'Z'.repeat(64)
|
|
98
|
-
const res = await request(context.server)
|
|
99
|
-
.get(`/v1/tx/details/${invalidHash}`)
|
|
100
|
-
|
|
101
|
-
expect(res.statusCode).toBe(400)
|
|
102
|
-
expect(res.body).toEqual({
|
|
103
|
-
error: "Invalid transaction hash format"
|
|
104
|
-
})
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
it("returns 400 for invalid confirmed parameter", async () => {
|
|
108
|
-
const hash = "0b4d1c1dac48af13212f616601d7399457476a0b644850875b7f4b79df6ff89c"
|
|
109
|
-
|
|
110
|
-
const res = await request(context.server)
|
|
111
|
-
.get(`/v1/tx/details/${hash}?confirmed=invalid`)
|
|
112
|
-
|
|
113
|
-
expect(res.statusCode).toBe(400)
|
|
114
|
-
expect(res.body).toEqual({
|
|
115
|
-
error: 'Parameter "confirmed" must be exactly "true" or "false"'
|
|
116
|
-
})
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
it("returns 400 for invalid confirmed parameter case (UPPERCASE)", async () => {
|
|
120
|
-
const hash = "0b4d1c1dac48af13212f616601d7399457476a0b644850875b7f4b79df6ff89c"
|
|
121
|
-
const res = await request(context.server).get(`/v1/tx/details/${hash}?confirmed=TRUE`)
|
|
122
|
-
expect(res.statusCode).toBe(400)
|
|
123
|
-
expect(res.body).toEqual({
|
|
124
|
-
error: 'Parameter "confirmed" must be exactly "true" or "false"'
|
|
125
|
-
})
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it("returns 400 when no hash provided", async () => {
|
|
129
|
-
const res = await request(context.server)
|
|
130
|
-
.get('/v1/tx/details')
|
|
131
|
-
|
|
132
|
-
expect(res.statusCode).toBe(400)
|
|
133
|
-
expect(res.body).toEqual({
|
|
134
|
-
error: "Transaction hash is required"
|
|
135
|
-
})
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
it("returns 400 for hash with invalid characters", async () => {
|
|
139
|
-
const invalidHash = '0b4d1c1dac48$af13212f6166017399457476a0b644850875b7f4b79df6ff89c'
|
|
140
|
-
const res = await request(context.server)
|
|
141
|
-
.get(`/v1/tx/details/${invalidHash}`)
|
|
142
|
-
|
|
143
|
-
expect(res.statusCode).toBe(400)
|
|
144
|
-
expect(res.body).toEqual({
|
|
145
|
-
error: "Invalid transaction hash format"
|
|
146
|
-
})
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
it("returns 400 for hash with special characters", async () => {
|
|
150
|
-
const invalidHash = '!@#$%^&*'.repeat(8)
|
|
151
|
-
const res = await request(context.server)
|
|
152
|
-
.get(`/v1/tx/details/${invalidHash}`)
|
|
153
|
-
|
|
154
|
-
expect(res.statusCode).toBe(400)
|
|
155
|
-
expect(res.body).toEqual({
|
|
156
|
-
error: "Invalid transaction hash format"
|
|
157
|
-
})
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
it("returns 400 for hash with spaces", async () => {
|
|
161
|
-
const invalidHash = '0b4d1c1dac48af13212f616601d7399457476a0b644850875b7 4b79df6ff89c'
|
|
162
|
-
const res = await request(context.server)
|
|
163
|
-
.get(`/v1/tx/details/${invalidHash}`)
|
|
164
|
-
|
|
165
|
-
expect(res.statusCode).toBe(400)
|
|
166
|
-
expect(res.body).toEqual({
|
|
167
|
-
error: "Invalid transaction hash format"
|
|
168
|
-
})
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
it("returns 400 for hash with 0x prefix", async () => {
|
|
172
|
-
const hash = "0x" + "0".repeat(62)
|
|
173
|
-
const res = await request(context.server).get(`/v1/tx/details/${hash}`)
|
|
174
|
-
expect(res.statusCode).toBe(400)
|
|
175
|
-
expect(res.body).toEqual({ error: "Invalid transaction hash format" })
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
it("returns 400 for odd-length hex", async () => {
|
|
179
|
-
const hash = "a".repeat(63)
|
|
180
|
-
const res = await request(context.server).get(`/v1/tx/details/${hash}`)
|
|
181
|
-
expect(res.statusCode).toBe(400)
|
|
182
|
-
expect(res.body).toEqual({ error: "Invalid transaction hash format" })
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
it("accepts uppercase hex", async () => {
|
|
186
|
-
const { payload, txHashHex } = await buildRpcSelfTransferPayload(
|
|
187
|
-
context,
|
|
188
|
-
context.rpcMsb.state,
|
|
189
|
-
1n
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
await waitForConnection(context.rpcMsb);
|
|
193
|
-
await request(context.server)
|
|
194
|
-
.post("/v1/broadcast-transaction")
|
|
195
|
-
.send(JSON.stringify({ payload }));
|
|
196
|
-
|
|
197
|
-
const upperHash = txHashHex.toUpperCase();
|
|
198
|
-
const res = await request(context.server)
|
|
199
|
-
.get(`/v1/tx/details/${upperHash}?confirmed=false`);
|
|
200
|
-
|
|
201
|
-
expect(res.statusCode).toBe(200);
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
it("returns 400 for trailing space hash", async () => {
|
|
205
|
-
const hash = "a".repeat(64) + " ";
|
|
206
|
-
const res = await request(context.server)
|
|
207
|
-
.get(`/v1/tx/details/${encodeURIComponent(hash)}`);
|
|
208
|
-
|
|
209
|
-
expect(res.statusCode).toBe(400);
|
|
210
|
-
expect(res.body).toEqual({ error: "Invalid transaction hash format" });
|
|
211
|
-
});
|
|
212
|
-
})
|
|
213
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import request from "supertest"
|
|
2
|
-
|
|
3
|
-
export const registerTxHashesTests = (context) => {
|
|
4
|
-
describe("GET /v1/tx-hashes", () => {
|
|
5
|
-
it("< 1000", async () => {
|
|
6
|
-
const res = await request(context.server).get("/v1/tx-hashes/1/1001")
|
|
7
|
-
expect(res.statusCode).toBe(200)
|
|
8
|
-
expect(res.body).toEqual({
|
|
9
|
-
hashes: expect.arrayContaining([
|
|
10
|
-
expect.objectContaining({
|
|
11
|
-
hash: expect.any(String),
|
|
12
|
-
confirmed_length: expect.any(Number),
|
|
13
|
-
})
|
|
14
|
-
])
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it("> 1000", async () => {
|
|
19
|
-
const res = await request(context.server).get("/v1/tx-hashes/1/1002")
|
|
20
|
-
expect(res.statusCode).toBe(400)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it("returns 400 for non-integer params", async () => {
|
|
24
|
-
const res = await request(context.server).get("/v1/tx-hashes/foo/bar")
|
|
25
|
-
expect(res.statusCode).toBe(400)
|
|
26
|
-
expect(res.body).toEqual({ error: "Params must be integer" })
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it("returns 400 for negative params", async () => {
|
|
30
|
-
const res = await request(context.server).get("/v1/tx-hashes/-1/10")
|
|
31
|
-
expect(res.statusCode).toBe(400)
|
|
32
|
-
expect(res.body).toEqual({ error: "Params must be non-negative" })
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it("returns 400 when end < start", async () => {
|
|
36
|
-
const res = await request(context.server).get("/v1/tx-hashes/10/5")
|
|
37
|
-
expect(res.statusCode).toBe(400)
|
|
38
|
-
expect(res.body).toEqual({ error: "endSignedLength must be greater than or equal to startSignedLength." })
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
it("accepts boundary at exactly MAX_SIGNED_LENGTH", async () => {
|
|
42
|
-
const res = await request(context.server).get("/v1/tx-hashes/1/1001")
|
|
43
|
-
expect(res.statusCode).toBe(200)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it("trims range to current confirmed length", async () => {
|
|
47
|
-
const confirmed = await request(context.server).get("/v1/confirmed-length")
|
|
48
|
-
expect(confirmed.statusCode).toBe(200)
|
|
49
|
-
const beyond = confirmed.body.confirmed_length + 50
|
|
50
|
-
const res = await request(context.server).get(`/v1/tx-hashes/0/${beyond}`)
|
|
51
|
-
expect(res.statusCode).toBe(200)
|
|
52
|
-
const hashes = res.body.hashes || []
|
|
53
|
-
// last item confirmed_length should not exceed current confirmed length
|
|
54
|
-
const maxReturned = hashes.reduce((max, { confirmed_length }) => Math.max(max, confirmed_length || 0), 0)
|
|
55
|
-
expect(maxReturned).toBeLessThanOrEqual(confirmed.body.confirmed_length)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it("returns empty hashes when no data in range", async () => {
|
|
59
|
-
const res = await request(context.server).get("/v1/tx-hashes/0/0")
|
|
60
|
-
expect(res.statusCode).toBe(200)
|
|
61
|
-
expect(res.body).toHaveProperty("hashes")
|
|
62
|
-
expect(Array.isArray(res.body.hashes)).toBe(true)
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it("returns empty hashes when start equals end", async () => {
|
|
66
|
-
const res = await request(context.server).get("/v1/tx-hashes/5/5")
|
|
67
|
-
expect(res.statusCode).toBe(200)
|
|
68
|
-
expect(res.body).toHaveProperty("hashes")
|
|
69
|
-
expect(res.body.hashes).toEqual([])
|
|
70
|
-
})
|
|
71
|
-
})
|
|
72
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import request from "supertest"
|
|
2
|
-
|
|
3
|
-
export const registerTxPayloadsBulkTests = (context) => {
|
|
4
|
-
describe("POST /v1/tx-payloads-bulk", () => {
|
|
5
|
-
it("returns payloads for requested hashes", async () => {
|
|
6
|
-
const result = await context.rpcMsb.state.confirmedTransactionsBetween(0, 40) // Arbitrary range that should contain valid entries
|
|
7
|
-
const hashes = result.map(({ hash }) => hash)
|
|
8
|
-
|
|
9
|
-
const payload = { hashes }
|
|
10
|
-
|
|
11
|
-
const res = await request(context.server)
|
|
12
|
-
.post("/v1/tx-payloads-bulk")
|
|
13
|
-
.set("Accept", "application/json")
|
|
14
|
-
.send(JSON.stringify(payload))
|
|
15
|
-
|
|
16
|
-
expect(res.statusCode).toBe(200)
|
|
17
|
-
expect(res.body).toMatchObject({
|
|
18
|
-
results: expect.arrayOf(
|
|
19
|
-
expect.objectContaining({
|
|
20
|
-
hash: expect.any(String),
|
|
21
|
-
})
|
|
22
|
-
),
|
|
23
|
-
missing: []
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import request from "supertest"
|
|
2
|
-
|
|
3
|
-
export const registerTxvTests = (context) => {
|
|
4
|
-
describe("GET /v1/txv", () => {
|
|
5
|
-
it("returns txv hash", async () => {
|
|
6
|
-
const res = await request(context.server).get("/v1/txv")
|
|
7
|
-
expect(res.statusCode).toBe(200)
|
|
8
|
-
expect(res.body).toEqual({ txv: expect.stringMatching(/^[a-z0-9]{64}$/) })
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import request from "supertest"
|
|
2
|
-
|
|
3
|
-
export const registerUnconfirmedLengthTests = (context) => {
|
|
4
|
-
describe("GET /v1/unconfirmed-length", () => {
|
|
5
|
-
it("returns unconfirmed length", async () => {
|
|
6
|
-
const res = await request(context.server).get("/v1/unconfirmed-length")
|
|
7
|
-
expect(res.statusCode).toBe(200)
|
|
8
|
-
expect(res.body).toEqual({ unconfirmed_length: expect.any(Number) })
|
|
9
|
-
})
|
|
10
|
-
})
|
|
11
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
export const testKeyPair1 = {
|
|
2
|
-
publicKey: '82f6c1f684f4e251dfe092155b8861a0625b596991810b2b80b9c65ccbec5ad3',
|
|
3
|
-
secretKey: '734aa8a4ff1506a502054f537c235d3fbe70452926bad869c3ab57e90d06df7382f6c1f684f4e251dfe092155b8861a0625b596991810b2b80b9c65ccbec5ad3',
|
|
4
|
-
mnemonic: 'slight wedding permit mention subject mask hawk awkward sniff leopard spider scatter close neutral deny apple wide category sick love sorry pupil then legal'
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const testKeyPair2 = {
|
|
8
|
-
publicKey: "8f17ec2862c7b3e4dbbedaf88a68a9b74d76e9d6acca6ca4a5fafb1b6c474616",
|
|
9
|
-
secretKey: "21b7f3c56eaa4d8114530258c79b8086bcca3e61d6c9edee589e8ca2f48688e98f17ec2862c7b3e4dbbedaf88a68a9b74d76e9d6acca6ca4a5fafb1b6c474616",
|
|
10
|
-
mnemonic: "century category maze cover student upset trip cup purchase area turtle keen minimum flee diagram romance stool absorb umbrella phone valve avocado fade window"
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const testKeyPair3 = {
|
|
14
|
-
publicKey: "3341b586cad305908b4ac0cf9176851d90c64a7b7d3ff74100262e383d63c6b8",
|
|
15
|
-
secretKey: "25178b87c194c3e84358323a2ec43069610a5b48fdd4ca88689155bbc5c180b13341b586cad305908b4ac0cf9176851d90c64a7b7d3ff74100262e383d63c6b8",
|
|
16
|
-
mnemonic: "inner pond duty corn danger board tragic penalty mad lounge excite lottery great current high exercise spin noble true curtain airport trend when decade"
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const testKeyPair4 = {
|
|
20
|
-
publicKey: "94bb26ad3449feb0039f201051ab7e0efb7e75cf6d919811b21b80ad7d111c68",
|
|
21
|
-
secretKey: "aaa800b8f5666f5a9e3036b22dff56d33f0da4d7dc09dad6319605b2312d022094bb26ad3449feb0039f201051ab7e0efb7e75cf6d919811b21b80ad7d111c68",
|
|
22
|
-
mnemonic: "blue moral east arch pistol episode misery garment spoil tip inflict mean seven improve doll loan artist you skill shoe aerobic decide border demand"
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const testKeyPair5 = {
|
|
26
|
-
publicKey: "6822a868e5a30c2c571e548f0807f3bd9760d04c4d6a32fe27d30c23c0eaa04b",
|
|
27
|
-
secretKey: "a573ec441c4f45a451ca615c5b31f4171e567c0c19e906cfe9af308826e6d37d6822a868e5a30c2c571e548f0807f3bd9760d04c4d6a32fe27d30c23c0eaa04b",
|
|
28
|
-
mnemonic: "walnut disagree toward verify shaft decade stage cactus very asset gasp recycle occur steel gorilla diamond slice sunset train train pill embrace senior clutch"
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const testKeyPair6 = {
|
|
32
|
-
publicKey: "362020e3249c6942d6ecfded6776820cf7c32242ee56ad169b97637fb32fa654",
|
|
33
|
-
secretKey: "6ab0b0102e31f1115b4e5a6d9de75aef64e83e3b98d683d09665789dd6811d52362020e3249c6942d6ecfded6776820cf7c32242ee56ad169b97637fb32fa654",
|
|
34
|
-
mnemonic: "marriage clean edit portion panic easy member worry cave elevator abuse math squirrel scorpion syrup eager horror human cruise robust duty trophy biology edit"
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const testKeyPair7 = {
|
|
38
|
-
publicKey: "e3d788961c2f0b9114e2545233c519bc3fc1c13ad0f8e00b624f308ce377e441",
|
|
39
|
-
secretKey: "9e7710867b2194fc06bfe72e2ceca043c045029edbf818a3538095b32f81f7cbe3d788961c2f0b9114e2545233c519bc3fc1c13ad0f8e00b624f308ce377e441",
|
|
40
|
-
mnemonic: "gift carry tackle motion siren ten hope slice danger wide miss abandon basic version nothing jar jeans coconut accuse lumber ocean swamp jump chef"
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const testKeyPair8 = {
|
|
44
|
-
publicKey: "ec72b40efcfabcf564766b7af17f3a3dc5a53d4c951eb826839ce2d0b1490e32",
|
|
45
|
-
secretKey: "485efdaad1cb695cd4d48af832826593c572f8373d55c3c4862ef8b293877e5dec72b40efcfabcf564766b7af17f3a3dc5a53d4c951eb826839ce2d0b1490e32",
|
|
46
|
-
mnemonic: "wide cram erupt possible buddy pause hole when spin exercise casino cruise panther hurdle cancel dutch time album pumpkin child report blind language birth"
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const testKeyPair9 = {
|
|
50
|
-
publicKey: "8198b64491c80430bb4c96bd81040a4e11531219c84e4834254a94c2b868ef6b",
|
|
51
|
-
secretKey: "8f86405b31f69e612f03087e0d58771e207b2cad69936c27a488edc528509e388198b64491c80430bb4c96bd81040a4e11531219c84e4834254a94c2b868ef6b",
|
|
52
|
-
mnemonic: "private eternal short purse rigid swim satoshi minor knock gauge energy project common avocado spell episode indicate repeat gentle permit defy stone pause hurdle"
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const testKeyPair10 = {
|
|
56
|
-
publicKey: "bfbb432d2ad0890590864e25a38112a0fd69fa09b82a12d61884c7c12fc47ddb",
|
|
57
|
-
secretKey: "e7f4375ae010685c28e96b970643fa4593090823fb652adc18a68a12e97b0a37bfbb432d2ad0890590864e25a38112a0fd69fa09b82a12d61884c7c12fc47ddb",
|
|
58
|
-
mnemonic: "increase spring lobster sound among leave champion help voyage debate thunder retreat venue easily open crouch boil fury burst bean weird survey dirt supply"
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const testKeyPair11 = {
|
|
62
|
-
publicKey: "bfbb432d2ad0890590864e25a38112a0fd69fa09b82a12d61884c7c12fc47ddb",
|
|
63
|
-
secretKey: "9b913cee5fd66c11eb29130cc80993ab5e889ae317b3016b58a2062836ff27e5e36ebd8d0ad007d0febca2794ce708e6483f9fa339f2eed9e8825b1d9bc455e0",
|
|
64
|
-
mnemonic: "fan exotic hill chronic cluster lucky heavy fury tell gym stone shrug guilt hamster achieve meat economy adjust young ignore tomorrow bachelor soft crumble"
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export const testKeyPair12 = {
|
|
68
|
-
publicKey: "7a2d1329679d9631bcf8a5046e38e826c0bc2c1f1c17561907e7ab6d46c61158",
|
|
69
|
-
secretKey: "e1dde2b8793f8f25677bd29b49e074804dd63b19b236e5f69783c7ee6a8287dc7a2d1329679d9631bcf8a5046e38e826c0bc2c1f1c17561907e7ab6d46c61158",
|
|
70
|
-
mnemonic: "time token syrup try play renew circle mirror palace vapor vacant chronic theme pudding jelly pride actual tank broccoli sugar onion absurd muffin bar"
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export const testKeyPair13 = {
|
|
74
|
-
publicKey: "fc13fa7f1df30d0e96d7ac80a208b5d738c501c0f7e7dab216a4d847fd9bd65c",
|
|
75
|
-
secretKey: "0d9aca8e607e9e07f69d80b372d5dcb152460fe4537a52edd87b0be231b0a9e6fc13fa7f1df30d0e96d7ac80a208b5d738c501c0f7e7dab216a4d847fd9bd65c",
|
|
76
|
-
mnemonic: "quality drop minimum teach present slogan electric hire home orange relax february race fragile actual prefer trade jealous sentence thrive orange grace royal tonight"
|
|
77
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import PeerWallet from 'trac-wallet';
|
|
2
|
-
import b4a from 'b4a';
|
|
3
|
-
import { config } from '../helpers/config.js';
|
|
4
|
-
|
|
5
|
-
export const mnemonicAdmin = "science edit ankle purity treat unable first express scatter depend also case nose regular rally area carbon wait power corn sibling metal crop farm";
|
|
6
|
-
|
|
7
|
-
export const writingKeyAdmin = b4a.from("0768953b234c79eccc6306fdcba2d7c1f0b05b9af6815a3502e96a83a8878ff7", 'hex');
|
|
8
|
-
export const writingKeyNonAdmin = b4a.from("1768953b234c79eccc6306fdcba2d7c1f0b05b9af6815a3502e96a83a8878ff8", 'hex');
|
|
9
|
-
|
|
10
|
-
export const bootstrapAdmin = writingKeyAdmin;
|
|
11
|
-
|
|
12
|
-
export const walletAdmin = new PeerWallet({ derivationPath: config.derivationPath });
|
|
13
|
-
export const walletNonAdmin = new PeerWallet({ derivationPath: config.derivationPath });
|
|
14
|
-
export const walletPeer = new PeerWallet({ derivationPath: config.derivationPath });
|
|
15
|
-
|
|
16
|
-
export const adminEntry = {
|
|
17
|
-
address: null,
|
|
18
|
-
wk: null,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const initAll = async () => {
|
|
22
|
-
if (!walletAdmin.publicKey) await walletAdmin.generateKeyPair(mnemonicAdmin, config.derivationPath);
|
|
23
|
-
if (!walletNonAdmin.publicKey) await walletNonAdmin.generateKeyPair(walletNonAdmin.generateMnemonic(), config.derivationPath);
|
|
24
|
-
if (!walletPeer.publicKey) await walletPeer.generateKeyPair(walletPeer.generateMnemonic(), config.derivationPath);
|
|
25
|
-
if (!adminEntry.address && !adminEntry.wk) {
|
|
26
|
-
adminEntry.address = walletAdmin.address;
|
|
27
|
-
adminEntry.wk = writingKeyAdmin;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default {
|
|
32
|
-
mnemonicAdmin,
|
|
33
|
-
writingKeyAdmin,
|
|
34
|
-
writingKeyNonAdmin,
|
|
35
|
-
bootstrapAdmin,
|
|
36
|
-
walletAdmin,
|
|
37
|
-
walletNonAdmin,
|
|
38
|
-
walletPeer,
|
|
39
|
-
adminEntry,
|
|
40
|
-
initAll,
|
|
41
|
-
}
|