postchain-client 1.22.0 → 2.0.1
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 +16 -0
- package/built/cjs/index.js +2205 -3742
- package/built/cjs/index.js.map +1 -1
- package/built/esm/index.js +10425 -11683
- package/built/esm/index.js.map +1 -1
- package/built/index.d.ts +3 -8
- package/built/index.js +2 -11
- package/built/index.js.map +1 -1
- package/built/mocks/handlers.d.ts +1 -1
- package/built/mocks/handlers.js +62 -21
- package/built/mocks/handlers.js.map +1 -1
- package/built/src/ICCF/IccfProofTxMaterialBuilder.d.ts +3 -2
- package/built/src/ICCF/IccfProofTxMaterialBuilder.js +23 -10
- package/built/src/ICCF/IccfProofTxMaterialBuilder.js.map +1 -1
- package/built/src/ICCF/types.d.ts +4 -1
- package/built/src/ICCF/utils.js +2 -2
- package/built/src/ICCF/utils.js.map +1 -1
- package/built/src/blockchainClient/blockchainClient.js +56 -53
- package/built/src/blockchainClient/blockchainClient.js.map +1 -1
- package/built/src/blockchainClient/clientStub.js +18 -16
- package/built/src/blockchainClient/clientStub.js.map +1 -1
- package/built/src/blockchainClient/enums.d.ts +5 -0
- package/built/src/blockchainClient/enums.js +6 -0
- package/built/src/blockchainClient/enums.js.map +1 -1
- package/built/src/blockchainClient/errors.d.ts +20 -0
- package/built/src/blockchainClient/errors.js +41 -0
- package/built/src/blockchainClient/errors.js.map +1 -1
- package/built/src/{restclient → blockchainClient}/failoverStrategies.d.ts +14 -0
- package/built/src/{restclient → blockchainClient}/failoverStrategies.js +104 -24
- package/built/src/blockchainClient/failoverStrategies.js.map +1 -0
- package/built/src/blockchainClient/httpUtil.d.ts +4 -0
- package/built/src/{restclient → blockchainClient}/httpUtil.js +27 -23
- package/built/src/blockchainClient/httpUtil.js.map +1 -0
- package/built/src/blockchainClient/interface.d.ts +48 -59
- package/built/src/{restclient → blockchainClient}/nodeManager.d.ts +3 -0
- package/built/src/{restclient → blockchainClient}/nodeManager.js +7 -0
- package/built/src/blockchainClient/nodeManager.js.map +1 -0
- package/built/src/blockchainClient/requestWithFailoverStrategy.d.ts +4 -0
- package/built/src/blockchainClient/requestWithFailoverStrategy.js +31 -0
- package/built/src/blockchainClient/requestWithFailoverStrategy.js.map +1 -0
- package/built/src/blockchainClient/types.d.ts +64 -20
- package/built/src/blockchainClient/utils.d.ts +47 -12
- package/built/src/blockchainClient/utils.js +149 -30
- package/built/src/blockchainClient/utils.js.map +1 -1
- package/built/src/blockchainClient/validation/merkleHash.js +2 -1
- package/built/src/blockchainClient/validation/merkleHash.js.map +1 -1
- package/built/src/blockchainClient/validation/rawGtx.d.ts +2 -0
- package/built/src/blockchainClient/validation/rawGtx.js +22 -0
- package/built/src/blockchainClient/validation/rawGtx.js.map +1 -0
- package/built/src/blockchainClient/validation/requests.d.ts +5 -2
- package/built/src/blockchainClient/validation/requests.js +26 -0
- package/built/src/blockchainClient/validation/requests.js.map +1 -1
- package/built/src/blockchainClient/validation/transactionStatusReponse.d.ts +2 -0
- package/built/src/blockchainClient/validation/transactionStatusReponse.js +24 -0
- package/built/src/blockchainClient/validation/transactionStatusReponse.js.map +1 -0
- package/built/src/blockchainClient/validation/txRid.js +1 -1
- package/built/src/blockchainClient/validation/txRid.js.map +1 -1
- package/built/src/encryption/encryption.d.ts +0 -1
- package/built/src/encryption/encryption.js +0 -2
- package/built/src/encryption/encryption.js.map +1 -1
- package/built/src/formatter.d.ts +5 -7
- package/built/src/formatter.js +10 -29
- package/built/src/formatter.js.map +1 -1
- package/built/src/gtv/index.d.ts +3 -2
- package/built/src/gtv/index.js +4 -6
- package/built/src/gtv/index.js.map +1 -1
- package/built/src/gtx/errors.d.ts +2 -1
- package/built/src/gtx/errors.js.map +1 -1
- package/built/src/gtx/gtx.d.ts +5 -2
- package/built/src/gtx/gtx.js +0 -7
- package/built/src/gtx/gtx.js.map +1 -1
- package/built/src/gtx/serialization.d.ts +0 -1
- package/built/src/gtx/serialization.js +0 -1
- package/built/src/gtx/serialization.js.map +1 -1
- package/built/src/gtx/types.d.ts +0 -8
- package/built/src/logger.d.ts +6 -9
- package/built/src/logger.js +8 -14
- package/built/src/logger.js.map +1 -1
- package/built/src/promiEvent/promiEventEmitter.d.ts +1 -8
- package/built/src/promiEvent/promiEventEmitter.js.map +1 -1
- package/built/src/utils/calculateTransactionRid.d.ts +1 -1
- package/built/src/utils/calculateTransactionRid.js +6 -6
- package/built/src/utils/calculateTransactionRid.js.map +1 -1
- package/built/src/utils/constants.d.ts +4 -0
- package/built/src/utils/constants.js +5 -0
- package/built/src/utils/constants.js.map +1 -0
- package/built/src/utils/decodeTransactionToGtx.d.ts +1 -1
- package/built/src/utils/decodeTransactionToGtx.js +4 -3
- package/built/src/utils/decodeTransactionToGtx.js.map +1 -1
- package/built/src/utils/encodeTransaction.d.ts +1 -1
- package/built/src/utils/encodeTransaction.js +4 -4
- package/built/src/utils/encodeTransaction.js.map +1 -1
- package/built/test/common/mocks.d.ts +118 -0
- package/built/test/common/mocks.js +239 -0
- package/built/test/common/mocks.js.map +1 -0
- package/built/test/{unit/gtx → common}/serializationtestobjects.d.ts +1 -1
- package/built/test/common/serializationtestobjects.js.map +1 -0
- package/built/test/common/setups.d.ts +27 -0
- package/built/test/common/setups.js +137 -0
- package/built/test/common/setups.js.map +1 -0
- package/built/test/{unit → common}/signatures.d.ts +0 -1
- package/built/test/{unit → common}/signatures.js +0 -1
- package/built/test/common/signatures.js.map +1 -0
- package/built/test/common/testData.js.map +1 -0
- package/built/test/{unit/validation → common}/validationMocks.d.ts +22 -2
- package/built/test/{unit/validation → common}/validationMocks.js +13 -1
- package/built/test/common/validationMocks.js.map +1 -0
- package/built/test/integration/clientGetBlockInfo.test.js +51 -0
- package/built/test/integration/clientGetBlockInfo.test.js.map +1 -0
- package/built/test/integration/clientGetRejectedTransactions.test.js +28 -0
- package/built/test/integration/clientGetRejectedTransactions.test.js.map +1 -0
- package/built/test/integration/clientGetTransaction.test.js +29 -0
- package/built/test/integration/clientGetTransaction.test.js.map +1 -0
- package/built/test/integration/clientGetTransactionStatus.test.js +71 -0
- package/built/test/integration/clientGetTransactionStatus.test.js.map +1 -0
- package/built/test/integration/clientGetWaitingTransaction.test.js +34 -0
- package/built/test/integration/clientGetWaitingTransaction.test.js.map +1 -0
- package/built/test/integration/clientGetWaitingTransactions.test.js +28 -0
- package/built/test/integration/clientGetWaitingTransactions.test.js.map +1 -0
- package/built/test/integration/clientIntegration.test.js +95 -0
- package/built/test/integration/clientIntegration.test.js.map +1 -0
- package/built/test/integration/clientQuery.test.js +380 -0
- package/built/test/integration/clientQuery.test.js.map +1 -0
- package/built/test/integration/clientSendTransaction.test.js +86 -0
- package/built/test/integration/clientSendTransaction.test.js.map +1 -0
- package/built/test/integration/clientSignAndSendUniqueTransaction.test.js +75 -0
- package/built/test/integration/clientSignAndSendUniqueTransaction.test.js.map +1 -0
- package/built/test/integration/clientSignTransaction.test.js +77 -0
- package/built/test/integration/clientSignTransaction.test.js.map +1 -0
- package/built/test/integration/{blockchainClientUtils.test.js → clientUtils.test.js} +13 -8
- package/built/test/integration/clientUtils.test.js.map +1 -0
- package/built/test/integration/createClientIntegration.test.js +158 -0
- package/built/test/integration/createClientIntegration.test.js.map +1 -0
- package/built/test/integration/encodeTransaction.test.js +3 -6
- package/built/test/integration/encodeTransaction.test.js.map +1 -1
- package/built/test/integration/getTransactionsInfo.test.js +17 -26
- package/built/test/integration/getTransactionsInfo.test.js.map +1 -1
- package/built/test/integration/signAndSendUniqueTransaction.test.js +26 -19
- package/built/test/integration/signAndSendUniqueTransaction.test.js.map +1 -1
- package/built/test/integrationChromiaNetwork/createIccfProofTx.test.js +59 -0
- package/built/test/integrationChromiaNetwork/createIccfProofTx.test.js.map +1 -0
- package/built/test/{integrationDevnet → integrationChromiaNetwork}/getAnchoringStatusForBlockRid.test.js +9 -15
- package/built/test/integrationChromiaNetwork/getAnchoringStatusForBlockRid.test.js.map +1 -0
- package/built/test/{integrationDevnet → integrationChromiaNetwork}/getTransactionConfirmationLevel.test.js +7 -13
- package/built/test/integrationChromiaNetwork/getTransactionConfirmationLevel.test.js.map +1 -0
- package/built/test/integrationChromiaNetwork/getTransactionStatus.test.js +45 -0
- package/built/test/integrationChromiaNetwork/getTransactionStatus.test.js.map +1 -0
- package/built/test/integrationChromiaNetwork/isBlockAnchored.test.js +35 -0
- package/built/test/integrationChromiaNetwork/isBlockAnchored.test.js.map +1 -0
- package/built/test/integrationChromiaNetwork/merkleHashIntegration.test.d.ts +1 -0
- package/built/test/integrationChromiaNetwork/merkleHashIntegration.test.js +134 -0
- package/built/test/integrationChromiaNetwork/merkleHashIntegration.test.js.map +1 -0
- package/built/test/integrationChromiaNetwork/nodeDiscovery.test.d.ts +1 -0
- package/built/test/integrationChromiaNetwork/nodeDiscovery.test.js +26 -0
- package/built/test/integrationChromiaNetwork/nodeDiscovery.test.js.map +1 -0
- package/built/test/integrationChromiaNetwork/requestWithFailoverStrategy.test.d.ts +1 -0
- package/built/test/integrationChromiaNetwork/requestWithFailoverStrategy.test.js +84 -0
- package/built/test/integrationChromiaNetwork/requestWithFailoverStrategy.test.js.map +1 -0
- package/built/test/integrationChromiaNetwork/signAndSendUniqueTransaction.test.d.ts +1 -0
- package/built/test/{integrationDevnet → integrationChromiaNetwork}/signAndSendUniqueTransaction.test.js +27 -44
- package/built/test/integrationChromiaNetwork/signAndSendUniqueTransaction.test.js.map +1 -0
- package/built/test/manual/iccfManually.test.js +18 -27
- package/built/test/manual/iccfManually.test.js.map +1 -1
- package/built/test/pcctf/getSuites.test.d.ts +1 -0
- package/built/test/pcctf/getSuites.test.js +106 -0
- package/built/test/pcctf/getSuites.test.js.map +1 -0
- package/built/test/pcctf/helpers.d.ts +92 -0
- package/built/test/pcctf/helpers.js +239 -0
- package/built/test/pcctf/helpers.js.map +1 -0
- package/built/test/unit/ICCF/iccf.test.js +63 -158
- package/built/test/unit/ICCF/iccf.test.js.map +1 -1
- package/built/test/unit/ICCF/iccfProofMaterialBuilder.test.d.ts +1 -2
- package/built/test/unit/ICCF/iccfProofMaterialBuilder.test.js +101 -296
- package/built/test/unit/ICCF/iccfProofMaterialBuilder.test.js.map +1 -1
- package/built/test/unit/blockchainClient/client.getRejectedTransactions.test.d.ts +1 -0
- package/built/test/unit/blockchainClient/client.getRejectedTransactions.test.js +48 -0
- package/built/test/unit/blockchainClient/client.getRejectedTransactions.test.js.map +1 -0
- package/built/test/unit/blockchainClient/client.getWaitingTransaction.test.d.ts +1 -0
- package/built/test/unit/blockchainClient/client.getWaitingTransaction.test.js +38 -0
- package/built/test/unit/blockchainClient/client.getWaitingTransaction.test.js.map +1 -0
- package/built/test/unit/blockchainClient/client.getWaitingTransactions.test.d.ts +1 -0
- package/built/test/unit/blockchainClient/client.getWaitingTransactions.test.js +30 -0
- package/built/test/unit/blockchainClient/client.getWaitingTransactions.test.js.map +1 -0
- package/built/test/unit/blockchainClient/client.test.d.ts +1 -0
- package/built/test/unit/blockchainClient/client.test.js +177 -0
- package/built/test/unit/blockchainClient/client.test.js.map +1 -0
- package/built/test/unit/blockchainClient/clientCustomStatusCodes.test.js +26 -32
- package/built/test/unit/blockchainClient/clientCustomStatusCodes.test.js.map +1 -1
- package/built/test/unit/blockchainClient/getAnchoringStatusForBlockRid.test.js +26 -59
- package/built/test/unit/blockchainClient/getAnchoringStatusForBlockRid.test.js.map +1 -1
- package/built/test/unit/blockchainClient/getSystemAnchoringTransactionConfirmation.test.js +21 -38
- package/built/test/unit/blockchainClient/getSystemAnchoringTransactionConfirmation.test.js.map +1 -1
- package/built/test/unit/blockchainClient/getTransactionConfirmationLevel.test.js +77 -127
- package/built/test/unit/blockchainClient/getTransactionConfirmationLevel.test.js.map +1 -1
- package/built/test/unit/blockchainClient/sendTransaction.test.js +352 -675
- package/built/test/unit/blockchainClient/sendTransaction.test.js.map +1 -1
- package/built/test/unit/blockchainClient/setMerkleVersion.test.js +14 -28
- package/built/test/unit/blockchainClient/setMerkleVersion.test.js.map +1 -1
- package/built/test/unit/blockchainClient/signAndSendUniqueTransactionPromiEvents.test.js +31 -98
- package/built/test/unit/blockchainClient/signAndSendUniqueTransactionPromiEvents.test.js.map +1 -1
- package/built/test/unit/blockchainClient/statusPollIntervals.test.js +34 -54
- package/built/test/unit/blockchainClient/statusPollIntervals.test.js.map +1 -1
- package/built/test/unit/blockchainClient/util.test.js +74 -133
- package/built/test/unit/blockchainClient/util.test.js.map +1 -1
- package/built/test/unit/decodeTransactionToGtx.test.js +3 -4
- package/built/test/unit/decodeTransactionToGtx.test.js.map +1 -1
- package/built/test/unit/dump.test.js +2 -3
- package/built/test/unit/dump.test.js.map +1 -1
- package/built/test/unit/encryption/encryption.test.js +23 -32
- package/built/test/unit/encryption/encryption.test.js.map +1 -1
- package/built/test/unit/failoverStrategies.test.js +122 -114
- package/built/test/unit/failoverStrategies.test.js.map +1 -1
- package/built/test/unit/formatter.test.js +38 -42
- package/built/test/unit/formatter.test.js.map +1 -1
- package/built/test/unit/gtv/gtvHash.test.js +5 -6
- package/built/test/unit/gtv/gtvHash.test.js.map +1 -1
- package/built/test/unit/gtx/checkGTXSignature.test.js +5 -7
- package/built/test/unit/gtx/checkGTXSignature.test.js.map +1 -1
- package/built/test/unit/gtx/newSignatureProvider.test.js +9 -10
- package/built/test/unit/gtx/newSignatureProvider.test.js.map +1 -1
- package/built/test/unit/gtx/serialization.test.js +37 -138
- package/built/test/unit/gtx/serialization.test.js.map +1 -1
- package/built/test/unit/httpUtil.test.js +27 -18
- package/built/test/unit/httpUtil.test.js.map +1 -1
- package/built/test/unit/logger.test.js +23 -25
- package/built/test/unit/logger.test.js.map +1 -1
- package/built/test/unit/nodeMananger.test.js +62 -74
- package/built/test/unit/nodeMananger.test.js.map +1 -1
- package/built/test/unit/setOrdering.test.js +9 -9
- package/built/test/unit/setOrdering.test.js.map +1 -1
- package/built/test/unit/stickyNode.test.js +44 -54
- package/built/test/unit/stickyNode.test.js.map +1 -1
- package/built/test/unit/validation/anchoringTransaction.test.js +7 -8
- package/built/test/unit/validation/anchoringTransaction.test.js.map +1 -1
- package/built/test/unit/validation/blockIdentifier.test.js +7 -9
- package/built/test/unit/validation/blockIdentifier.test.js.map +1 -1
- package/built/test/unit/validation/bufferSchema.test.js +4 -5
- package/built/test/unit/validation/bufferSchema.test.js.map +1 -1
- package/built/test/unit/validation/networkSettings.test.js +11 -13
- package/built/test/unit/validation/networkSettings.test.js.map +1 -1
- package/built/test/unit/validation/rawGtx.test.d.ts +1 -0
- package/built/test/unit/validation/rawGtx.test.js +84 -0
- package/built/test/unit/validation/rawGtx.test.js.map +1 -0
- package/built/test/unit/validation/requests.test.js +80 -74
- package/built/test/unit/validation/requests.test.js.map +1 -1
- package/built/test/unit/validation/signMethod.test.js +8 -10
- package/built/test/unit/validation/signMethod.test.js.map +1 -1
- package/built/test/unit/validation/statusObject.test.d.ts +1 -0
- package/built/test/unit/validation/statusObject.test.js +91 -0
- package/built/test/unit/validation/statusObject.test.js.map +1 -0
- package/built/test/unit/validation/txRid.test.js +7 -9
- package/built/test/unit/validation/txRid.test.js.map +1 -1
- package/built/umd/index.js +31711 -31107
- package/built/umd/index.js.map +1 -1
- package/package.json +26 -22
- package/built/src/chromia/chromiaClientProvider.d.ts +0 -9
- package/built/src/chromia/chromiaClientProvider.js +0 -36
- package/built/src/chromia/chromiaClientProvider.js.map +0 -1
- package/built/src/chromia/interfaces.d.ts +0 -4
- package/built/src/chromia/interfaces.js +0 -2
- package/built/src/chromia/interfaces.js.map +0 -1
- package/built/src/constants.d.ts +0 -3
- package/built/src/constants.js +0 -4
- package/built/src/constants.js.map +0 -1
- package/built/src/gtx/gtxclient.d.ts +0 -3
- package/built/src/gtx/gtxclient.js +0 -96
- package/built/src/gtx/gtxclient.js.map +0 -1
- package/built/src/gtx/interfaces.d.ts +0 -91
- package/built/src/gtx/interfaces.js +0 -2
- package/built/src/gtx/interfaces.js.map +0 -1
- package/built/src/merkle/binarytree.d.ts +0 -131
- package/built/src/merkle/binarytree.js +0 -146
- package/built/src/merkle/binarytree.js.map +0 -1
- package/built/src/merkle/binarytreefactory.d.ts +0 -86
- package/built/src/merkle/binarytreefactory.js +0 -251
- package/built/src/merkle/binarytreefactory.js.map +0 -1
- package/built/src/merkle/merkleHelper.d.ts +0 -18
- package/built/src/merkle/merkleHelper.js +0 -110
- package/built/src/merkle/merkleHelper.js.map +0 -1
- package/built/src/merkle/merklehashcalculator.d.ts +0 -37
- package/built/src/merkle/merklehashcalculator.js +0 -73
- package/built/src/merkle/merklehashcalculator.js.map +0 -1
- package/built/src/merkle/path.d.ts +0 -151
- package/built/src/merkle/path.js +0 -306
- package/built/src/merkle/path.js.map +0 -1
- package/built/src/merkle/proof/merklehashcarrier.d.ts +0 -17
- package/built/src/merkle/proof/merklehashcarrier.js +0 -23
- package/built/src/merkle/proof/merklehashcarrier.js.map +0 -1
- package/built/src/merkle/proof/merklehashsummaryfactory.d.ts +0 -53
- package/built/src/merkle/proof/merklehashsummaryfactory.js +0 -82
- package/built/src/merkle/proof/merklehashsummaryfactory.js.map +0 -1
- package/built/src/merkle/proof/merkleproof.d.ts +0 -36
- package/built/src/merkle/proof/merkleproof.js +0 -61
- package/built/src/merkle/proof/merkleproof.js.map +0 -1
- package/built/src/merkle/proof/merkleprooftree.d.ts +0 -124
- package/built/src/merkle/proof/merkleprooftree.js +0 -117
- package/built/src/merkle/proof/merkleprooftree.js.map +0 -1
- package/built/src/merkle/proof/merkleprooftreefactory.d.ts +0 -47
- package/built/src/merkle/proof/merkleprooftreefactory.js +0 -123
- package/built/src/merkle/proof/merkleprooftreefactory.js.map +0 -1
- package/built/src/merkle/types.d.ts +0 -11
- package/built/src/merkle/types.js +0 -2
- package/built/src/merkle/types.js.map +0 -1
- package/built/src/restclient/enums.d.ts +0 -4
- package/built/src/restclient/enums.js +0 -6
- package/built/src/restclient/enums.js.map +0 -1
- package/built/src/restclient/errors.d.ts +0 -33
- package/built/src/restclient/errors.js +0 -63
- package/built/src/restclient/errors.js.map +0 -1
- package/built/src/restclient/failoverStrategies.js.map +0 -1
- package/built/src/restclient/httpUtil.d.ts +0 -6
- package/built/src/restclient/httpUtil.js.map +0 -1
- package/built/src/restclient/interfaces.d.ts +0 -68
- package/built/src/restclient/interfaces.js +0 -2
- package/built/src/restclient/interfaces.js.map +0 -1
- package/built/src/restclient/nodeManager.js.map +0 -1
- package/built/src/restclient/restclient.d.ts +0 -18
- package/built/src/restclient/restclient.js +0 -200
- package/built/src/restclient/restclient.js.map +0 -1
- package/built/src/restclient/restclientutil.d.ts +0 -32
- package/built/src/restclient/restclientutil.js +0 -141
- package/built/src/restclient/restclientutil.js.map +0 -1
- package/built/src/restclient/types.d.ts +0 -78
- package/built/src/restclient/types.js +0 -2
- package/built/src/restclient/types.js.map +0 -1
- package/built/test/integration/blockchainClientIntegration.test.js +0 -1075
- package/built/test/integration/blockchainClientIntegration.test.js.map +0 -1
- package/built/test/integration/blockchainClientUtils.test.js.map +0 -1
- package/built/test/integration/gtxClientIntegration.test.js +0 -334
- package/built/test/integration/gtxClientIntegration.test.js.map +0 -1
- package/built/test/integration/merkleIntegration.test.js +0 -138
- package/built/test/integration/merkleIntegration.test.js.map +0 -1
- package/built/test/integration/objectGenerator.d.ts +0 -3
- package/built/test/integration/objectGenerator.js +0 -17
- package/built/test/integration/objectGenerator.js.map +0 -1
- package/built/test/integration/restClientIntegration.test.js +0 -170
- package/built/test/integration/restClientIntegration.test.js.map +0 -1
- package/built/test/integration/testData.js.map +0 -1
- package/built/test/integrationDevnet/constants.d.ts +0 -1
- package/built/test/integrationDevnet/constants.js +0 -2
- package/built/test/integrationDevnet/constants.js.map +0 -1
- package/built/test/integrationDevnet/getAnchoringStatusForBlockRid.test.js.map +0 -1
- package/built/test/integrationDevnet/getTransactionConfirmationLevel.test.js.map +0 -1
- package/built/test/integrationDevnet/getTransactionStatus.test.js +0 -53
- package/built/test/integrationDevnet/getTransactionStatus.test.js.map +0 -1
- package/built/test/integrationDevnet/signAndSendUniqueTransaction.test.js.map +0 -1
- package/built/test/manual/chromiaClientProviderManually.test.js +0 -28
- package/built/test/manual/chromiaClientProviderManually.test.js.map +0 -1
- package/built/test/manual/restClientManually.test.js +0 -52
- package/built/test/manual/restClientManually.test.js.map +0 -1
- package/built/test/unit/ICCF/util.d.ts +0 -6
- package/built/test/unit/ICCF/util.js +0 -21
- package/built/test/unit/ICCF/util.js.map +0 -1
- package/built/test/unit/blockchainClient/blockchainClient.test.js +0 -287
- package/built/test/unit/blockchainClient/blockchainClient.test.js.map +0 -1
- package/built/test/unit/blockchainClient/helpers/sendTransaction.d.ts +0 -25
- package/built/test/unit/blockchainClient/helpers/sendTransaction.js +0 -56
- package/built/test/unit/blockchainClient/helpers/sendTransaction.js.map +0 -1
- package/built/test/unit/chromiaClientProvider.test.js +0 -70
- package/built/test/unit/chromiaClientProvider.test.js.map +0 -1
- package/built/test/unit/common/mocks.d.ts +0 -34
- package/built/test/unit/common/mocks.js +0 -69
- package/built/test/unit/common/mocks.js.map +0 -1
- package/built/test/unit/gtx/gtxClient.test.js +0 -97
- package/built/test/unit/gtx/gtxClient.test.js.map +0 -1
- package/built/test/unit/gtx/serializationtestobjects.js.map +0 -1
- package/built/test/unit/merkle/merkleHelper/merkleHelperTest.js +0 -87
- package/built/test/unit/merkle/merkleHelper/merkleHelperTest.js.map +0 -1
- package/built/test/unit/requestWithFailoverStrategy.test.js +0 -146
- package/built/test/unit/requestWithFailoverStrategy.test.js.map +0 -1
- package/built/test/unit/restClient.test.js +0 -389
- package/built/test/unit/restClient.test.js.map +0 -1
- package/built/test/unit/restClientUtil.test.js +0 -226
- package/built/test/unit/restClientUtil.test.js.map +0 -1
- package/built/test/unit/signatures.js.map +0 -1
- package/built/test/unit/validation/validationMocks.js.map +0 -1
- package/changelog.md +0 -586
- /package/built/test/{unit/gtx → common}/serializationtestobjects.js +0 -0
- /package/built/test/{integration → common}/testData.d.ts +0 -0
- /package/built/test/{integration → common}/testData.js +0 -0
- /package/built/test/integration/{blockchainClientIntegration.test.d.ts → clientGetBlockInfo.test.d.ts} +0 -0
- /package/built/test/integration/{blockchainClientUtils.test.d.ts → clientGetRejectedTransactions.test.d.ts} +0 -0
- /package/built/test/integration/{gtxClientIntegration.test.d.ts → clientGetTransaction.test.d.ts} +0 -0
- /package/built/test/integration/{merkleIntegration.test.d.ts → clientGetTransactionStatus.test.d.ts} +0 -0
- /package/built/test/integration/{restClientIntegration.test.d.ts → clientGetWaitingTransaction.test.d.ts} +0 -0
- /package/built/test/{integrationDevnet/getAnchoringStatusForBlockRid.test.d.ts → integration/clientGetWaitingTransactions.test.d.ts} +0 -0
- /package/built/test/{integrationDevnet/getTransactionConfirmationLevel.test.d.ts → integration/clientIntegration.test.d.ts} +0 -0
- /package/built/test/{integrationDevnet/getTransactionStatus.test.d.ts → integration/clientQuery.test.d.ts} +0 -0
- /package/built/test/{integrationDevnet/signAndSendUniqueTransaction.test.d.ts → integration/clientSendTransaction.test.d.ts} +0 -0
- /package/built/test/{manual/chromiaClientProviderManually.test.d.ts → integration/clientSignAndSendUniqueTransaction.test.d.ts} +0 -0
- /package/built/test/{manual/restClientManually.test.d.ts → integration/clientSignTransaction.test.d.ts} +0 -0
- /package/built/test/{unit/blockchainClient/blockchainClient.test.d.ts → integration/clientUtils.test.d.ts} +0 -0
- /package/built/test/{unit/chromiaClientProvider.test.d.ts → integration/createClientIntegration.test.d.ts} +0 -0
- /package/built/test/{unit/gtx/gtxClient.test.d.ts → integrationChromiaNetwork/createIccfProofTx.test.d.ts} +0 -0
- /package/built/test/{unit/merkle/merkleHelper/merkleHelperTest.d.ts → integrationChromiaNetwork/getAnchoringStatusForBlockRid.test.d.ts} +0 -0
- /package/built/test/{unit/requestWithFailoverStrategy.test.d.ts → integrationChromiaNetwork/getTransactionConfirmationLevel.test.d.ts} +0 -0
- /package/built/test/{unit/restClient.test.d.ts → integrationChromiaNetwork/getTransactionStatus.test.d.ts} +0 -0
- /package/built/test/{unit/restClientUtil.test.d.ts → integrationChromiaNetwork/isBlockAnchored.test.d.ts} +0 -0
|
@@ -1,1075 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
|
-
import chai from "chai";
|
|
22
|
-
import chaiAsPromised from "chai-as-promised";
|
|
23
|
-
import * as secp256k1 from "secp256k1";
|
|
24
|
-
import { randomInt } from "crypto";
|
|
25
|
-
import * as sinon from "sinon";
|
|
26
|
-
import { Buffer } from "buffer";
|
|
27
|
-
import { createClient } from "../../src/blockchainClient/blockchainClient";
|
|
28
|
-
import { signDigest } from "../../src/encryption/encryption";
|
|
29
|
-
import { getDigestToSign } from "../../src/gtx/gtx";
|
|
30
|
-
import * as gtxTool from "../../src/gtx/gtx";
|
|
31
|
-
import * as handleRequestModule from "../../src/restclient/httpUtil";
|
|
32
|
-
import { ComplexArgumentObject } from "./testData";
|
|
33
|
-
import { toBuffer } from "../../src/formatter";
|
|
34
|
-
import { MissingBlockchainIdentifierError } from "../../src/blockchainClient/errors";
|
|
35
|
-
import { ChainConfirmationLevel, ResponseStatus, TransactionEvent, } from "../../src/blockchainClient/enums";
|
|
36
|
-
import { CONFIGURED_POLL_COUNT, mockStringDirectoryChainRid, mockThirtyTwoBytesBuffer, } from "../unit/common/mocks";
|
|
37
|
-
import { setStatusPolling } from "../../src/blockchainClient/utils";
|
|
38
|
-
import { LOCAL_POOL } from "../../src/constants";
|
|
39
|
-
const expect = chai.expect;
|
|
40
|
-
chai.use(chaiAsPromised);
|
|
41
|
-
const invalidEndpointPool = [
|
|
42
|
-
"http://localhost1:7740",
|
|
43
|
-
"http://localhost2:7740",
|
|
44
|
-
"http://localhost3:7740",
|
|
45
|
-
];
|
|
46
|
-
const signerPrivKeyA = Buffer.alloc(32, "a");
|
|
47
|
-
const signerPubKeyA = Buffer.from(secp256k1.publicKeyCreate(signerPrivKeyA));
|
|
48
|
-
const signerKeyPairA = {
|
|
49
|
-
privKey: signerPrivKeyA,
|
|
50
|
-
pubKey: signerPubKeyA,
|
|
51
|
-
};
|
|
52
|
-
const sigProvA = {
|
|
53
|
-
pubKey: signerPubKeyA,
|
|
54
|
-
sign: (rawGtxBody) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
const digest = gtxTool.getDigestToSignFromRawGtxBody(rawGtxBody, 1);
|
|
56
|
-
return signDigest(digest, signerPrivKeyA);
|
|
57
|
-
}),
|
|
58
|
-
};
|
|
59
|
-
const signerPrivKeyB = Buffer.alloc(32, "b");
|
|
60
|
-
const signerPubKeyB = Buffer.from(secp256k1.publicKeyCreate(signerPrivKeyB));
|
|
61
|
-
const signerKeyPairB = {
|
|
62
|
-
privKey: signerPrivKeyB,
|
|
63
|
-
pubKey: signerPubKeyB,
|
|
64
|
-
};
|
|
65
|
-
const unsignedNonUniqueTx = {
|
|
66
|
-
operations: [
|
|
67
|
-
{
|
|
68
|
-
name: "setInteger",
|
|
69
|
-
args: [1],
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
signers: [signerPubKeyA],
|
|
73
|
-
};
|
|
74
|
-
const unsignedNonUniqueTxWithTwoSigners = {
|
|
75
|
-
operations: [
|
|
76
|
-
{
|
|
77
|
-
name: "setInteger",
|
|
78
|
-
args: [1],
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
signers: [signerPubKeyA, signerPubKeyB],
|
|
82
|
-
};
|
|
83
|
-
const signedNonUniqueTxHex = "a581bb3081b8a56e306ca1220420bfb34abea1045bb97ed18a5dbb2b8dce84cb181585d55abb3" +
|
|
84
|
-
"21a33133dba0595a51d301ba5193017a20c0c0a736574496e7465676572a5073005a303020101" +
|
|
85
|
-
"a5273025a123042102e5a018b3a2e155316109d9cdc5eab739759c0e07e0c00bf9fccb8237fe4" +
|
|
86
|
-
"d7f02a5463044a1420440eb6c468bc2693a218a71e7b50465ba08343780d0829ec0132337cf8b" +
|
|
87
|
-
"293d841e09ac203ef0200ac7641a359a98ba1b37baace48fd96c21f7870e197f3246de0b";
|
|
88
|
-
const unsignedTx = {
|
|
89
|
-
operations: [
|
|
90
|
-
{
|
|
91
|
-
name: "setInteger",
|
|
92
|
-
args: [randomInt(99999)],
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
signers: [signerPubKeyA],
|
|
96
|
-
};
|
|
97
|
-
const getTxWithGTXAndTxRID = (client, signers = []) => {
|
|
98
|
-
const operation = {
|
|
99
|
-
name: "setInteger",
|
|
100
|
-
args: [randomInt(99999)],
|
|
101
|
-
};
|
|
102
|
-
const gtxBody = {
|
|
103
|
-
blockchainRid: toBuffer(client.config.blockchainRid),
|
|
104
|
-
operations: [
|
|
105
|
-
{
|
|
106
|
-
opName: operation.name,
|
|
107
|
-
args: operation.args,
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
signers,
|
|
111
|
-
};
|
|
112
|
-
const gtx = Object.assign(Object.assign({}, gtxBody), { signatures: [] });
|
|
113
|
-
const tx = {
|
|
114
|
-
operations: [operation],
|
|
115
|
-
signers,
|
|
116
|
-
};
|
|
117
|
-
const txRID = getDigestToSign(gtx, 2);
|
|
118
|
-
return { operation, gtx, txRID, tx };
|
|
119
|
-
};
|
|
120
|
-
describe("Blockchain client", () => {
|
|
121
|
-
let client;
|
|
122
|
-
let faultyClient;
|
|
123
|
-
let stableConfigClient;
|
|
124
|
-
let handleRequestSpy;
|
|
125
|
-
before(done => {
|
|
126
|
-
faultyClient = createClient({
|
|
127
|
-
nodeUrlPool: invalidEndpointPool,
|
|
128
|
-
blockchainRid: process.env.BLOCKCHAIN_RID,
|
|
129
|
-
failOverConfig: {
|
|
130
|
-
attemptInterval: 1,
|
|
131
|
-
},
|
|
132
|
-
directoryChainRid: mockStringDirectoryChainRid,
|
|
133
|
-
merkleHashVersion: 1,
|
|
134
|
-
});
|
|
135
|
-
stableConfigClient = createClient({
|
|
136
|
-
nodeUrlPool: LOCAL_POOL,
|
|
137
|
-
blockchainRid: "BFB34ABEA1045BB97ED18A5DBB2B8DCE84CB181585D55ABB321A33133DBA0595",
|
|
138
|
-
merkleHashVersion: 1,
|
|
139
|
-
});
|
|
140
|
-
client = createClient({
|
|
141
|
-
nodeUrlPool: LOCAL_POOL,
|
|
142
|
-
blockchainIid: 0,
|
|
143
|
-
merkleHashVersion: 1,
|
|
144
|
-
}).finally(() => {
|
|
145
|
-
done();
|
|
146
|
-
});
|
|
147
|
-
handleRequestSpy = sinon.spy(handleRequestModule, "default");
|
|
148
|
-
});
|
|
149
|
-
beforeEach(() => {
|
|
150
|
-
handleRequestSpy.resetHistory();
|
|
151
|
-
});
|
|
152
|
-
after(() => {
|
|
153
|
-
handleRequestSpy.restore();
|
|
154
|
-
});
|
|
155
|
-
// TODO: Clean up after tests? E.g. wipe database?
|
|
156
|
-
describe("Init client", () => {
|
|
157
|
-
it("inits client", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
158
|
-
const client = yield createClient({
|
|
159
|
-
nodeUrlPool: "https://localhost:7740",
|
|
160
|
-
blockchainRid: process.env.BLOCKCHAIN_RID,
|
|
161
|
-
directoryChainRid: mockStringDirectoryChainRid,
|
|
162
|
-
merkleHashVersion: 1,
|
|
163
|
-
});
|
|
164
|
-
const _a = client.config, { nodeManager } = _a, restClientConfig = __rest(_a, ["nodeManager"]);
|
|
165
|
-
expect(restClientConfig).to.deep.equal({
|
|
166
|
-
endpointPool: [{ url: "https://localhost:7740", whenAvailable: 0 }],
|
|
167
|
-
blockchainRid: process.env.BLOCKCHAIN_RID,
|
|
168
|
-
failoverStrategy: "abortOnError",
|
|
169
|
-
merkleHashVersion: 1,
|
|
170
|
-
attemptsPerEndpoint: 3,
|
|
171
|
-
attemptInterval: 500,
|
|
172
|
-
unreachableDuration: 30000,
|
|
173
|
-
directoryChainRid: mockStringDirectoryChainRid,
|
|
174
|
-
dappStatusPolling: {
|
|
175
|
-
interval: 500,
|
|
176
|
-
count: 20,
|
|
177
|
-
},
|
|
178
|
-
clusterAnchoringStatusPolling: {
|
|
179
|
-
interval: 500,
|
|
180
|
-
count: 20,
|
|
181
|
-
},
|
|
182
|
-
systemAnchoringStatusPolling: {
|
|
183
|
-
interval: 500,
|
|
184
|
-
count: 20,
|
|
185
|
-
},
|
|
186
|
-
});
|
|
187
|
-
expect(nodeManager).to.have.property("nodes");
|
|
188
|
-
expect(nodeManager).to.have.property("getAvailableNodes");
|
|
189
|
-
expect(nodeManager).to.have.property("getNode");
|
|
190
|
-
expect(nodeManager).to.have.property("setStickyNode");
|
|
191
|
-
expect(nodeManager).to.have.property("makeNodeUnavailable");
|
|
192
|
-
expect(nodeManager.stickedNode).to.be.null;
|
|
193
|
-
expect(nodeManager.nodes).to.have.deep.members([
|
|
194
|
-
{
|
|
195
|
-
url: "https://localhost:7740",
|
|
196
|
-
whenAvailable: 0,
|
|
197
|
-
isAvailable: true,
|
|
198
|
-
},
|
|
199
|
-
]);
|
|
200
|
-
}));
|
|
201
|
-
it("fails to init client if no blockchainRID or blockchainIID is provided", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
202
|
-
const promise = createClient({
|
|
203
|
-
nodeUrlPool: "localhost:7740",
|
|
204
|
-
});
|
|
205
|
-
yield expect(promise).to.be.rejectedWith(new MissingBlockchainIdentifierError().message);
|
|
206
|
-
}));
|
|
207
|
-
it("fails to init client if no nodeUrlPool or directoryNodeUrlPool was provided", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
208
|
-
const promise = createClient({});
|
|
209
|
-
yield expect(promise).to.be.rejectedWith(new MissingBlockchainIdentifierError().message);
|
|
210
|
-
}));
|
|
211
|
-
it.skip("inits client with node discovery");
|
|
212
|
-
it("inits client with Blockchain IID", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
213
|
-
const client = yield createClient({
|
|
214
|
-
nodeUrlPool: [LOCAL_POOL],
|
|
215
|
-
blockchainIid: 0,
|
|
216
|
-
directoryChainRid: mockStringDirectoryChainRid,
|
|
217
|
-
});
|
|
218
|
-
const _b = client.config, { nodeManager } = _b, restClientConfig = __rest(_b, ["nodeManager"]);
|
|
219
|
-
expect(restClientConfig).to.deep.equal({
|
|
220
|
-
endpointPool: [{ url: LOCAL_POOL, whenAvailable: 0 }],
|
|
221
|
-
blockchainRid: process.env.BLOCKCHAIN_RID,
|
|
222
|
-
failoverStrategy: "abortOnError",
|
|
223
|
-
merkleHashVersion: 1,
|
|
224
|
-
attemptsPerEndpoint: 3,
|
|
225
|
-
attemptInterval: 500,
|
|
226
|
-
unreachableDuration: 30000,
|
|
227
|
-
directoryChainRid: mockStringDirectoryChainRid,
|
|
228
|
-
dappStatusPolling: {
|
|
229
|
-
interval: 500,
|
|
230
|
-
count: 20,
|
|
231
|
-
},
|
|
232
|
-
clusterAnchoringStatusPolling: {
|
|
233
|
-
interval: 500,
|
|
234
|
-
count: 20,
|
|
235
|
-
},
|
|
236
|
-
systemAnchoringStatusPolling: {
|
|
237
|
-
interval: 500,
|
|
238
|
-
count: 20,
|
|
239
|
-
},
|
|
240
|
-
});
|
|
241
|
-
expect(nodeManager).to.have.property("nodes");
|
|
242
|
-
expect(nodeManager).to.have.property("getAvailableNodes");
|
|
243
|
-
expect(nodeManager).to.have.property("getNode");
|
|
244
|
-
expect(nodeManager).to.have.property("setStickyNode");
|
|
245
|
-
expect(nodeManager).to.have.property("makeNodeUnavailable");
|
|
246
|
-
expect(nodeManager.stickedNode).to.deep.equal({
|
|
247
|
-
url: LOCAL_POOL,
|
|
248
|
-
whenAvailable: 0,
|
|
249
|
-
isAvailable: true,
|
|
250
|
-
});
|
|
251
|
-
expect(nodeManager.nodes).to.have.deep.members([
|
|
252
|
-
{
|
|
253
|
-
url: LOCAL_POOL,
|
|
254
|
-
whenAvailable: 0,
|
|
255
|
-
isAvailable: true,
|
|
256
|
-
},
|
|
257
|
-
]);
|
|
258
|
-
}));
|
|
259
|
-
});
|
|
260
|
-
describe("query", () => {
|
|
261
|
-
it("returns a value", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
262
|
-
const result = yield (yield client).query("test_boolean", {
|
|
263
|
-
arg1: true,
|
|
264
|
-
});
|
|
265
|
-
expect(result).to.equal(1);
|
|
266
|
-
}));
|
|
267
|
-
it("takes a query object as argument", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
268
|
-
const result = yield (yield client).query({
|
|
269
|
-
name: "test_boolean",
|
|
270
|
-
args: {
|
|
271
|
-
arg1: true,
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
expect(result).to.equal(1);
|
|
275
|
-
}));
|
|
276
|
-
it("works with large complex object as argument", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
277
|
-
const result = yield (yield client).query({
|
|
278
|
-
name: "test_complex_object",
|
|
279
|
-
args: ComplexArgumentObject,
|
|
280
|
-
});
|
|
281
|
-
expect(result).to.equal("");
|
|
282
|
-
}));
|
|
283
|
-
it("takes a query object without arguments as argument", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
284
|
-
const result = yield (yield client).query({ name: "test_without_args" });
|
|
285
|
-
expect(result).to.equal(1);
|
|
286
|
-
}));
|
|
287
|
-
it("returns a promise", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
288
|
-
const promise = (yield client).query("test_boolean", {
|
|
289
|
-
arg1: true,
|
|
290
|
-
});
|
|
291
|
-
expect(promise.then).to.be.a("function");
|
|
292
|
-
}));
|
|
293
|
-
// TODO: Results in a timeout error if expect statements fails. Fix this.
|
|
294
|
-
it("takes a callback", done => {
|
|
295
|
-
client.then(_client => {
|
|
296
|
-
_client.query("test_boolean", {
|
|
297
|
-
arg1: true,
|
|
298
|
-
}, (err, result) => {
|
|
299
|
-
expect(result).to.equal(1);
|
|
300
|
-
done();
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
// TODO: Results in a timeout error if expect statements fails. Fix this.
|
|
305
|
-
it("takes a callback when using query object as argument", done => {
|
|
306
|
-
client.then(_client => {
|
|
307
|
-
_client.query({
|
|
308
|
-
name: "test_boolean",
|
|
309
|
-
args: {
|
|
310
|
-
arg1: true,
|
|
311
|
-
},
|
|
312
|
-
}, undefined, (err, result) => {
|
|
313
|
-
expect(result).to.equal(1);
|
|
314
|
-
done();
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
// Attempt at testing typescript generics. Will make the test suite fail
|
|
319
|
-
// if the query function doesn't take these generics
|
|
320
|
-
it("takes a typed argument", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
321
|
-
const _client = yield client;
|
|
322
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
323
|
-
const result = yield _client.query("test_boolean", {
|
|
324
|
-
arg1: true,
|
|
325
|
-
});
|
|
326
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
327
|
-
const resultQueryObject = yield _client.query({
|
|
328
|
-
name: "test_boolean",
|
|
329
|
-
args: {
|
|
330
|
-
arg1: true,
|
|
331
|
-
},
|
|
332
|
-
});
|
|
333
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
334
|
-
const resultNoArgs = yield _client.query("test_without_args");
|
|
335
|
-
_client.query("test_boolean", {
|
|
336
|
-
arg1: true,
|
|
337
|
-
}, (err, response) => {
|
|
338
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
339
|
-
const numberResponse = response;
|
|
340
|
-
});
|
|
341
|
-
}));
|
|
342
|
-
it("takes a nullable argument", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
343
|
-
const nullableStructQueryObject = {
|
|
344
|
-
name: "test_nullable_struct",
|
|
345
|
-
args: {
|
|
346
|
-
arg1: [null],
|
|
347
|
-
},
|
|
348
|
-
};
|
|
349
|
-
const result = yield (yield client).query(nullableStructQueryObject);
|
|
350
|
-
expect(result).to.deep.equal({ int: null });
|
|
351
|
-
}));
|
|
352
|
-
it("rejects promise on error", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
353
|
-
const promise = (yield client).query("does_not_exist");
|
|
354
|
-
yield expect(promise).to.be.rejected;
|
|
355
|
-
}));
|
|
356
|
-
// TODO: Results in a timeout error if expect statements fails. Fix this.
|
|
357
|
-
it("propagates errors when using a callback", done => {
|
|
358
|
-
client.then(_client => {
|
|
359
|
-
_client.query("does_not_exist", {}, (err, result) => {
|
|
360
|
-
expect(result).to.be.null;
|
|
361
|
-
expect(err).to.be.an("error");
|
|
362
|
-
done();
|
|
363
|
-
});
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
it("works without arguments", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
367
|
-
const result = yield (yield client).query("test_without_args");
|
|
368
|
-
expect(result).to.equal(1);
|
|
369
|
-
}));
|
|
370
|
-
it("returns string key map", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
371
|
-
const result = yield (yield client).query("test_map");
|
|
372
|
-
expect(result["sample_key"]).to.equal("sample_value");
|
|
373
|
-
}));
|
|
374
|
-
it("returns byte array key map as an array with buffers", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
375
|
-
const result = yield (yield client).query("test_map_with_bytearray_key");
|
|
376
|
-
expect(Array.isArray(result)).to.be.true;
|
|
377
|
-
expect(Buffer.isBuffer(result[0][0])).to.be.true;
|
|
378
|
-
expect(result[0][1]).to.equal("sample_value");
|
|
379
|
-
}));
|
|
380
|
-
// TODO: make generic test that takes query name and arguments
|
|
381
|
-
// same as gtxClientIntegrationTest.ts
|
|
382
|
-
it.skip("works with basic types as arguments");
|
|
383
|
-
it.skip("retries default number of times", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
384
|
-
try {
|
|
385
|
-
yield (yield faultyClient).query("test_without_arguments");
|
|
386
|
-
}
|
|
387
|
-
catch (err) {
|
|
388
|
-
expect(handleRequestSpy.callCount).to.equal(9);
|
|
389
|
-
}
|
|
390
|
-
}));
|
|
391
|
-
it.skip("retries configured number of times", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
392
|
-
const _client = yield createClient({
|
|
393
|
-
nodeUrlPool: invalidEndpointPool,
|
|
394
|
-
blockchainRid: process.env.BLOCKCHAIN_RID,
|
|
395
|
-
failOverConfig: {
|
|
396
|
-
attemptsPerEndpoint: 1,
|
|
397
|
-
attemptInterval: 1,
|
|
398
|
-
},
|
|
399
|
-
merkleHashVersion: 1,
|
|
400
|
-
directoryChainRid: mockStringDirectoryChainRid,
|
|
401
|
-
});
|
|
402
|
-
try {
|
|
403
|
-
yield _client.query("test_without_arguments");
|
|
404
|
-
}
|
|
405
|
-
catch (err) {
|
|
406
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
407
|
-
}
|
|
408
|
-
}));
|
|
409
|
-
// TODO: Mock backend and use fake timers to make this more robust
|
|
410
|
-
it.skip("uses default attemptInterval of 500", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
411
|
-
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
412
|
-
const _client = yield createClient({
|
|
413
|
-
nodeUrlPool: invalidEndpointPool,
|
|
414
|
-
blockchainRid: process.env.BLOCKCHAIN_RID,
|
|
415
|
-
failOverConfig: {
|
|
416
|
-
attemptsPerEndpoint: 1,
|
|
417
|
-
},
|
|
418
|
-
merkleHashVersion: 1,
|
|
419
|
-
directoryChainRid: mockStringDirectoryChainRid,
|
|
420
|
-
});
|
|
421
|
-
_client.query("test_without_arguments");
|
|
422
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
423
|
-
yield sleep(250);
|
|
424
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
425
|
-
yield sleep(500);
|
|
426
|
-
expect(handleRequestSpy.callCount).to.equal(2);
|
|
427
|
-
yield sleep(500);
|
|
428
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
429
|
-
yield sleep(500);
|
|
430
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
431
|
-
}));
|
|
432
|
-
// TODO: Mock backend and use fake timers to make this more robust
|
|
433
|
-
it("uses configured attemptInterval", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
434
|
-
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
435
|
-
const _client = yield createClient({
|
|
436
|
-
nodeUrlPool: invalidEndpointPool,
|
|
437
|
-
blockchainRid: process.env.BLOCKCHAIN_RID,
|
|
438
|
-
failOverConfig: {
|
|
439
|
-
attemptsPerEndpoint: 1,
|
|
440
|
-
attemptInterval: 100,
|
|
441
|
-
},
|
|
442
|
-
merkleHashVersion: 1,
|
|
443
|
-
directoryChainRid: mockStringDirectoryChainRid,
|
|
444
|
-
});
|
|
445
|
-
_client.query("test_without_arguments");
|
|
446
|
-
//TODO: test not working locally (all values have to be 1)
|
|
447
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
448
|
-
yield sleep(50);
|
|
449
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
450
|
-
yield sleep(100);
|
|
451
|
-
expect(handleRequestSpy.callCount).to.equal(2);
|
|
452
|
-
yield sleep(100);
|
|
453
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
454
|
-
yield sleep(100);
|
|
455
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
456
|
-
}));
|
|
457
|
-
it("inits client with Blockchain IID and send query", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
458
|
-
const client = yield createClient({
|
|
459
|
-
nodeUrlPool: [LOCAL_POOL],
|
|
460
|
-
blockchainIid: 0,
|
|
461
|
-
});
|
|
462
|
-
const result = yield client.query("test_boolean", {
|
|
463
|
-
arg1: true,
|
|
464
|
-
});
|
|
465
|
-
expect(result).to.equal(1);
|
|
466
|
-
}));
|
|
467
|
-
});
|
|
468
|
-
describe("signTransaction", () => {
|
|
469
|
-
it("returns transaction with a signature when using signature provider", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
470
|
-
const client = yield stableConfigClient;
|
|
471
|
-
const signedTx = yield client.signTransaction(unsignedNonUniqueTx, sigProvA);
|
|
472
|
-
expect(signedTx.toString("hex")).to.equal(signedNonUniqueTxHex);
|
|
473
|
-
}));
|
|
474
|
-
it("returns transaction with a signature when using key pair", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
475
|
-
const signedTx = yield (yield stableConfigClient).signTransaction(unsignedNonUniqueTx, {
|
|
476
|
-
privKey: signerPrivKeyA,
|
|
477
|
-
pubKey: signerPubKeyA,
|
|
478
|
-
});
|
|
479
|
-
expect(signedTx.toString("hex")).to.equal(signedNonUniqueTxHex);
|
|
480
|
-
}));
|
|
481
|
-
it("adds signature to an already signed transaction", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
482
|
-
const _client = yield stableConfigClient;
|
|
483
|
-
const signedTxA = yield _client.signTransaction(unsignedNonUniqueTxWithTwoSigners, signerKeyPairA);
|
|
484
|
-
const signedTx = yield _client.signTransaction(signedTxA, signerKeyPairB);
|
|
485
|
-
const deserialized = gtxTool.deserialize(signedTx);
|
|
486
|
-
expect(deserialized.signatures).to.have.length(2);
|
|
487
|
-
expect(signedTx.toString("hex")).to.equal("a582012930820125a58194308191a1220420bfb34abea1045bb97ed18a5dbb2b8dce84" +
|
|
488
|
-
"cb181585d55abb321a33133dba0595a51d301ba5193017a20c0c0a736574496e746567" +
|
|
489
|
-
"6572a5073005a303020101a54c304aa123042102e5a018b3a2e155316109d9cdc5eab7" +
|
|
490
|
-
"39759c0e07e0c00bf9fccb8237fe4d7f02a123042103cb144659ef300200912762786a" +
|
|
491
|
-
"173663150592d78f4408390c47e9956d9a6c31a5818b308188a1420440c6d576625143" +
|
|
492
|
-
"eb97c783efc56a4fef7fa9f76dff775e65222c3217aef96c93be43a4d3d96f8f9c301f" +
|
|
493
|
-
"da9d9577c86f0dd400f803988bb7b97107c7d61e27b99fa1420440817ef63a1c3bc642" +
|
|
494
|
-
"6d9c23521ece05ad1b9e6607f68d25c699e4380865e00a82044d3ad31f422bdd9e39d2" +
|
|
495
|
-
"3769680fcb97bec393b3505de8743709dd3f373487");
|
|
496
|
-
}));
|
|
497
|
-
it.skip("returns error if signers does not match signMethod");
|
|
498
|
-
it("takes a callback, transaction with a signature when using signature provider", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
499
|
-
const client = yield stableConfigClient;
|
|
500
|
-
yield client.signTransaction(unsignedNonUniqueTx, sigProvA, (err, signedTx) => {
|
|
501
|
-
expect(signedTx === null || signedTx === void 0 ? void 0 : signedTx.toString("hex")).to.equal(signedNonUniqueTxHex);
|
|
502
|
-
});
|
|
503
|
-
}));
|
|
504
|
-
it("takes a callback, transaction with a signature when using key pair", done => {
|
|
505
|
-
stableConfigClient.then(_client => {
|
|
506
|
-
_client.signTransaction(unsignedNonUniqueTx, { privKey: signerPrivKeyA, pubKey: signerPubKeyA }, (err, signedTx) => {
|
|
507
|
-
expect(signedTx === null || signedTx === void 0 ? void 0 : signedTx.toString("hex")).to.equal(signedNonUniqueTxHex);
|
|
508
|
-
done();
|
|
509
|
-
});
|
|
510
|
-
});
|
|
511
|
-
});
|
|
512
|
-
it("rejects promise if signer does not exist", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
513
|
-
const promise = (yield stableConfigClient).signTransaction(unsignedTx, {
|
|
514
|
-
privKey: signerPrivKeyB,
|
|
515
|
-
pubKey: signerPubKeyB,
|
|
516
|
-
});
|
|
517
|
-
yield expect(promise).to.be.rejectedWith("No such signer, remember to add signer to transaction before" + " adding a signature");
|
|
518
|
-
}));
|
|
519
|
-
it("propagates errors when using a callback if signer does not exist", done => {
|
|
520
|
-
stableConfigClient.then(_client => {
|
|
521
|
-
_client.signTransaction(unsignedTx, { privKey: signerPrivKeyB, pubKey: signerPubKeyB }, (err, result) => {
|
|
522
|
-
expect(result).to.be.null;
|
|
523
|
-
expect(err).to.be.be.an("error");
|
|
524
|
-
done();
|
|
525
|
-
});
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
});
|
|
529
|
-
describe("sendTransaction", () => {
|
|
530
|
-
it("returns a PromiEvent", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
531
|
-
const promiEvent = (yield client).sendTransaction({
|
|
532
|
-
name: "setInteger",
|
|
533
|
-
args: [randomInt(99999)],
|
|
534
|
-
});
|
|
535
|
-
expect(promiEvent.then).to.be.a("function");
|
|
536
|
-
expect(promiEvent.on).to.be.a("function");
|
|
537
|
-
expect(promiEvent.once).to.be.a("function");
|
|
538
|
-
}));
|
|
539
|
-
// TODO: Results in a timeout error if expect statements fails. Fix this.
|
|
540
|
-
it("takes a callback", done => {
|
|
541
|
-
client.then(_client => {
|
|
542
|
-
_client.sendTransaction({
|
|
543
|
-
name: "setInteger",
|
|
544
|
-
args: [randomInt(99999)],
|
|
545
|
-
}, true, (err, receipt) => {
|
|
546
|
-
const transactionReceipt = receipt;
|
|
547
|
-
expect(transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.status).to.equal(ResponseStatus.Waiting);
|
|
548
|
-
expect(transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.statusCode).to.equal(200);
|
|
549
|
-
expect(transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.transactionRid).to.not.be.null;
|
|
550
|
-
done();
|
|
551
|
-
});
|
|
552
|
-
});
|
|
553
|
-
});
|
|
554
|
-
it("rejects promise on error", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
555
|
-
const promise = (yield client).sendTransaction({
|
|
556
|
-
name: "doesNotExist",
|
|
557
|
-
});
|
|
558
|
-
yield expect(promise).to.be.rejected;
|
|
559
|
-
}));
|
|
560
|
-
it.skip("rejects promise if transaction is rejected by network");
|
|
561
|
-
it("rejects promise if signers and signatures array have different size", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
562
|
-
const signedTx = yield (yield client).signTransaction(unsignedNonUniqueTxWithTwoSigners, sigProvA);
|
|
563
|
-
const deserializedSignedTx = gtxTool.deserialize(signedTx);
|
|
564
|
-
expect(deserializedSignedTx.signers.length).to.not.equal(deserializedSignedTx.signatures.length);
|
|
565
|
-
const promise = (yield client).sendTransaction(signedTx);
|
|
566
|
-
yield expect(promise).to.be.rejectedWith("Not matching number of signers and signatures");
|
|
567
|
-
}));
|
|
568
|
-
it("propagates errors when using a callback", done => {
|
|
569
|
-
client.then(_client => {
|
|
570
|
-
_client.sendTransaction({
|
|
571
|
-
name: "doesNotExist",
|
|
572
|
-
}, true, (err, receipt) => {
|
|
573
|
-
expect(receipt).to.be.null;
|
|
574
|
-
expect(err).to.be.be.an("error");
|
|
575
|
-
done();
|
|
576
|
-
});
|
|
577
|
-
});
|
|
578
|
-
});
|
|
579
|
-
it.skip("resolves promise once the transaction is accepted");
|
|
580
|
-
// TODO: Results in a timeout error if expect statements fails. Fix this.
|
|
581
|
-
it("emits PromiEvent 'sent' once transaction is sent", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
582
|
-
const client = yield createClient({
|
|
583
|
-
nodeUrlPool: LOCAL_POOL,
|
|
584
|
-
blockchainIid: 0,
|
|
585
|
-
});
|
|
586
|
-
const promiEvent = client.sendTransaction({
|
|
587
|
-
name: "setInteger",
|
|
588
|
-
args: [randomInt(99999)],
|
|
589
|
-
}, true, undefined, ChainConfirmationLevel.None);
|
|
590
|
-
promiEvent.on(TransactionEvent.DappReceived, (receipt) => {
|
|
591
|
-
expect(receipt.status).to.equal(ResponseStatus.Waiting);
|
|
592
|
-
expect(receipt.statusCode).to.equal(200);
|
|
593
|
-
expect(receipt.transactionRid).to.not.be.null;
|
|
594
|
-
});
|
|
595
|
-
}));
|
|
596
|
-
it.skip("resolves to a TransactionReceipt");
|
|
597
|
-
// TODO: Test fails when running entire test suite. Make it more robust
|
|
598
|
-
// by mocking the backend or writing unit tests
|
|
599
|
-
it.skip("uses default attemptInterval of 500", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
600
|
-
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
601
|
-
const _client = yield createClient({
|
|
602
|
-
nodeUrlPool: invalidEndpointPool,
|
|
603
|
-
blockchainRid: process.env.BLOCKCHAIN_RID,
|
|
604
|
-
failOverConfig: {
|
|
605
|
-
attemptsPerEndpoint: 1,
|
|
606
|
-
},
|
|
607
|
-
});
|
|
608
|
-
_client.sendTransaction({
|
|
609
|
-
name: "setInteger",
|
|
610
|
-
args: [randomInt(99999)],
|
|
611
|
-
});
|
|
612
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
613
|
-
yield sleep(250);
|
|
614
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
615
|
-
yield sleep(500);
|
|
616
|
-
expect(handleRequestSpy.callCount).to.equal(2);
|
|
617
|
-
yield sleep(500);
|
|
618
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
619
|
-
yield sleep(500);
|
|
620
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
621
|
-
}));
|
|
622
|
-
// TODO: Test fails when running entire test suite. Make it more robust
|
|
623
|
-
// by mocking the backend or writing unit tests
|
|
624
|
-
it.skip("uses default pollingInterval of 500", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
625
|
-
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
626
|
-
(yield client).sendTransaction({
|
|
627
|
-
name: "setInteger",
|
|
628
|
-
args: [randomInt(99999)],
|
|
629
|
-
});
|
|
630
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
631
|
-
yield sleep(250);
|
|
632
|
-
// will have sent the transaction and polled for status once
|
|
633
|
-
expect(handleRequestSpy.callCount).to.equal(2);
|
|
634
|
-
yield sleep(500);
|
|
635
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
636
|
-
yield sleep(500);
|
|
637
|
-
expect(handleRequestSpy.callCount).to.equal(4);
|
|
638
|
-
}));
|
|
639
|
-
// TODO: Test fails when running entire test suite. Make it more robust
|
|
640
|
-
// by mocking the backend or writing unit tests
|
|
641
|
-
it.skip("uses configured pollingInterval of 100", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
642
|
-
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
643
|
-
const _client = yield createClient({
|
|
644
|
-
nodeUrlPool: LOCAL_POOL,
|
|
645
|
-
blockchainRid: process.env.BLOCKCHAIN_RID,
|
|
646
|
-
dappStatusPolling: setStatusPolling({ interval: 100, count: CONFIGURED_POLL_COUNT }),
|
|
647
|
-
clusterAnchoringStatusPolling: setStatusPolling(),
|
|
648
|
-
systemAnchoringStatusPolling: setStatusPolling(),
|
|
649
|
-
});
|
|
650
|
-
_client.sendTransaction({
|
|
651
|
-
name: "setInteger",
|
|
652
|
-
args: [randomInt(99999)],
|
|
653
|
-
});
|
|
654
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
655
|
-
yield sleep(100);
|
|
656
|
-
expect(handleRequestSpy.callCount).to.equal(2);
|
|
657
|
-
yield sleep(100);
|
|
658
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
659
|
-
yield sleep(100);
|
|
660
|
-
expect(handleRequestSpy.callCount).to.equal(4);
|
|
661
|
-
}));
|
|
662
|
-
});
|
|
663
|
-
describe("addNop", () => {
|
|
664
|
-
it("adds nop to transaction object", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
665
|
-
var _a;
|
|
666
|
-
const transaction = (yield client).addNop(unsignedTx);
|
|
667
|
-
const nopOperation = transaction.operations[1];
|
|
668
|
-
expect(nopOperation).to.include({ name: "nop" });
|
|
669
|
-
expect(nopOperation.args).to.have.lengthOf(1);
|
|
670
|
-
expect((_a = nopOperation.args) === null || _a === void 0 ? void 0 : _a[0]).to.be.instanceof(Buffer);
|
|
671
|
-
// TODO changed nop to add randomBytes instead of randomInt because if failed in the browser
|
|
672
|
-
//expect((nopOperation.args?.[0] as number) % 1).to.equal(0); // Is integer
|
|
673
|
-
}));
|
|
674
|
-
it("adds nop with a unique argument", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
675
|
-
const transactionOne = (yield client).addNop({
|
|
676
|
-
operations: [
|
|
677
|
-
{
|
|
678
|
-
name: "setInteger",
|
|
679
|
-
args: [1],
|
|
680
|
-
},
|
|
681
|
-
],
|
|
682
|
-
signers: [signerPubKeyA],
|
|
683
|
-
});
|
|
684
|
-
const transactionTwo = (yield client).addNop({
|
|
685
|
-
operations: [
|
|
686
|
-
{
|
|
687
|
-
name: "setInteger",
|
|
688
|
-
args: [1],
|
|
689
|
-
},
|
|
690
|
-
],
|
|
691
|
-
signers: [signerPubKeyA],
|
|
692
|
-
});
|
|
693
|
-
const nopOperationOne = transactionOne.operations[1];
|
|
694
|
-
const nopOperationTwo = transactionTwo.operations[1];
|
|
695
|
-
expect(nopOperationOne).to.not.equal(nopOperationTwo);
|
|
696
|
-
}));
|
|
697
|
-
});
|
|
698
|
-
describe("signAndSendUniqueTransaction", () => {
|
|
699
|
-
it("returns a PromiEvent", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
700
|
-
const promiEvent = (yield client).signAndSendUniqueTransaction({
|
|
701
|
-
name: "setInteger",
|
|
702
|
-
args: [randomInt(99999)],
|
|
703
|
-
}, sigProvA);
|
|
704
|
-
expect(promiEvent.then).to.be.a("function");
|
|
705
|
-
expect(promiEvent.on).to.be.a("function");
|
|
706
|
-
expect(promiEvent.once).to.be.a("function");
|
|
707
|
-
}));
|
|
708
|
-
// TODO: Results in a timeout error if expect statements fails. Fix this.
|
|
709
|
-
it("takes a callback", done => {
|
|
710
|
-
client.then(_client => {
|
|
711
|
-
_client.signAndSendUniqueTransaction({
|
|
712
|
-
name: "setInteger",
|
|
713
|
-
args: [randomInt(99999)],
|
|
714
|
-
}, sigProvA, true, (err, receipt) => {
|
|
715
|
-
const transactionReceipt = receipt;
|
|
716
|
-
expect(transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.status).to.equal(ResponseStatus.Waiting);
|
|
717
|
-
expect(transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.statusCode).to.equal(200);
|
|
718
|
-
expect(transactionReceipt === null || transactionReceipt === void 0 ? void 0 : transactionReceipt.transactionRid).to.not.be.null;
|
|
719
|
-
done();
|
|
720
|
-
});
|
|
721
|
-
});
|
|
722
|
-
});
|
|
723
|
-
it.skip("rejects promise if send failed");
|
|
724
|
-
it("rejects promise if transaction has empty list of signers", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
725
|
-
const promise = (yield client).signAndSendUniqueTransaction({
|
|
726
|
-
operations: [
|
|
727
|
-
{
|
|
728
|
-
name: "setInteger",
|
|
729
|
-
args: [randomInt(99999)],
|
|
730
|
-
},
|
|
731
|
-
],
|
|
732
|
-
signers: [],
|
|
733
|
-
}, sigProvA);
|
|
734
|
-
yield expect(promise).to.be.rejectedWith("No such signer, remember to add signer to transaction before adding a signature");
|
|
735
|
-
}));
|
|
736
|
-
it("rejects promise if transaction has signers that do not match signMethod", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
737
|
-
const promise = (yield client).signAndSendUniqueTransaction({
|
|
738
|
-
operations: [
|
|
739
|
-
{
|
|
740
|
-
name: "setInteger",
|
|
741
|
-
args: [randomInt(99999)],
|
|
742
|
-
},
|
|
743
|
-
],
|
|
744
|
-
signers: [signerPubKeyB],
|
|
745
|
-
}, sigProvA);
|
|
746
|
-
yield expect(promise).to.be.rejectedWith("No such signer, remember to add signer to transaction before adding a signature");
|
|
747
|
-
}));
|
|
748
|
-
it.skip("rejects promise if transaction is rejected by network");
|
|
749
|
-
it("propagates errors when using a callback", done => {
|
|
750
|
-
client.then(_client => {
|
|
751
|
-
_client.signAndSendUniqueTransaction({
|
|
752
|
-
name: "doesNotExist",
|
|
753
|
-
}, sigProvA, true, (err, receipt) => {
|
|
754
|
-
expect(receipt).to.be.null;
|
|
755
|
-
expect(err).to.be.be.an("error");
|
|
756
|
-
done();
|
|
757
|
-
});
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
// TODO: Results in a timeout error if expect statements fails. Fix this.
|
|
761
|
-
it("emits PromiEvent 'sent' once transaction is sent", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
762
|
-
const client = yield createClient({
|
|
763
|
-
nodeUrlPool: LOCAL_POOL,
|
|
764
|
-
blockchainIid: 0,
|
|
765
|
-
});
|
|
766
|
-
const promiEvent = client.signAndSendUniqueTransaction({
|
|
767
|
-
name: "setInteger",
|
|
768
|
-
args: [randomInt(99999)],
|
|
769
|
-
}, sigProvA, true, undefined, ChainConfirmationLevel.None);
|
|
770
|
-
promiEvent.on(TransactionEvent.DappReceived, (receipt) => {
|
|
771
|
-
expect(receipt.status).to.equal(ResponseStatus.Waiting);
|
|
772
|
-
expect(receipt.statusCode).to.equal(200);
|
|
773
|
-
expect(receipt.transactionRid).to.not.be.null;
|
|
774
|
-
});
|
|
775
|
-
}));
|
|
776
|
-
it.skip("resolves promise once the transaction is accepted");
|
|
777
|
-
it.skip("resolves to a TransactionReceipt");
|
|
778
|
-
// TODO: Test fails when running entire test suite. Make it more robust
|
|
779
|
-
// by mocking the backend or writing unit tests
|
|
780
|
-
it.skip("uses default attemptInterval of 500", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
781
|
-
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
782
|
-
const _client = yield createClient({
|
|
783
|
-
nodeUrlPool: invalidEndpointPool,
|
|
784
|
-
blockchainRid: process.env.BLOCKCHAIN_RID,
|
|
785
|
-
failOverConfig: {
|
|
786
|
-
attemptsPerEndpoint: 1,
|
|
787
|
-
},
|
|
788
|
-
});
|
|
789
|
-
_client.signAndSendUniqueTransaction({
|
|
790
|
-
name: "setInteger",
|
|
791
|
-
args: [randomInt(99999)],
|
|
792
|
-
}, signerKeyPairA);
|
|
793
|
-
yield sleep(10);
|
|
794
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
795
|
-
yield sleep(440);
|
|
796
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
797
|
-
yield sleep(500);
|
|
798
|
-
expect(handleRequestSpy.callCount).to.equal(2);
|
|
799
|
-
yield sleep(500);
|
|
800
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
801
|
-
yield sleep(500);
|
|
802
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
803
|
-
})).timeout(5000);
|
|
804
|
-
});
|
|
805
|
-
describe("getTransaction", () => {
|
|
806
|
-
it("rejects promise if a specific txRID does not exist in blockchain", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
807
|
-
const _client = yield client;
|
|
808
|
-
const promise = _client.getTransaction(Buffer.alloc(32, "a"));
|
|
809
|
-
yield expect(promise).to.be.rejectedWith(`{"error":"Can't find transaction with RID: 6161616161616161616161616161616161616161616161616161616161616161"}`);
|
|
810
|
-
}));
|
|
811
|
-
it("returns a promise", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
812
|
-
const _client = yield client;
|
|
813
|
-
const { txRID } = getTxWithGTXAndTxRID(_client);
|
|
814
|
-
const promise = _client.getTransaction(txRID);
|
|
815
|
-
expect(promise.then).to.be.a("function");
|
|
816
|
-
}));
|
|
817
|
-
it("rejects promise if transaction RID is invalid", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
818
|
-
const _client = yield client;
|
|
819
|
-
const promise = _client.getTransaction(Buffer.from("invalid"));
|
|
820
|
-
yield expect(promise).to.be.rejectedWith("expected length 32 of txRID, but got 7");
|
|
821
|
-
}));
|
|
822
|
-
it("propagates errors when using a callback", done => {
|
|
823
|
-
client.then(_client => {
|
|
824
|
-
_client.getTransaction(Buffer.from("invalid"), (err, serializedMessage) => {
|
|
825
|
-
expect(err === null || err === void 0 ? void 0 : err.message).to.equal("expected length 32 of txRID, but got 7");
|
|
826
|
-
expect(serializedMessage).to.be.null;
|
|
827
|
-
done();
|
|
828
|
-
});
|
|
829
|
-
});
|
|
830
|
-
});
|
|
831
|
-
});
|
|
832
|
-
describe("getTransactionStatus", () => {
|
|
833
|
-
it("gets status of an unknown transaction", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
834
|
-
const _client = yield client;
|
|
835
|
-
const { txRID } = getTxWithGTXAndTxRID(_client);
|
|
836
|
-
const { status } = yield _client.getTransactionStatus(txRID);
|
|
837
|
-
expect(status).to.equal(ResponseStatus.Unknown);
|
|
838
|
-
}));
|
|
839
|
-
it.skip("gets status of a rejected transaction");
|
|
840
|
-
it("returns a promise", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
841
|
-
const _client = yield client;
|
|
842
|
-
const { txRID } = getTxWithGTXAndTxRID(_client);
|
|
843
|
-
const promise = _client.getTransactionStatus(txRID);
|
|
844
|
-
expect(promise.then).to.be.a("function");
|
|
845
|
-
}));
|
|
846
|
-
it("rejects promise if transaction RID is invalid", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
847
|
-
const promise = (yield client).getTransactionStatus(Buffer.from("invalid"));
|
|
848
|
-
yield expect(promise).to.be.rejectedWith("expected length 32 of txRID, but got 7");
|
|
849
|
-
}));
|
|
850
|
-
it("propagates errors when using a callback", done => {
|
|
851
|
-
const callback = (err, statusObj) => {
|
|
852
|
-
expect(err === null || err === void 0 ? void 0 : err.message).to.equal("expected length 32 of txRID, but got 7");
|
|
853
|
-
expect(statusObj).to.be.null;
|
|
854
|
-
done();
|
|
855
|
-
};
|
|
856
|
-
client.then(_client => {
|
|
857
|
-
_client.getTransactionStatus(Buffer.from("invalid"), callback);
|
|
858
|
-
});
|
|
859
|
-
});
|
|
860
|
-
it.skip("retries default number of times", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
861
|
-
const _faultyClient = yield faultyClient;
|
|
862
|
-
try {
|
|
863
|
-
const { txRID } = getTxWithGTXAndTxRID(_faultyClient);
|
|
864
|
-
yield _faultyClient.getTransactionStatus(txRID);
|
|
865
|
-
}
|
|
866
|
-
catch (err) {
|
|
867
|
-
expect(handleRequestSpy.callCount).to.equal(9);
|
|
868
|
-
}
|
|
869
|
-
}));
|
|
870
|
-
it("uses default attemptInterval of 500", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
871
|
-
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
872
|
-
const _client = yield createClient({
|
|
873
|
-
nodeUrlPool: invalidEndpointPool,
|
|
874
|
-
blockchainRid: process.env.BLOCKCHAIN_RID,
|
|
875
|
-
failOverConfig: {
|
|
876
|
-
attemptsPerEndpoint: 1,
|
|
877
|
-
},
|
|
878
|
-
directoryChainRid: mockStringDirectoryChainRid,
|
|
879
|
-
});
|
|
880
|
-
try {
|
|
881
|
-
const { txRID } = getTxWithGTXAndTxRID(_client);
|
|
882
|
-
_client.getTransactionStatus(txRID);
|
|
883
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
884
|
-
yield sleep(500);
|
|
885
|
-
expect(handleRequestSpy.callCount).to.equal(1);
|
|
886
|
-
yield sleep(500);
|
|
887
|
-
expect(handleRequestSpy.callCount).to.equal(2);
|
|
888
|
-
yield sleep(500);
|
|
889
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
890
|
-
yield sleep(500);
|
|
891
|
-
expect(handleRequestSpy.callCount).to.equal(3);
|
|
892
|
-
}
|
|
893
|
-
catch (error) {
|
|
894
|
-
expect(error).to.not.be.null;
|
|
895
|
-
}
|
|
896
|
-
})).timeout(4000);
|
|
897
|
-
});
|
|
898
|
-
describe("getTransactionRID", () => {
|
|
899
|
-
it("takes a transaction object", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
900
|
-
const txRID = (yield stableConfigClient).getTransactionRid({
|
|
901
|
-
operations: [
|
|
902
|
-
{
|
|
903
|
-
name: "setInteger",
|
|
904
|
-
args: [1],
|
|
905
|
-
},
|
|
906
|
-
],
|
|
907
|
-
signers: [],
|
|
908
|
-
});
|
|
909
|
-
expect(txRID.toString("hex")).to.equal("9f8966574214d987ddcc918c09eb7f1b6a1a75855d8e03bbffb07ef2cb949534");
|
|
910
|
-
}));
|
|
911
|
-
it("takes an operation", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
912
|
-
const txRID = (yield stableConfigClient).getTransactionRid({
|
|
913
|
-
name: "setInteger",
|
|
914
|
-
args: [1],
|
|
915
|
-
});
|
|
916
|
-
expect(txRID.toString("hex")).to.equal("9f8966574214d987ddcc918c09eb7f1b6a1a75855d8e03bbffb07ef2cb949534");
|
|
917
|
-
}));
|
|
918
|
-
it("takes a signed transaction buffer", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
919
|
-
const signedTx = Buffer.from(signedNonUniqueTxHex, "hex");
|
|
920
|
-
const txRID = (yield stableConfigClient).getTransactionRid(signedTx);
|
|
921
|
-
expect(txRID.toString("hex")).to.equal("33754eb08c2a7c6be69821608378ef315399f3113de6ea229023ccad2b7ea7a7");
|
|
922
|
-
}));
|
|
923
|
-
});
|
|
924
|
-
describe("getTransactionsInfo", () => {
|
|
925
|
-
it("returns empty array when limit is invalid", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
926
|
-
const _client = yield client;
|
|
927
|
-
const transactions = yield _client.getTransactionsInfo(-1);
|
|
928
|
-
expect(transactions).to.be.instanceOf(Array).and.lengthOf(0);
|
|
929
|
-
}));
|
|
930
|
-
it.skip("returns empty array when before-time is invalid", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
931
|
-
const _client = yield client;
|
|
932
|
-
const transactions = yield _client.getTransactionsInfo(undefined, new Date(-1));
|
|
933
|
-
expect(transactions).to.be.instanceOf(Array).and.lengthOf(0);
|
|
934
|
-
}));
|
|
935
|
-
});
|
|
936
|
-
describe("getTransactionInfo", () => {
|
|
937
|
-
it("should throw 404 error when transaction rid is not found", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
938
|
-
const _client = yield client;
|
|
939
|
-
const invalidTxRid = "8FB7809B264587F165771FDE89471F8C81838785FB9DAC65E3DFFD1B41B7EFFC";
|
|
940
|
-
const transactionInfoPromise = _client.getTransactionInfo(toBuffer(invalidTxRid));
|
|
941
|
-
yield expect(transactionInfoPromise).to.be.rejectedWith(`{"error":"Can't find transaction with RID: ${invalidTxRid}"}`);
|
|
942
|
-
}));
|
|
943
|
-
});
|
|
944
|
-
describe("getBlockInfo", () => {
|
|
945
|
-
it("should return an error when provided with a block identifier of the wrong type.", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
946
|
-
const _client = yield client;
|
|
947
|
-
const rejectedPromise = _client.getBlockInfo(["test"]);
|
|
948
|
-
yield expect(rejectedPromise).to.be.rejectedWith(`Invalid "blockIdentifier" type. Expected string or number, but received object.`);
|
|
949
|
-
}));
|
|
950
|
-
it("should return an error when provided with a block identifier string of a wrong format.", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
951
|
-
const _client = yield client;
|
|
952
|
-
const rejectedPromise = _client.getBlockInfo("123213asdsad");
|
|
953
|
-
yield expect(rejectedPromise).to.be.rejectedWith("Parameter 'blockIdentifier' does not have the correct format (64-character hexadecimal string).");
|
|
954
|
-
}));
|
|
955
|
-
it("should return null when given a non-existing block RID.", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
956
|
-
const _client = yield client;
|
|
957
|
-
const block = yield _client.getBlockInfo("B640E5935B54E9CB2029C56EF33F89D0A3C1041E2C1B38389F2930DFC1179657");
|
|
958
|
-
expect(block).to.be.null;
|
|
959
|
-
}));
|
|
960
|
-
it("should return null when given a non-existing block height.", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
961
|
-
const _client = yield client;
|
|
962
|
-
const block = yield _client.getBlockInfo(999999999999);
|
|
963
|
-
expect(block).to.be.null;
|
|
964
|
-
}));
|
|
965
|
-
it("should fetch a block when provided with a block height", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
966
|
-
const _client = yield client;
|
|
967
|
-
const block = yield _client.getBlockInfo(1);
|
|
968
|
-
expect(block).to.have.keys([
|
|
969
|
-
"rid",
|
|
970
|
-
"prevBlockRid",
|
|
971
|
-
"header",
|
|
972
|
-
"height",
|
|
973
|
-
"transactions",
|
|
974
|
-
"witness",
|
|
975
|
-
"witnesses",
|
|
976
|
-
"timestamp",
|
|
977
|
-
]);
|
|
978
|
-
}));
|
|
979
|
-
it("should fetch a block when provided with a block RID.", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
980
|
-
const _client = yield client;
|
|
981
|
-
const blockFromHeight = yield _client.getBlockInfo(1);
|
|
982
|
-
const block = yield _client.getBlockInfo(blockFromHeight.rid.toString("hex"));
|
|
983
|
-
expect(block).to.have.keys([
|
|
984
|
-
"rid",
|
|
985
|
-
"prevBlockRid",
|
|
986
|
-
"header",
|
|
987
|
-
"height",
|
|
988
|
-
"transactions",
|
|
989
|
-
"witness",
|
|
990
|
-
"witnesses",
|
|
991
|
-
"timestamp",
|
|
992
|
-
]);
|
|
993
|
-
}));
|
|
994
|
-
});
|
|
995
|
-
describe("getLatestBlock", () => {
|
|
996
|
-
it("get latest block", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
997
|
-
const blockInfo = yield (yield client).getLatestBlock();
|
|
998
|
-
expect(blockInfo).to.have.keys([
|
|
999
|
-
"rid",
|
|
1000
|
-
"prevBlockRid",
|
|
1001
|
-
"header",
|
|
1002
|
-
"height",
|
|
1003
|
-
"transactions",
|
|
1004
|
-
"witness",
|
|
1005
|
-
"witnesses",
|
|
1006
|
-
"timestamp",
|
|
1007
|
-
]);
|
|
1008
|
-
}));
|
|
1009
|
-
});
|
|
1010
|
-
describe("getBlocksInfo", () => {
|
|
1011
|
-
it("fetches all blocks for a chain", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1012
|
-
const _client = yield client;
|
|
1013
|
-
const blocks = yield _client.getBlocksInfo();
|
|
1014
|
-
expect(blocks).to.not.be.empty;
|
|
1015
|
-
}));
|
|
1016
|
-
it("fetches all blocks before a block height", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1017
|
-
const _client = yield client;
|
|
1018
|
-
const blocks = yield _client.getBlocksInfo(undefined, undefined, 2);
|
|
1019
|
-
expect(blocks).to.have.length(2);
|
|
1020
|
-
}));
|
|
1021
|
-
});
|
|
1022
|
-
describe("getClientNodeURLPool", () => {
|
|
1023
|
-
it("gets list of url from the client config", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1024
|
-
const nodeUrlPool = (yield client).getClientNodeUrlPool();
|
|
1025
|
-
expect(nodeUrlPool).to.deep.equal([LOCAL_POOL]);
|
|
1026
|
-
}));
|
|
1027
|
-
});
|
|
1028
|
-
describe("getConfirmationProof", () => {
|
|
1029
|
-
it("returns error", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1030
|
-
const _client = yield client;
|
|
1031
|
-
const promise = _client.getConfirmationProof(mockThirtyTwoBytesBuffer);
|
|
1032
|
-
yield expect(promise).to.be.rejectedWith(`{"error":"Can't find transaction with RID: 0000000000000000000000000000000000000000000000000000000000000000"}`);
|
|
1033
|
-
}));
|
|
1034
|
-
});
|
|
1035
|
-
describe("createClient", () => {
|
|
1036
|
-
it("initializes with default status polling configurations", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1037
|
-
const client = yield createClient({
|
|
1038
|
-
nodeUrlPool: LOCAL_POOL,
|
|
1039
|
-
blockchainRid: "BFB34ABEA1045BB97ED18A5DBB2B8DCE84CB181585D55ABB321A33133DBA0595",
|
|
1040
|
-
});
|
|
1041
|
-
const defaultStatusPollingConfig = {
|
|
1042
|
-
interval: 500,
|
|
1043
|
-
count: 20,
|
|
1044
|
-
};
|
|
1045
|
-
expect(client.config.dappStatusPolling).to.deep.equal(defaultStatusPollingConfig);
|
|
1046
|
-
expect(client.config.clusterAnchoringStatusPolling).to.deep.equal(defaultStatusPollingConfig);
|
|
1047
|
-
expect(client.config.systemAnchoringStatusPolling).to.deep.equal(defaultStatusPollingConfig);
|
|
1048
|
-
}));
|
|
1049
|
-
it("initializes with 3 different status polling configurations", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1050
|
-
const dappStatusPollingConfig = {
|
|
1051
|
-
interval: 100,
|
|
1052
|
-
count: 5,
|
|
1053
|
-
};
|
|
1054
|
-
const clusterAnchoringStatusPollingConfig = {
|
|
1055
|
-
interval: 200,
|
|
1056
|
-
count: 10,
|
|
1057
|
-
};
|
|
1058
|
-
const systemAnchoringStatusPollingConfig = {
|
|
1059
|
-
interval: 500,
|
|
1060
|
-
count: 20,
|
|
1061
|
-
};
|
|
1062
|
-
const client = yield createClient({
|
|
1063
|
-
nodeUrlPool: LOCAL_POOL,
|
|
1064
|
-
blockchainRid: "BFB34ABEA1045BB97ED18A5DBB2B8DCE84CB181585D55ABB321A33133DBA0595",
|
|
1065
|
-
dappStatusPolling: dappStatusPollingConfig,
|
|
1066
|
-
clusterAnchoringStatusPolling: clusterAnchoringStatusPollingConfig,
|
|
1067
|
-
systemAnchoringStatusPolling: systemAnchoringStatusPollingConfig,
|
|
1068
|
-
});
|
|
1069
|
-
expect(client.config.dappStatusPolling).to.deep.equal(dappStatusPollingConfig);
|
|
1070
|
-
expect(client.config.clusterAnchoringStatusPolling).to.deep.equal(clusterAnchoringStatusPollingConfig);
|
|
1071
|
-
expect(client.config.systemAnchoringStatusPolling).to.deep.equal(systemAnchoringStatusPollingConfig);
|
|
1072
|
-
}));
|
|
1073
|
-
});
|
|
1074
|
-
});
|
|
1075
|
-
//# sourceMappingURL=blockchainClientIntegration.test.js.map
|