From 86b90956080502e290f17ed42efcb7def83a037c Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 21 Jun 2022 13:32:52 +0900 Subject: [PATCH 01/42] Implemented newly added rpc calls to before common architecture --- rpc.json | 54 +++++++++++++++++++++++- types/packages/caver-klay/src/index.d.ts | 9 ++++ types/packages/caver-rtm/src/index.d.ts | 51 +++++++++++++++++++--- 3 files changed, 108 insertions(+), 6 deletions(-) diff --git a/rpc.json b/rpc.json index a767ee9d..cf76418e 100644 --- a/rpc.json +++ b/rpc.json @@ -86,12 +86,24 @@ "params": 1, "inputFormatter": ["inputTransactionFormatter"] }, + { + "name": "signTransactionAsFeePayer", + "call": "klay_signTransactionAsFeePayer", + "params": 1, + "inputFormatter": ["inputTransactionFormatter"] + }, { "name": "sendTransaction", "call": "klay_sendTransaction", "params": 1, "inputFormatter": ["inputTransactionFormatter"] }, + { + "name": "sendTransactionAsFeePayer", + "call": "klay_sendTransactionAsFeePayer", + "params": 1, + "inputFormatter": ["inputTransactionFormatter"] + }, { "name": "call", "call": "klay_call", @@ -126,13 +138,20 @@ "params": 2, "inputFormatter": ["inputBlockNumberFormatter", "toBoolean"] }, + { + "name": "getHeader", + "call": "klay_getHeaderByNumber", + "hexCall": "klay_getHeaderByHash", + "params": 1, + "inputFormatter": ["inputBlockNumberFormatter"] + }, { "name": "getBlockTransactionCount", "call": "klay_getBlockTransactionCountByNumber", "hexCall": "klay_getBlockTransactionCountByHash", "params": 1, "inputFormatter": ["inputBlockNumberFormatter"], - "outputFormatter": "hexToNumber" + "outputFormatter": "hexToNumber" }, { "name": "getTransactionFromBlock", @@ -368,11 +387,44 @@ "call": "klay_getBlockReceipts", "params": 1 }, + { + "name": "getDecodedAnchoringTransactionByHash", + "call": "klay_getDecodedAnchoringTransactionByHash", + "params": 1 + }, + { + "name": "createAccessList", + "call": "klay_createAccessList", + "params": 2, + "inputFormatter": ["inputTransactionFormatter", "inputDefaultBlockNumberFormatter"] + }, + { + "name": "getMaxPriorityFeePerGas", + "call": "klay_maxPriorityFeePerGas", + "params": 0 + }, + { + "name": "getFeeHistory", + "call": "klay_feeHistory", + "params": 3, + "inputFormatter": ["numberToHex", "inputBlockNumberFormatter", null] + }, + { + "name": "getFeeHistory", + "call": "klay_feeHistory", + "params": 3, + "inputFormatter": ["numberToHex", "inputBlockNumberFormatter", null] + }, { "name": "peerCountByType", "call": "net_peerCountByType", "params": 0 }, + { + "name": "getVersion", + "call": "net_version", + "params": 0 + }, { "name": "estimateComputationCost", "call": "klay_estimateComputationCost", diff --git a/types/packages/caver-klay/src/index.d.ts b/types/packages/caver-klay/src/index.d.ts index 4bfc37b3..02d83605 100644 --- a/types/packages/caver-klay/src/index.d.ts +++ b/types/packages/caver-klay/src/index.d.ts @@ -81,6 +81,9 @@ export class DeprecatedKlayRPC { getBlock: RpcCallToMethod['klay_getBlock'] getBlockByNumber: RpcCallToMethod['klay_getBlockByNumber'] getBlockByHash: RpcCallToMethod['klay_getBlockByHash'] + getHeader: RpcCallToMethod['klay_getHeader'] + getHeaderByNumber: RpcCallToMethod['klay_getHeaderByNumber'] + getHeaderByHash: RpcCallToMethod['klay_getHeaderByHash'] getBlockReceipts: RpcCallToMethod['klay_getBlockReceipts'] getBlockWithConsensusInfo: RpcCallToMethod['klay_getBlockWithConsensusInfo'] getBlockWithConsensusInfoByNumber: RpcCallToMethod['klay_getBlockWithConsensusInfoByNumber'] @@ -106,11 +109,17 @@ export class DeprecatedKlayRPC { getTransactionBySenderTxHash: RpcCallToMethod['klay_getTransactionBySenderTxHash'] getTransactionReceipt: RpcCallToMethod['klay_getTransactionReceipt'] getTransactionReceiptBySenderTxHash: RpcCallToMethod['klay_getTransactionReceiptBySenderTxHash'] + createAccessList: RpcCallToMethod['klay_createAccessList'] + getDecodedAnchoringTransactionByHash: RpcCallToMethod['klay_getDecodedAnchoringTransactionByHash'] + getFeeHistory: RpcCallToMethod['klay_feeHistory'] + getMaxPriorityFeePerGas: RpcCallToMethod['klay_maxPriorityFeePerGas'] sendRawTransaction: RpcCallToMethod['klay_sendRawTransaction'] sendSignedTransaction: RpcCallToMethod['klay_sendRawTransaction'] sendTransaction: RpcCallToMethod['klay_sendTransaction'] + sendTransactionAsFeePayer: RpcCallToMethod['klay_sendTransactionAsFeePayer'] signTransaction: RpcCallToMethod['klay_signTransaction'] + signTransactionAsFeePayer: RpcCallToMethod['klay_signTransactionAsFeePayer'] getChainId: RpcCallToMethod['klay_chainID'] getNodeInfo: RpcCallToMethod['klay_clientVersion'] diff --git a/types/packages/caver-rtm/src/index.d.ts b/types/packages/caver-rtm/src/index.d.ts index 53873f8d..c638b276 100644 --- a/types/packages/caver-rtm/src/index.d.ts +++ b/types/packages/caver-rtm/src/index.d.ts @@ -12,9 +12,11 @@ You should have received a copy of the GNU Lesser General Public License along with the caver-js. If not, see . */ -// no use import -// import { AccountKey } from '../../caver-account/src' + +import BN = require('bn.js') +import BigNumber from 'bignumber.js' import { + Header, Block, BlockNumber, TransactionReceipt, @@ -23,13 +25,14 @@ import { PromiEvent, TransactionForSendRPC, RLPEncodedTransaction, - DecodedAnchoringTransaction, Log, LogsOptions, LogObject, CallObject, + DecodedAnchoringTransaction, + FeeHistoryResult, } from '../../caver-core/src' -import { Transaction } from '../../caver-transaction/src' +import { Transaction, FeeDelegatedTransaction, AccessListResult } from '../../caver-transaction/src' import { Syncing, AccountKeyForRPC, AccountForRPC } from '../../caver-rpc/src/klay' import { PeerCountByType } from '../../caver-rpc/src/net' @@ -74,10 +77,18 @@ export default class RpcCallToMethod { transaction: TransactionForSendRPC | Transaction, callback?: (error: Error, result: RLPEncodedTransaction) => void ): Promise + klay_signTransactionAsFeePayer( + transaction: TransactionForSendRPC | FeeDelegatedTransaction, + callback?: (error: Error, result: RLPEncodedTransaction) => void + ): Promise klay_sendTransaction( transaction: TransactionForSendRPC | Transaction, callback?: (error: Error, result: TransactionReceipt) => void ): PromiEvent + klay_sendTransactionAsFeePayer( + transaction: TransactionForSendRPC | FeeDelegatedTransaction, + callback?: (error: Error, result: TransactionReceipt) => void + ): PromiEvent klay_call(callObject: CallObject, blockNumber?: BlockNumber, callback?: (error: Error, result: string) => void): Promise klay_estimateGas(callObject: CallObject, blockNumber?: BlockNumber, callback?: (error: Error, result: string) => void): Promise klay_getLogs(options: LogsOptions, callback?: (error: Error, result: Log[]) => void): Promise @@ -102,6 +113,18 @@ export default class RpcCallToMethod { returnTransactionObjects?: boolean, callback?: (error: Error, result: Block) => void ): Promise + klay_getHeader( + blockNumberOrHash: BlockNumber | string, + callback?: (error: Error, result: Header) => void + ): Promise
+ klay_getHeaderByNumber( + blockNumber: BlockNumber, + callback?: (error: Error, result: Header) => void + ): Promise
+ klay_getHeaderByHash( + blockHash: string, + callback?: (error: Error, result: Header) => void + ): Promise
klay_getTransactionFromBlock( blockNumber: BlockNumber, index: number, @@ -189,11 +212,29 @@ export default class RpcCallToMethod { callback?: (error: Error, result: string) => void ): Promise klay_chainID(callback?: (error: Error, result: string) => void): Promise - + klay_createAccessList( + callObject: CallObject, + blockNumber: BlockNumber, + callback?: (error: Error, result: AccessListResult) => void + ): Promise + klay_getDecodedAnchoringTransactionByHash( + transactionHash: string, + callback?: (error: Error, result: DecodedAnchoringTransaction) => void + ): Promise + klay_feeHistory( + blockCount: string | number | BN | BigNumber, + latestBlock: BlockNumber, + rewardPercentiles: number[], + callback?: (error: Error, result: FeeHistoryResult) => void + ): Promise + klay_maxPriorityFeePerGas( + callback?: (error: Error, result: string) => void + ): Promise net_networkID(callback?: (error: Error, result: string) => void): Promise net_listening(callback?: (error: Error, result: boolean) => void): Promise net_peerCount(callback?: (error: Error, result: string) => void): Promise net_peerCountByType(callback?: (error: Error, result: PeerCountByType) => void): Promise + net_version(callback?: (error: Error, result: string) => void): Promise personal_listAccounts(callback?: (error: Error, result: string) => void): Promise personal_newAccount(passphrase?: string, callback?: (error: Error, result: string) => void): Promise From cfb5994398ede43e8a898283a85866ac38300aa4 Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 22 Jun 2022 15:47:12 +0900 Subject: [PATCH 02/42] Added net_version rpc call to rpc layer --- packages/caver-rpc/src/net.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/caver-rpc/src/net.js b/packages/caver-rpc/src/net.js index e96a930a..1cc91035 100644 --- a/packages/caver-rpc/src/net.js +++ b/packages/caver-rpc/src/net.js @@ -107,6 +107,24 @@ const Net = function Net(...args) { call: 'net_peerCountByType', params: 0, }), + /** + * Returns the current klaytn protocol version. + * + * @memberof Net + * @method getVersion + * @instance + * + * @example + * const result = await caver.rpc.net.getVersion() + * + * @param {function} [callback] Optional callback, returns an error object as the first parameter and the result as the second. + * @return {Promise} The klaytn protocol version. + */ + new Method({ + name: 'getVersion', + call: 'net_version', + params: 0, + }), ] netMethods.forEach(function(method) { From d73cc62684d3860aa3880b98c6b99a26691841b5 Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 22 Jun 2022 15:49:34 +0900 Subject: [PATCH 03/42] Added effectiveGasPrice field to receipt in types file --- types/packages/caver-core/src/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/packages/caver-core/src/index.d.ts b/types/packages/caver-core/src/index.d.ts index 11d2edcb..9459e765 100644 --- a/types/packages/caver-core/src/index.d.ts +++ b/types/packages/caver-core/src/index.d.ts @@ -134,6 +134,7 @@ export interface TransactionReceipt { blockNumber: string codeFormat?: string chainId?: string + effectiveGasPrice?: string feePayer?: string feePayerSignatures?: SignatureForRPC[] feeRatio?: string From 066877abbafb8502e4cd8fa1fcf8c708afb0ff63 Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 22 Jun 2022 15:49:43 +0900 Subject: [PATCH 04/42] Fixed mistypo --- test/packages/caver.transaction/ethereumDynamicFee.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/packages/caver.transaction/ethereumDynamicFee.js b/test/packages/caver.transaction/ethereumDynamicFee.js index f4d4b8ee..71958e6c 100644 --- a/test/packages/caver.transaction/ethereumDynamicFee.js +++ b/test/packages/caver.transaction/ethereumDynamicFee.js @@ -899,7 +899,7 @@ describe('TxTypeEthereumDynamicFee', () => { }) context('ethereumDynamicFee.fillTransaction', () => { - it('CAVERJS-UNIT-TRANSACTION-547: fillTransaction should call klay_getMaxPriorityFeePerGas to fill maxPriorityFeePerGas when maxPriorityFeePerGas is undefined', async () => { + it('CAVERJS-UNIT-TRANSACTION-547: fillTransaction should call klay_maxPriorityFeePerGas to fill maxPriorityFeePerGas when maxPriorityFeePerGas is undefined', async () => { transactionObj.nonce = '0x3a' delete transactionObj.maxPriorityFeePerGas const tx = caver.transaction.ethereumDynamicFee.create(transactionObj) From 1f5c9305bdcad4eccc1c673b1b076269160327bf Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 22 Jun 2022 15:52:57 +0900 Subject: [PATCH 05/42] Implemented _getSuggestedGasPrice for internal use in caver.klay.accounts --- .../caver-klay-accounts/src/index.js | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/caver-klay/caver-klay-accounts/src/index.js b/packages/caver-klay/caver-klay-accounts/src/index.js index 80889c4f..8b52e6d8 100644 --- a/packages/caver-klay/caver-klay-accounts/src/index.js +++ b/packages/caver-klay/caver-klay-accounts/src/index.js @@ -292,7 +292,7 @@ const Accounts = function Accounts(...args) { delete this.BatchRequest delete this.extend - const _klaytnCall = [rpc.getChainId, rpc.getGasPrice, rpc.getTransactionCount] + const _klaytnCall = [rpc.getChainId, rpc.getGasPrice, rpc.getTransactionCount, rpc.getHeader] // attach methods to this._klaytnCall this._klaytnCall = {} _.each(_klaytnCall, function(method) { @@ -393,6 +393,27 @@ Accounts.prototype._getRoleKey = function _getRoleKey(tx, account) { return key } +/** + * _getSuggestedGasPrice returns suggested gas price. + * This function will be used to set gasPrice field if that is omitted. + * Before common architecture does not support newly added transaction types. + * + * @method _getSuggestedGasPrice + * @return {string} + */ +Accounts.prototype._getSuggestedGasPrice = async function _getSuggestedGasPrice() { + const header = await this._klaytnCall.getHeader('latest') + const bf = utils.hexToNumber(header.baseFeePerGas || '0x0') + + // In before common architecture, ethereum typed transactions are not supported. + // So just depends on baseFeePerGas field in the header, + // return `baseFee * 2` or `gasPrice`. + if (bf > 0) return bf * 2 + + const gasPrice = await this._klaytnCall.getGasPrice() + return gasPrice +} + /** * create function creates random account with entropy. * @@ -888,7 +909,7 @@ Accounts.prototype.signTransaction = function signTransaction() { // Otherwise, get the missing info from the Klaytn Node return Promise.all([ isNot(tx.chainId) ? _this._klaytnCall.getChainId() : tx.chainId, - isNot(tx.gasPrice) ? _this._klaytnCall.getGasPrice() : tx.gasPrice, + isNot(tx.gasPrice) ? _this._getSuggestedGasPrice() : tx.gasPrice, isNot(tx.nonce) ? _this._klaytnCall.getTransactionCount(tx.from, 'pending') : tx.nonce, ]).then(function(args) { if (isNot(args[0]) || isNot(args[1]) || isNot(args[2])) { From 8e230f5969f4321d2ff80fd13cb3bc067c729be4 Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 23 Jun 2022 10:38:26 +0900 Subject: [PATCH 06/42] Supports dynamic base fee in the common architecture features --- packages/caver-core-method/src/index.js | 55 +- .../transactionTypes/abstractTransaction.js | 42 +- .../accountUpdate/accountUpdate.js | 2 +- .../feeDelegatedAccountUpdate.js | 2 +- .../feeDelegatedAccountUpdateWithRatio.js | 2 +- .../src/transactionTypes/cancel/cancel.js | 2 +- .../cancel/feeDelegatedCancel.js | 2 +- .../cancel/feeDelegatedCancelWithRatio.js | 2 +- .../chainDataAnchoring/chainDataAnchoring.js | 2 +- .../feeDelegatedChainDataAnchoring.js | 2 +- ...feeDelegatedChainDataAnchoringWithRatio.js | 2 +- .../ethereumAccessList.js | 2 +- .../ethereumDynamicFee.js | 10 +- .../legacyTransaction/legacyTransaction.js | 2 +- .../feeDelegatedSmartContractDeploy.js | 2 +- ...eeDelegatedSmartContractDeployWithRatio.js | 2 +- .../smartContractDeploy.js | 2 +- .../feeDelegatedSmartContractExecution.js | 2 +- ...elegatedSmartContractExecutionWithRatio.js | 2 +- .../smartContractExecution.js | 2 +- .../feeDelegatedValueTransfer.js | 2 +- .../feeDelegatedValueTransferWithRatio.js | 2 +- .../valueTransfer/valueTransfer.js | 2 +- .../feeDelegatedValueTransferMemo.js | 2 +- .../feeDelegatedValueTransferMemoWithRatio.js | 2 +- .../valueTransferMemo/valueTransferMemo.js | 2 +- test/dynamicBaseFee.js | 571 ++++++++++++++++++ 27 files changed, 680 insertions(+), 44 deletions(-) create mode 100644 test/dynamicBaseFee.js diff --git a/packages/caver-core-method/src/index.js b/packages/caver-core-method/src/index.js index 22d9838d..533c162f 100644 --- a/packages/caver-core-method/src/index.js +++ b/packages/caver-core-method/src/index.js @@ -449,7 +449,7 @@ const buildSendRequestFunc = (defer, sendSignedTx, sendTxCallback) => (payload, return method.requestManager.send(payload, sendTxCallback) } -const buildSendFunc = (method, isSendTx) => (...args) => { +const buildSendFunc = (method, isSendTx) => async (...args) => { const defer = utils.promiEvent(!isSendTx) const payload = method.toPayload(args) @@ -459,27 +459,66 @@ const buildSendFunc = (method, isSendTx) => (...args) => { const isGasPriceInputMissing = isSendTx && _.isObject(payload.params[0]) && payload.params[0].gasPrice === undefined - // If gasPrice input is missing, call getGasPrice rpc - if (!isGasPriceInputMissing) { + // The TxTypeEthereumDynamicFee transaction does not use the gasPrice field, + // so we need to check `maxPriorityFeePerGas` and `maxFeePerGas` field instead of `gasPrice`. + const isDynamicFeeTx = payload.params[0].type === TX_TYPE_STRING.TxTypeEthereumDynamicFee + const filledDynamicGasFeeTx = + isDynamicFeeTx && payload.params[0].maxPriorityFeePerGas !== undefined && payload.params[0].maxFeePerGas !== undefined + + // If gasPrice is missing, have to fill gasPrice field before sending tx + if (!isGasPriceInputMissing || filledDynamicGasFeeTx) { sendRequest(payload, method) return defer.eventEmitter } + const getHeader = new Method({ + name: 'getHeader', + call: 'klay_getHeaderByNumber', + params: 1, + }).createFunction(method.requestManager) + const getGasPrice = new Method({ name: 'getGasPrice', call: 'klay_gasPrice', params: 0, }).createFunction(method.requestManager) - getGasPrice((err, gasPrice) => { + const getMaxPriorityFeePerGas = new Method({ + name: 'getMaxPriorityFeePerGas', + call: 'klay_maxPriorityFeePerGas', + params: 0, + }).createFunction(method.requestManager) + + const header = await getHeader('latest') + const bf = utils.hexToNumber(header.baseFeePerGas || '0x0') + + // The baseFeePerGas is bigger than 0 means that Klaytn uses dynamic gas price. + if (bf > 0) { + if (!isDynamicFeeTx) { + payload.params[0].gasPrice = bf * 2 + } else { + // If maxFeePerGas is undefined, set maxFeePerGas with `baseFee * 2`. + payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || bf * 2 + // If maxPriorityFeePerGas is undefined, call `klay_maxPriorityFeePerGas`. + if (payload.params[0].maxPriorityFeePerGas === undefined) { + const maxPriorityFeePerGas = await getMaxPriorityFeePerGas() + payload.params[0].maxPriorityFeePerGas = maxPriorityFeePerGas + } + } + } else { + // If baseFeePerGas is not defined or 0, we need to use unit price for the `gasPrice` field. + const gp = await getGasPrice() // The TxTypeEthereumDynamicFee transaction does not use the gasPrice field, // so the gas price default is not set for TxTypeEthereumDynamicFee. - if (payload.params[0].type !== TX_TYPE_STRING.TxTypeEthereumDynamicFee) { - payload.params[0].gasPrice = gasPrice || payload.params[0].gasPrice + if (!isDynamicFeeTx) { + payload.params[0].gasPrice = payload.params[0].gasPrice || gp + } else { + payload.params[0].maxPriorityFeePerGas = payload.params[0].maxPriorityFeePerGas || gp + payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || gp } - sendRequest(payload, method) - }) + } + sendRequest(payload, method) /** * attaching `.on('receipt')` is possible by returning defer.eventEmitter */ diff --git a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js index fa4c5c62..ec63bde7 100644 --- a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js +++ b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js @@ -157,7 +157,7 @@ class AbstractTransaction { * Calls `klay_chainID` klay rpc call. * * @example - * const result = tx.getChainId() + * const result = await tx.getChainId() * * @return {string} chain id */ @@ -166,11 +166,40 @@ class AbstractTransaction { return chainId } + /** + * Returns a suggested gas price to use in the transaction. + * If `baseFee` is bigger than `0` in the header, + * then returns `baseFee * 2`. + * If not, calls `klay_gasPrice` to return unit price of the gas. + * + * @example + * const result = await tx.getSuggestedGasPrice() + * + * @return {string} gas price + */ + async getSuggestedGasPrice() { + const bfStr = await this.getBaseFee() + const baseFee = utils.hexToNumber(bfStr) + + let suggestedGasPrice + if (baseFee > 0) { + // After hard KIP-71 fork, set gasPrice (or maxFeePerGas) with baseFee * 2 + suggestedGasPrice = baseFee * 2 + suggestedGasPrice = utils.toHex(suggestedGasPrice) + } else { + // Before hard KIP-71 fork, set gasPrice (or maxFeePerGas) with gas unit price + suggestedGasPrice = await this.klaytnCall.getGasPrice() + } + return suggestedGasPrice + } + /** * Calls `klay_gasPrice` klay rpc call. + * Note that when Klaytn network use dynamic gas fee, + * you need to use `tx.getSuggestedGasPrice` function in the gasPrice field. * * @example - * const result = tx.getGasPrice() + * const result = await tx.getGasPrice() * * @return {string} gas price */ @@ -183,7 +212,7 @@ class AbstractTransaction { * Calls `klay_getTransactionCount` klay rpc call. * * @example - * const result = tx.getNonce('0x{from address}') + * const result = await tx.getNonce('0x{from address}') * * @return {string} nonce */ @@ -194,22 +223,23 @@ class AbstractTransaction { /** * Calls `klay_getHeaderByNumber` klay rpc call to get `baseFeePerGas` in header. + * If `baseFeePerGas` is not existed, returns '0x0'. * * @example - * const result = tx.getBaseFee() + * const result = await tx.getBaseFee() * * @return {string} base fee */ async getBaseFee() { const header = await this.klaytnCall.getHeaderByNumber('latest') - return header.baseFeePerGas + return header.baseFeePerGas || '0x0' } /** * Calls `klay_maxPriorityFeePerGas` klay rpc call. * * @example - * const result = tx.getMaxPriorityFeePerGas() + * const result = await tx.getMaxPriorityFeePerGas() * * @return {string} suggested max priority fee per gas */ diff --git a/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js b/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js index 91a267a2..4218e399 100644 --- a/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js +++ b/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js @@ -180,7 +180,7 @@ class AccountUpdate extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js index 747b8353..d7aaadc2 100644 --- a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js +++ b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js @@ -186,7 +186,7 @@ class FeeDelegatedAccountUpdate extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js index b1087df2..b2e10799 100644 --- a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js @@ -190,7 +190,7 @@ class FeeDelegatedAccountUpdateWithRatio extends AbstractFeeDelegatedWithRatioTr async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/cancel/cancel.js b/packages/caver-transaction/src/transactionTypes/cancel/cancel.js index 539042b1..70c67a0c 100644 --- a/packages/caver-transaction/src/transactionTypes/cancel/cancel.js +++ b/packages/caver-transaction/src/transactionTypes/cancel/cancel.js @@ -154,7 +154,7 @@ class Cancel extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js index 06965d1e..ad7fa530 100644 --- a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js +++ b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js @@ -159,7 +159,7 @@ class FeeDelegatedCancel extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js index 2b335024..f17cade6 100644 --- a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js @@ -164,7 +164,7 @@ class FeeDelegatedCancelWithRatio extends AbstractFeeDelegatedWithRatioTransacti async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js index 935aa03d..34f5d3c6 100644 --- a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js +++ b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js @@ -174,7 +174,7 @@ class ChainDataAnchoring extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js index 12c9ec47..79fd3b26 100644 --- a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js +++ b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js @@ -181,7 +181,7 @@ class FeeDelegatedChainDataAnchoring extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js index aa646f56..9e29eade 100644 --- a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js @@ -184,7 +184,7 @@ class FeeDelegatedChainDataAnchoringWithRatio extends AbstractFeeDelegatedWithRa async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js index 734e0dd2..81c31e38 100644 --- a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js +++ b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js @@ -373,7 +373,7 @@ class EthereumAccessList extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js index 96ddb68a..920f69d1 100644 --- a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js +++ b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js @@ -390,21 +390,17 @@ class EthereumDynamicFee extends AbstractTransaction { async fillTransaction() { const isNotMaxPriorityFeePerGas = isNot(this.maxPriorityFeePerGas) const isNotMaxFeePerGas = isNot(this.maxFeePerGas) - const [chainId, maxPriorityFeePerGas, nonce, baseFee] = await Promise.all([ + const [chainId, maxPriorityFeePerGas, nonce, maxFeePerGas] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, isNotMaxPriorityFeePerGas ? this.getMaxPriorityFeePerGas() : this.maxPriorityFeePerGas, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, - isNotMaxPriorityFeePerGas || isNotMaxFeePerGas ? this.getBaseFee() : undefined, + isNotMaxFeePerGas ? this.getSuggestedGasPrice() : this.maxFeePerGas, ]) this.chainId = chainId this.nonce = nonce this.maxPriorityFeePerGas = maxPriorityFeePerGas - - // Set maxFeePerGas with `block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas)` - if (isNotMaxFeePerGas) { - this.maxFeePerGas = utils.hexToNumber(baseFee) * 2 + utils.hexToNumber(this.maxPriorityFeePerGas) - } + this.maxFeePerGas = maxFeePerGas } /** diff --git a/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js b/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js index beab96c4..b15ba88d 100644 --- a/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js +++ b/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js @@ -268,7 +268,7 @@ class LegacyTransaction extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js index fc522db9..42140aa9 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js @@ -260,7 +260,7 @@ class FeeDelegatedSmartContractDeploy extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js index ec9d2133..6bcd90c6 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js @@ -275,7 +275,7 @@ class FeeDelegatedSmartContractDeployWithRatio extends AbstractFeeDelegatedWithR async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js index eb4d3b24..9604f929 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js @@ -254,7 +254,7 @@ class SmartContractDeploy extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js index ee5e03e3..fae3ca67 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js @@ -226,7 +226,7 @@ class FeeDelegatedSmartContractExecution extends AbstractFeeDelegatedTransaction async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js index 85be8e4e..172e94ec 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js @@ -229,7 +229,7 @@ class FeeDelegatedSmartContractExecutionWithRatio extends AbstractFeeDelegatedWi async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js b/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js index c87e5948..22b7d868 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js @@ -219,7 +219,7 @@ class SmartContractExecution extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js index aae47966..68aad344 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js @@ -193,7 +193,7 @@ class FeeDelegatedValueTransfer extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js index c4982916..8c590e87 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js @@ -196,7 +196,7 @@ class FeeDelegatedValueTransferWithRatio extends AbstractFeeDelegatedWithRatioTr async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js b/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js index b77ced0c..2bbc54cf 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js @@ -187,7 +187,7 @@ class ValueTransfer extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js index f7cb3192..64a31b51 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js @@ -224,7 +224,7 @@ class FeeDelegatedValueTransferMemo extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js index 09ea66ea..53212cc8 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js @@ -227,7 +227,7 @@ class FeeDelegatedValueTransferMemoWithRatio extends AbstractFeeDelegatedWithRat async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js index ea8d917a..1a9db895 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js @@ -217,7 +217,7 @@ class ValueTransferMemo extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/test/dynamicBaseFee.js b/test/dynamicBaseFee.js new file mode 100644 index 00000000..70dd7243 --- /dev/null +++ b/test/dynamicBaseFee.js @@ -0,0 +1,571 @@ +/* + Copyright 2022 The caver-js Authors + This file is part of the caver-js library. + + The caver-js library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + The caver-js library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with the caver-js. If not, see . +*/ + +const { expect } = require('chai') + +const Caver = require('../index') +const testRPCURL = require('./testrpc') + +const { kip7JsonInterface, kip7ByteCode } = require('../packages/caver-kct/src/kctHelper') + +const caver = new Caver(testRPCURL) + +let sender +let feePayer +let password + +before(() => { + const senderPrvKey = + process.env.privateKey && String(process.env.privateKey).indexOf('0x') === -1 + ? `0x${process.env.privateKey}` + : process.env.privateKey + const feePayerPrvKey = + process.env.privateKey2 && String(process.env.privateKey2).indexOf('0x') === -1 + ? `0x${process.env.privateKey2}` + : process.env.privateKey2 + + // Add keyrings to `caver.wallet` (common architecture) + sender = caver.wallet.add(caver.wallet.keyring.createFromPrivateKey(senderPrvKey)) + feePayer = caver.wallet.add(caver.wallet.keyring.createFromPrivateKey(feePayerPrvKey)) + + // Add accounts to `caver.klay.accounts.wallet` (before common architecture) + caver.klay.accounts.wallet.add(senderPrvKey) + caver.klay.accounts.wallet.add(feePayerPrvKey) + + password = process.env.password ? process.env.password : 'password' +}) + +async function generateTxsBomb(num = 100) { + const txs = [] + const input = + '0x608060405234801561001057600080fd5b506101de806100206000396000f3006080604052600436106100615763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631a39d8ef81146100805780636353586b146100a757806370a08231146100ca578063fd6b7ef8146100f8575b3360009081526001602052604081208054349081019091558154019055005b34801561008c57600080fd5b5061009561010d565b60408051918252519081900360200190f35b6100c873ffffffffffffffffffffffffffffffffffffffff60043516610113565b005b3480156100d657600080fd5b5061009573ffffffffffffffffffffffffffffffffffffffff60043516610147565b34801561010457600080fd5b506100c8610159565b60005481565b73ffffffffffffffffffffffffffffffffffffffff1660009081526001602052604081208054349081019091558154019055565b60016020526000908152604090205481565b336000908152600160205260408120805490829055908111156101af57604051339082156108fc029083906000818181858888f193505050501561019c576101af565b3360009081526001602052604090208190555b505600a165627a7a72305820627ca46bb09478a015762806cc00c431230501118c7c26c30ac58c4e09e51c4f0029' + + let senderNonce = caver.utils.hexToNumber(await caver.rpc.klay.getTransactionCount(sender.address)) + for (let i = 0; i < num; i++) { + const tx = caver.transaction.smartContractDeploy.create({ + from: sender.address, + input, + gas: 10000000, + nonce: senderNonce, + }) + await caver.wallet.sign(sender.address, tx) + txs.push(tx.getRLPEncoding()) + senderNonce++ + } + + await Promise.all( + Object.keys(txs).map(async signedTx => { + caver.rpc.klay.sendRawTransaction(signedTx) + }) + ) +} + +async function validateGasFeeWithReceipt(receipt) { + const gasPriceInReceipt = caver.utils.hexToNumber(receipt.gasPrice) + const gasPriceAtParentBlock = await caver.rpc.klay.getGasPriceAt(caver.utilsl.hexToNumber(receipt.blockNumber) - 1) // Klaytn will return baseFee + const gasPriceAtReceiptBlock = await caver.rpc.klay.getGasPriceAt(receipt.blockNumber) // Klaytn will return baseFee + + // To process a transaction, the gasPrice of the tx should be equal or bigger than baseFee(effectiveGasPrice) + if (caver.utils.hexToNumber(receipt.effectiveGasPrice) > gasPriceInReceipt) return false + + // effectiveGasPrice should be defined by baseFee used gas price when tx is processed + if (receipt.effectiveGasPrice !== gasPriceAtReceiptBlock) return false + + // Set gasPrice with `baseFee * 2` + if (caver.utils.hexToNumber(gasPriceAtParentBlock) * 2 !== gasPriceInReceipt) return false + return true +} + +async function validateDynamicFeeTxWithReceipt(tx, receipt) { + const maxFeePerGas = caver.utils.hexToNumber(receipt.maxFeePerGas) + const gasPriceAtParentBlock = await caver.rpc.klay.getGasPriceAt(caver.utilsl.hexToNumber(receipt.blockNumber) - 1) // Klaytn will return baseFee + + // To process a transaction, the maxFeePerGas of the tx should be equal or bigger than baseFee(effectiveGasPrice) + if (caver.utils.hexToNumber(receipt.effectiveGasPrice) > maxFeePerGas) return false + + // Set gasPrice with `baseFee * 2` + if (caver.utils.hexToNumber(gasPriceAtParentBlock) * 2 !== maxFeePerGas) return false + return true +} + +async function validateGasPrice(tx) { + // Klaytn will return baseFee + const gasPriceAtCurrentBlock = caver.utils.hexToNumber(await caver.rpc.klay.getGasPrice()) + + // If transaction type is TxTypeEthereumDynamicFee, + // validate `maxPriorityFeePerGas` and `maxFeePerGas`. + if (tx.type.incldues('DynamicFee')) { + const maxPriorityFeePerGas = await caver.rpc.klay.getMaxPriorityFeePerGas() + if (tx.maxPriorityFeePerGas !== maxPriorityFeePerGas) return false + // maxFeePerGas will be set with `baseFee * 2`, so maxFeePerGas cannnot be smaller than current base fee + if (caver.utils.hexToNumber(tx.maxFeePerGas) < gasPriceAtCurrentBlock) return false + return true + } + + // gasPrice will be set with `baseFee * 2`, so gasPrice cannnot be smaller than current base fee + if (caver.utils.hexToNumber(tx.gasPrice) < gasPriceAtCurrentBlock) return false + return true +} + +describe('Have to set correct value optional fields named gasPrice, maxFeePerGas or maxPriorityFeePerGas', () => { + it('CAVERJS-UNIT-ETC-405: caver.contract operates with optional gasPrice value', async () => { + // Generate many txs to increase baseFee + await generateTxsBomb() + + // Deploy a contract without optional gasPrice field + const contract = caver.contract.create(kip7JsonInterface) + const receipt = await contract.deploy( + { + from: sender.address, + gas: 50000000, + contractDeployFormatter: receipt => { + return receipt + }, + }, + kip7ByteCode, + 'Jamie', + 'JME', + 18, + '10000000000000000' + ) + expect(receipt).not.to.be.undefined + expect(receipt.status).to.equal(true) + expect(receipt.contractAddress).not.to.be.undefined + let isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + + // Generate many txs to increase baseFee + await generateTxsBomb() + + // Execute a contract without optional gasPrice field + contract.options.address = receipt.contractAddress + const minterAddedReceipt = await contract.send( + { from: sender.address, gas: 50000000 }, + 'addMinter', + caver.wallet.keyring.generate().address + ) + expect(minterAddedReceipt).not.to.be.undefined + expect(minterAddedReceipt.status).to.equal(true) + expect(minterAddedReceipt.to).to.equal(receipt.contractAddress) + isValid = await validateGasFeeWithReceipt(minterAddedReceipt) + expect(isValid).to.be.true + + // Sign a transaction to execute the smart contract without optional gasPrice field (basic tx) + let signedTx = await contract.sign({ from: sender.address, gas: 50000000 }, 'addMinter', caver.wallet.keyring.generate().address) + expect(signedTx.type).to.equal('TxTypeSmartContractExecution') + expect(caver.utils.isEmptySig(signedTx.signatures)).to.be.false + isValid = await validateGasPrice(signedTx) + expect(isValid).to.be.true + + // Sign a transaction to execute the smart contract without optional gasPrice field (fd tx) + signedTx = await contract.sign( + { from: sender.address, gas: 50000000, feeDelegation: true }, + 'addMinter', + caver.wallet.keyring.generate().address + ) + expect(signedTx.type).to.equal('TxTypeFeeDelegatedSmartContractExecution') + expect(caver.utils.isEmptySig(signedTx.signatures)).to.be.false + isValid = await validateGasPrice(signedTx) + expect(isValid).to.be.true + + // Sign a transaction to execute the smart contract without optional gasPrice field (fdr tx) + signedTx = await contract.sign( + { from: sender.address, gas: 50000000, feeDelegation: true, feeRatio: 30 }, + 'addMinter', + caver.wallet.keyring.generate().address + ) + expect(signedTx.type).to.equal('TxTypeFeeDelegatedSmartContractExecutionWithRatio') + expect(caver.utils.isEmptySig(signedTx.signatures)).to.be.false + isValid = await validateGasPrice(signedTx) + expect(isValid).to.be.true + + // Sign a transaction as a fee payer to execute the smart contract without optional gasPrice field (fd tx) + signedTx = await contract.signAsFeePayer( + { from: sender.address, gas: 50000000, feeDelegation: true, feePayer: feePayer.address }, + 'addMinter', + caver.wallet.keyring.generate().address + ) + expect(signedTx.type).to.equal('TxTypeFeeDelegatedSmartContractExecution') + expect(caver.utils.isEmptySig(signedTx.feePayerSignatures)).to.be.false + isValid = await validateGasPrice(signedTx) + expect(isValid).to.be.true + + // Sign a transaction as a fee payer to execute the smart contract without optional gasPrice field (fdr tx) + signedTx = await contract.signAsFeePayer( + { from: sender.address, gas: 50000000, feeDelegation: true, feePayer: feePayer.address, feeRatio: 30 }, + 'addMinter', + caver.wallet.keyring.generate().address + ) + expect(signedTx.type).to.equal('TxTypeFeeDelegatedSmartContractExecutionWithRatio') + expect(caver.utils.isEmptySig(signedTx.feePayerSignatures)).to.be.false + isValid = await validateGasPrice(signedTx) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-ETC-406: caver.klay.Contract operates with optional gasPrice value', async () => { + // Generate many txs to increase baseFee + await generateTxsBomb() + + // Deploy a contract without optional gasPrice field + const contract = new caver.klay.Contract(kip7JsonInterface) + const receipt = await contract + .deploy({ + data: kip7ByteCode, + arguments: ['Jamie', 'JME', 18, '10000000000000000'], + }) + .send({ + from: sender.address, + gas: 50000000, + contractDeployFormatter: receipt => { + return receipt + }, + }) + expect(receipt).not.to.be.undefined + expect(receipt.status).to.equal(true) + expect(receipt.contractAddress).not.to.be.undefined + let isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + + // Generate many txs to increase baseFee + await generateTxsBomb() + + // Execute a contract without optional gasPrice field + contract.options.address = receipt.contractAddress + const minterAddedReceipt = await contract.methods + .addMinter(caver.wallet.keyring.generate().address) + .send({ from: sender.address, gas: 50000000 }) + expect(minterAddedReceipt).not.to.be.undefined + expect(minterAddedReceipt.status).to.equal(true) + expect(minterAddedReceipt.to).to.equal(receipt.contractAddress) + isValid = await validateGasFeeWithReceipt(minterAddedReceipt) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-TRANSACTION-556: caver.transaction sign and signAsFeePayer signs with optional gasPrice value', async () => { + // Generate many txs to increase baseFee + await generateTxsBomb() + + // Test transaction.sign with basic tx + let tx = caver.transaction.valueTransfer.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + }) + await tx.sign(sender) + let isValid = await validateGasPrice(tx) + expect(isValid).to.be.true + let receipt = await caver.rpc.klay.sendRawTransaction(tx) + isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + + // Test transaction.signAsFeePayer with fee delegation tx + tx = caver.transaction.feeDelegatedValueTransfer.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + feePayer: feePayer.address, + }) + await tx.signAsFeePayer(feePayer) + await tx.sign(sender) + isValid = await validateGasPrice(tx) + expect(isValid).to.be.true + receipt = await caver.rpc.klay.sendRawTransaction(tx) + isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + + // Test transaction.sign with ethereum dynamic fee tx + tx = caver.transaction.ethereumDynamicFee.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 900000, + accessList: [], + }) + await tx.sign(sender) + isValid = await validateGasPrice(tx) + expect(isValid).to.be.true + receipt = await caver.rpc.klay.sendRawTransaction(tx) + isValid = await validateDynamicFeeTxWithReceipt(receipt) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-WALLET-431: caver.wallet sign and signAsFeePayer signs with optional gasPrice value', async () => { + // Generate many txs to increase baseFee + await generateTxsBomb() + + // Test caver.wallet.sign with basic tx + let tx = caver.transaction.valueTransfer.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + }) + await caver.wallet.sign(sender.address, tx) + let isValid = await validateGasPrice(tx) + expect(isValid).to.be.true + let receipt = await caver.rpc.klay.sendRawTransaction(tx) + isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + + // Test caver.wallet.signAsFeePayer with fee delegation tx + tx = caver.transaction.feeDelegatedValueTransfer.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + feePayer: feePayer.address, + }) + await caver.wallet.signAsFeePayer(feePayer.address, tx) + await caver.wallet.sign(sender.address, tx) + isValid = await validateGasPrice(tx) + expect(isValid).to.be.true + receipt = await caver.rpc.klay.sendRawTransaction(tx) + isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + + // Test caver.wallet.sign with ethereum dynamic fee tx + tx = caver.transaction.ethereumDynamicFee.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 900000, + accessList: [], + }) + await caver.wallet.sign(sender.address, tx) + isValid = await validateGasPrice(tx) + expect(isValid).to.be.true + receipt = await caver.rpc.klay.sendRawTransaction(tx) + isValid = await validateDynamicFeeTxWithReceipt(receipt) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-RPC-030: caver.rpc.klay.sendTransaction sends a tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { + // Generate many txs to increase baseFee + await generateTxsBomb() + + const isUnlock = await caver.klay.personal.unlockAccount(sender.address, password) + expect(isUnlock).to.be.true + + let tx = caver.transaction.valueTransfer.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + }) + let receipt = await caver.rpc.klay.sendTransaction(tx) + let isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + + tx = caver.transaction.ethereumDynamicFee.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 900000, + accessList: [], + }) + receipt = await caver.rpc.klay.sendTransaction(tx) + isValid = await validateDynamicFeeTxWithReceipt(receipt) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-RPC-031: caver.rpc.klay.sendTransactionAsFeepayer sends a fee delegation tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { + // Generate many txs to increase baseFee + await generateTxsBomb() + + const isUnlock = await caver.klay.personal.unlockAccount(feePayer.address, password) + expect(isUnlock).to.be.true + + const tx = caver.transaction.feeDelegatedValueTransfer.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + feePayer: feePayer.address, + }) + await caver.wallet.sign(sender, tx) + const receipt = await caver.rpc.klay.sendTransactionAsFeePayer(tx) + const isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-RPC-032: caver.rpc.klay.signTransaction signs a tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { + const isUnlock = await caver.klay.personal.unlockAccount(sender.address, password) + expect(isUnlock).to.be.true + + let tx = caver.transaction.valueTransfer.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + }) + let signed = await caver.rpc.klay.signTransaction(tx) + let decodedTx = caver.transaction.decode(signed.raw) + let isValid = await validateGasPrice(decodedTx) + expect(isValid).to.be.true + + tx = caver.transaction.ethereumDynamicFee.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 900000, + accessList: [], + }) + signed = await caver.rpc.klay.signTransaction(tx) + decodedTx = caver.transaction.decode(signed.raw) + isValid = await validateGasPrice(decodedTx) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-RPC-033: caver.rpc.klay.signTransactionAsFeepayer signs a fee delegation tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { + const isUnlock = await caver.klay.personal.unlockAccount(feePayer.address, password) + expect(isUnlock).to.be.true + + const tx = caver.transaction.feeDelegatedValueTransfer.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + feePayer: feePayer.address, + }) + const signed = await caver.rpc.klay.sendTransactionAsFeepayer(tx) + const decodedTx = caver.transaction.decode(signed.raw) + const isValid = await validateGasPrice(decodedTx) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-WALLET-432: caver.klay.accounts.signTransaction signs with optional gasPrice value', async () => { + const tx = { + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + } + const senderAccount = caver.klay.accounts.wallet[sender.address] + const signed = await caver.klay.accounts.signTransaction(tx, senderAccount.privateKey) + const decodedTx = caver.transaction.decode(signed.rawTransaction) + let isValid = await validateGasPrice(decodedTx) + expect(isValid).to.be.true + const receipt = await caver.rpc.klay.sendRawTransaction(signed.rawTransaction) + isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-WALLET-433: caver.klay.accounts.feePayerSignTransaction signs as fee payer with optional gasPrice value', async () => { + const tx = { + type: 'FEE_DELEGATED_VALUE_TRANSFER', + from: sender.address, + feePayer: feePayer.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + } + const feePayerAccount = caver.klay.accounts.wallet[feePayer.address] + const signed = await caver.klay.accounts.feePayerSignTransaction(tx, feePayerAccount.privateKey) + const decodedTx = caver.transaction.decode(signed.rawTransaction) + const isValid = await validateGasPrice(decodedTx) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-ETC-407: caver.klay.personal.sendTransaction sends a tx with optional gasPrice value', async () => { + // Generate many txs to increase baseFee + await generateTxsBomb() + + let tx = caver.transaction.valueTransfer.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + }) + let receipt = await caver.klay.personal.sendTransaction(tx, password) + let isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + + tx = caver.transaction.ethereumDynamicFee.create({ + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + accessList: [], + }) + receipt = await caver.klay.personal.sendTransaction(tx, password) + isValid = await validateDynamicFeeTxWithReceipt(receipt) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-ETC-408: caver.klay.personal.sendValueTransfer sends a value transfer tx with optional gasPrice value', async () => { + // Generate many txs to increase baseFee + await generateTxsBomb() + + const receipt = await caver.klay.personal.sendValueTransfer( + { + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + }, + password + ) + const isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-ETC-409: caver.klay.personal.sendAccountUpdate sends a value transfer tx with optional gasPrice value', async () => { + // Generate many txs to increase baseFee + await generateTxsBomb() + + const receipt = await caver.klay.personal.sendAccountUpdate( + { + from: sender.address, + gas: 2500000, + key: '0x01c0', + }, + password + ) + const isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + }).timeout(100000) + + it('CAVERJS-UNIT-RPC-034: caver.klay.sendTransaction sends a tx with optional gasPrice value', async () => { + // Sign a tx with an account in the in-memory wallet and send to network. + let tx = { + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + } + let receipt = await caver.klay.sendTransaction(tx) + let isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + + // Remove an account from in-memory wallet to send tx with keystore in the Node. + caver.klay.accounts.wallet.remove(sender.address) + const isUnlock = await caver.klay.personal.unlockAccount(sender.address, password) + expect(isUnlock).to.be.true + tx = { + from: sender.address, + to: caver.wallet.keyring.generate().address, + value: 1, + gas: 2500000, + } + receipt = await caver.klay.sendTransaction(tx) + isValid = await validateGasFeeWithReceipt(receipt) + expect(isValid).to.be.true + }).timeout(100000) +}) From 62a71b582b34806b7d719cbeabc020d4013fe13c Mon Sep 17 00:00:00 2001 From: Jamie Date: Mon, 27 Jun 2022 10:27:39 +0900 Subject: [PATCH 07/42] Fixed lint error --- test/dynamicBaseFee.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/dynamicBaseFee.js b/test/dynamicBaseFee.js index 70dd7243..84ec4ac5 100644 --- a/test/dynamicBaseFee.js +++ b/test/dynamicBaseFee.js @@ -133,8 +133,8 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas { from: sender.address, gas: 50000000, - contractDeployFormatter: receipt => { - return receipt + contractDeployFormatter: r => { + return r }, }, kip7ByteCode, @@ -231,8 +231,8 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas .send({ from: sender.address, gas: 50000000, - contractDeployFormatter: receipt => { - return receipt + contractDeployFormatter: r => { + return r }, }) expect(receipt).not.to.be.undefined From f8bc956863a048fc42cbf6609c5fda1540288c42 Mon Sep 17 00:00:00 2001 From: Jamie Date: Mon, 27 Jun 2022 11:25:20 +0900 Subject: [PATCH 08/42] Fixed test error --- packages/caver-core-method/src/index.js | 2 +- .../caver.transaction/ethereumDynamicFee.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/caver-core-method/src/index.js b/packages/caver-core-method/src/index.js index 533c162f..eea968e1 100644 --- a/packages/caver-core-method/src/index.js +++ b/packages/caver-core-method/src/index.js @@ -461,7 +461,7 @@ const buildSendFunc = (method, isSendTx) => async (...args) => { // The TxTypeEthereumDynamicFee transaction does not use the gasPrice field, // so we need to check `maxPriorityFeePerGas` and `maxFeePerGas` field instead of `gasPrice`. - const isDynamicFeeTx = payload.params[0].type === TX_TYPE_STRING.TxTypeEthereumDynamicFee + const isDynamicFeeTx = isSendTx && payload.params[0].type === TX_TYPE_STRING.TxTypeEthereumDynamicFee const filledDynamicGasFeeTx = isDynamicFeeTx && payload.params[0].maxPriorityFeePerGas !== undefined && payload.params[0].maxFeePerGas !== undefined diff --git a/test/packages/caver.transaction/ethereumDynamicFee.js b/test/packages/caver.transaction/ethereumDynamicFee.js index 71958e6c..cbdbff75 100644 --- a/test/packages/caver.transaction/ethereumDynamicFee.js +++ b/test/packages/caver.transaction/ethereumDynamicFee.js @@ -906,7 +906,7 @@ describe('TxTypeEthereumDynamicFee', () => { await tx.fillTransaction() expect(getMaxPriorityFeePerGasSpy).to.have.been.calledOnce - expect(getHeaderByNumberSpy).to.have.been.calledOnce + expect(getHeaderByNumberSpy).not.to.have.been.calledOnce // getHeader only when maxFeePerGas is empty to get baseFee. expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -915,9 +915,14 @@ describe('TxTypeEthereumDynamicFee', () => { transactionObj.nonce = '0x3a' delete transactionObj.maxFeePerGas const tx = caver.transaction.ethereumDynamicFee.create(transactionObj) - const expectedMaxFeePerGas = utils.toHex( - utils.hexToNumber(baseFee) * 2 + utils.hexToNumber(transactionObj.maxPriorityFeePerGas) - ) + + let expectedMaxFeePerGas + const latestHeader = await caver.rpc.klay.getHeaderByNumber('latest') + if (latestHeader.baseFeePerGas && caver.utils.hexToNumber(latestHeader.baseFeePerGas) > 0) { + expectedMaxFeePerGas = caver.utils.toHex(caver.utils.hexToNumber(latestHeader.baseFeePerGas) * 2) + } else { + expectedMaxFeePerGas = await caver.rpc.klay.getGasPrice() + } await tx.fillTransaction() From 16c26603aab18c045a0cb0267b2143dabfcf7af6 Mon Sep 17 00:00:00 2001 From: Jamie <32922423+jimni1222@users.noreply.github.com> Date: Mon, 27 Jun 2022 16:03:47 +0800 Subject: [PATCH 09/42] Update packages/caver-core-method/src/index.js Co-authored-by: Denver --- packages/caver-core-method/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/caver-core-method/src/index.js b/packages/caver-core-method/src/index.js index eea968e1..238fb4fc 100644 --- a/packages/caver-core-method/src/index.js +++ b/packages/caver-core-method/src/index.js @@ -465,7 +465,7 @@ const buildSendFunc = (method, isSendTx) => async (...args) => { const filledDynamicGasFeeTx = isDynamicFeeTx && payload.params[0].maxPriorityFeePerGas !== undefined && payload.params[0].maxFeePerGas !== undefined - // If gasPrice is missing, have to fill gasPrice field before sending tx + // gasPrice is already set so it is ok to send transaction. if (!isGasPriceInputMissing || filledDynamicGasFeeTx) { sendRequest(payload, method) return defer.eventEmitter From 4dc316da29297607f955493f5ad68e7625bf5ebc Mon Sep 17 00:00:00 2001 From: Jamie <32922423+jimni1222@users.noreply.github.com> Date: Mon, 27 Jun 2022 16:03:51 +0800 Subject: [PATCH 10/42] Update packages/caver-core-method/src/index.js Co-authored-by: Denver --- packages/caver-core-method/src/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/caver-core-method/src/index.js b/packages/caver-core-method/src/index.js index 238fb4fc..c73fe299 100644 --- a/packages/caver-core-method/src/index.js +++ b/packages/caver-core-method/src/index.js @@ -471,6 +471,7 @@ const buildSendFunc = (method, isSendTx) => async (...args) => { return defer.eventEmitter } + // gasPrice is missing, have to fill gasPrice field before sending tx const getHeader = new Method({ name: 'getHeader', call: 'klay_getHeaderByNumber', From 179a3f723f382910127522ee67efa45b72c0eb82 Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 29 Jun 2022 16:00:42 +0900 Subject: [PATCH 11/42] Changed method name to suggestedGasPrice --- packages/caver-klay/caver-klay-accounts/src/index.js | 8 ++++---- .../src/transactionTypes/abstractTransaction.js | 6 +++--- .../src/transactionTypes/accountUpdate/accountUpdate.js | 2 +- .../accountUpdate/feeDelegatedAccountUpdate.js | 2 +- .../accountUpdate/feeDelegatedAccountUpdateWithRatio.js | 2 +- .../src/transactionTypes/cancel/cancel.js | 2 +- .../src/transactionTypes/cancel/feeDelegatedCancel.js | 2 +- .../cancel/feeDelegatedCancelWithRatio.js | 2 +- .../chainDataAnchoring/chainDataAnchoring.js | 2 +- .../chainDataAnchoring/feeDelegatedChainDataAnchoring.js | 2 +- .../feeDelegatedChainDataAnchoringWithRatio.js | 2 +- .../ethereumTypedTransaction/ethereumAccessList.js | 2 +- .../ethereumTypedTransaction/ethereumDynamicFee.js | 2 +- .../legacyTransaction/legacyTransaction.js | 2 +- .../feeDelegatedSmartContractDeploy.js | 2 +- .../feeDelegatedSmartContractDeployWithRatio.js | 2 +- .../smartContractDeploy/smartContractDeploy.js | 2 +- .../feeDelegatedSmartContractExecution.js | 2 +- .../feeDelegatedSmartContractExecutionWithRatio.js | 2 +- .../smartContractExecution/smartContractExecution.js | 2 +- .../valueTransfer/feeDelegatedValueTransfer.js | 2 +- .../valueTransfer/feeDelegatedValueTransferWithRatio.js | 2 +- .../src/transactionTypes/valueTransfer/valueTransfer.js | 2 +- .../valueTransferMemo/feeDelegatedValueTransferMemo.js | 2 +- .../feeDelegatedValueTransferMemoWithRatio.js | 2 +- .../valueTransferMemo/valueTransferMemo.js | 2 +- 26 files changed, 31 insertions(+), 31 deletions(-) diff --git a/packages/caver-klay/caver-klay-accounts/src/index.js b/packages/caver-klay/caver-klay-accounts/src/index.js index 8b52e6d8..9871b84e 100644 --- a/packages/caver-klay/caver-klay-accounts/src/index.js +++ b/packages/caver-klay/caver-klay-accounts/src/index.js @@ -394,14 +394,14 @@ Accounts.prototype._getRoleKey = function _getRoleKey(tx, account) { } /** - * _getSuggestedGasPrice returns suggested gas price. + * _suggestedGasPrice returns suggested gas price. * This function will be used to set gasPrice field if that is omitted. * Before common architecture does not support newly added transaction types. * - * @method _getSuggestedGasPrice + * @method _suggestedGasPrice * @return {string} */ -Accounts.prototype._getSuggestedGasPrice = async function _getSuggestedGasPrice() { +Accounts.prototype._suggestedGasPrice = async function _suggestedGasPrice() { const header = await this._klaytnCall.getHeader('latest') const bf = utils.hexToNumber(header.baseFeePerGas || '0x0') @@ -909,7 +909,7 @@ Accounts.prototype.signTransaction = function signTransaction() { // Otherwise, get the missing info from the Klaytn Node return Promise.all([ isNot(tx.chainId) ? _this._klaytnCall.getChainId() : tx.chainId, - isNot(tx.gasPrice) ? _this._getSuggestedGasPrice() : tx.gasPrice, + isNot(tx.gasPrice) ? _this._suggestedGasPrice() : tx.gasPrice, isNot(tx.nonce) ? _this._klaytnCall.getTransactionCount(tx.from, 'pending') : tx.nonce, ]).then(function(args) { if (isNot(args[0]) || isNot(args[1]) || isNot(args[2])) { diff --git a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js index ec63bde7..d16d613f 100644 --- a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js +++ b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js @@ -173,11 +173,11 @@ class AbstractTransaction { * If not, calls `klay_gasPrice` to return unit price of the gas. * * @example - * const result = await tx.getSuggestedGasPrice() + * const result = await tx.suggestedGasPrice() * * @return {string} gas price */ - async getSuggestedGasPrice() { + async suggestedGasPrice() { const bfStr = await this.getBaseFee() const baseFee = utils.hexToNumber(bfStr) @@ -196,7 +196,7 @@ class AbstractTransaction { /** * Calls `klay_gasPrice` klay rpc call. * Note that when Klaytn network use dynamic gas fee, - * you need to use `tx.getSuggestedGasPrice` function in the gasPrice field. + * you need to use `tx.suggestedGasPrice` function in the gasPrice field. * * @example * const result = await tx.getGasPrice() diff --git a/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js b/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js index 4218e399..2594767f 100644 --- a/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js +++ b/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js @@ -180,7 +180,7 @@ class AccountUpdate extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js index d7aaadc2..2da42c59 100644 --- a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js +++ b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js @@ -186,7 +186,7 @@ class FeeDelegatedAccountUpdate extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js index b2e10799..6497df56 100644 --- a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js @@ -190,7 +190,7 @@ class FeeDelegatedAccountUpdateWithRatio extends AbstractFeeDelegatedWithRatioTr async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/cancel/cancel.js b/packages/caver-transaction/src/transactionTypes/cancel/cancel.js index 70c67a0c..e7a235fb 100644 --- a/packages/caver-transaction/src/transactionTypes/cancel/cancel.js +++ b/packages/caver-transaction/src/transactionTypes/cancel/cancel.js @@ -154,7 +154,7 @@ class Cancel extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js index ad7fa530..52eebe35 100644 --- a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js +++ b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js @@ -159,7 +159,7 @@ class FeeDelegatedCancel extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js index f17cade6..e8d668f1 100644 --- a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js @@ -164,7 +164,7 @@ class FeeDelegatedCancelWithRatio extends AbstractFeeDelegatedWithRatioTransacti async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js index 34f5d3c6..ba6d9885 100644 --- a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js +++ b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js @@ -174,7 +174,7 @@ class ChainDataAnchoring extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js index 79fd3b26..6abc7058 100644 --- a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js +++ b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js @@ -181,7 +181,7 @@ class FeeDelegatedChainDataAnchoring extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js index 9e29eade..be43dfe6 100644 --- a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js @@ -184,7 +184,7 @@ class FeeDelegatedChainDataAnchoringWithRatio extends AbstractFeeDelegatedWithRa async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js index 81c31e38..123cbbec 100644 --- a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js +++ b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js @@ -373,7 +373,7 @@ class EthereumAccessList extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js index 920f69d1..820279c2 100644 --- a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js +++ b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js @@ -394,7 +394,7 @@ class EthereumDynamicFee extends AbstractTransaction { isNot(this.chainId) ? this.getChainId() : this.chainId, isNotMaxPriorityFeePerGas ? this.getMaxPriorityFeePerGas() : this.maxPriorityFeePerGas, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, - isNotMaxFeePerGas ? this.getSuggestedGasPrice() : this.maxFeePerGas, + isNotMaxFeePerGas ? this.suggestedGasPrice() : this.maxFeePerGas, ]) this.chainId = chainId diff --git a/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js b/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js index b15ba88d..62a65327 100644 --- a/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js +++ b/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js @@ -268,7 +268,7 @@ class LegacyTransaction extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js index 42140aa9..4f3572dd 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js @@ -260,7 +260,7 @@ class FeeDelegatedSmartContractDeploy extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js index 6bcd90c6..002fa8d9 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js @@ -275,7 +275,7 @@ class FeeDelegatedSmartContractDeployWithRatio extends AbstractFeeDelegatedWithR async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js index 9604f929..22c3bc23 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js @@ -254,7 +254,7 @@ class SmartContractDeploy extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js index fae3ca67..1bf52e76 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js @@ -226,7 +226,7 @@ class FeeDelegatedSmartContractExecution extends AbstractFeeDelegatedTransaction async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js index 172e94ec..76cb2432 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js @@ -229,7 +229,7 @@ class FeeDelegatedSmartContractExecutionWithRatio extends AbstractFeeDelegatedWi async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js b/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js index 22b7d868..1e72cafa 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js @@ -219,7 +219,7 @@ class SmartContractExecution extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js index 68aad344..162d0f40 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js @@ -193,7 +193,7 @@ class FeeDelegatedValueTransfer extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js index 8c590e87..ae041cf3 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js @@ -196,7 +196,7 @@ class FeeDelegatedValueTransferWithRatio extends AbstractFeeDelegatedWithRatioTr async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js b/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js index 2bbc54cf..c351f345 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js @@ -187,7 +187,7 @@ class ValueTransfer extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js index 64a31b51..bebef412 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js @@ -224,7 +224,7 @@ class FeeDelegatedValueTransferMemo extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js index 53212cc8..a5b2a091 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js @@ -227,7 +227,7 @@ class FeeDelegatedValueTransferMemoWithRatio extends AbstractFeeDelegatedWithRat async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js index 1a9db895..cdfba575 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js @@ -217,7 +217,7 @@ class ValueTransferMemo extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.getSuggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) From 80943911c1a2e453dec0097fe74e658de6cf6fd3 Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 5 Jul 2022 13:19:59 +0900 Subject: [PATCH 12/42] Fixed mistypo --- test/dynamicBaseFee.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/dynamicBaseFee.js b/test/dynamicBaseFee.js index 84ec4ac5..bc55e30a 100644 --- a/test/dynamicBaseFee.js +++ b/test/dynamicBaseFee.js @@ -77,7 +77,7 @@ async function generateTxsBomb(num = 100) { async function validateGasFeeWithReceipt(receipt) { const gasPriceInReceipt = caver.utils.hexToNumber(receipt.gasPrice) - const gasPriceAtParentBlock = await caver.rpc.klay.getGasPriceAt(caver.utilsl.hexToNumber(receipt.blockNumber) - 1) // Klaytn will return baseFee + const gasPriceAtParentBlock = await caver.rpc.klay.getGasPriceAt(caver.utils.hexToNumber(receipt.blockNumber) - 1) // Klaytn will return baseFee const gasPriceAtReceiptBlock = await caver.rpc.klay.getGasPriceAt(receipt.blockNumber) // Klaytn will return baseFee // To process a transaction, the gasPrice of the tx should be equal or bigger than baseFee(effectiveGasPrice) @@ -93,7 +93,7 @@ async function validateGasFeeWithReceipt(receipt) { async function validateDynamicFeeTxWithReceipt(tx, receipt) { const maxFeePerGas = caver.utils.hexToNumber(receipt.maxFeePerGas) - const gasPriceAtParentBlock = await caver.rpc.klay.getGasPriceAt(caver.utilsl.hexToNumber(receipt.blockNumber) - 1) // Klaytn will return baseFee + const gasPriceAtParentBlock = await caver.rpc.klay.getGasPriceAt(caver.utils.hexToNumber(receipt.blockNumber) - 1) // Klaytn will return baseFee // To process a transaction, the maxFeePerGas of the tx should be equal or bigger than baseFee(effectiveGasPrice) if (caver.utils.hexToNumber(receipt.effectiveGasPrice) > maxFeePerGas) return false From 970c5da4260efcff783723d6979dd89677bc6f47 Mon Sep 17 00:00:00 2001 From: Tony Lee <52311277+iv0rish@users.noreply.github.com> Date: Wed, 6 Jul 2022 15:51:53 +0900 Subject: [PATCH 13/42] Create CLA pipeline --- .github/workflows/CLA.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/CLA.yml diff --git a/.github/workflows/CLA.yml b/.github/workflows/CLA.yml new file mode 100644 index 00000000..642800c2 --- /dev/null +++ b/.github/workflows/CLA.yml @@ -0,0 +1,23 @@ +name: "CLA Assistant" +on: + issue_comment: + types: [created] + pull_request_target: + types: [opened, closed, synchronize] + +jobs: + CLAssistant: + runs-on: ubuntu-latest + steps: + - name: "CLA Assistant" + if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' + uses: cla-assistant/github-action@v2.1.3-beta + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_PERSONAL_ACCESS_TOKEN }} + with: + path-to-signatures: "signatures/version1/cla.json" + path-to-document: "https://gist.github.com/e78f99e1c527225637e269cff1bc7e49" # Klaytn Gist + branch: "master" + allowlist: dependabot[bot] + remote-repository-name: ${{ secrets.CLA_REPOSITORY }} From 1b8c43d349a02a0ae70643c589185168bf84a3e2 Mon Sep 17 00:00:00 2001 From: Tony Lee <52311277+iv0rish@users.noreply.github.com> Date: Wed, 6 Jul 2022 19:28:28 +0900 Subject: [PATCH 14/42] Modify signature path --- .github/workflows/CLA.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CLA.yml b/.github/workflows/CLA.yml index 642800c2..a744544b 100644 --- a/.github/workflows/CLA.yml +++ b/.github/workflows/CLA.yml @@ -16,7 +16,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_PERSONAL_ACCESS_TOKEN }} with: - path-to-signatures: "signatures/version1/cla.json" + path-to-signatures: "${{ github.event.repository.name }}/signatures/version1/cla.json" path-to-document: "https://gist.github.com/e78f99e1c527225637e269cff1bc7e49" # Klaytn Gist branch: "master" allowlist: dependabot[bot] From 86fd21be6f55f5fe79c0f0e64fdb49d0b9dcc6cb Mon Sep 17 00:00:00 2001 From: Jamie Date: Thu, 7 Jul 2022 10:55:18 +0900 Subject: [PATCH 15/42] Format to hex string with filled gas price values --- packages/caver-core-method/src/index.js | 26 +++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/caver-core-method/src/index.js b/packages/caver-core-method/src/index.js index c73fe299..52accafe 100644 --- a/packages/caver-core-method/src/index.js +++ b/packages/caver-core-method/src/index.js @@ -457,11 +457,17 @@ const buildSendFunc = (method, isSendTx) => async (...args) => { const sendSignedTx = buildSendSignedTxFunc(method, payload, sendTxCallback) const sendRequest = buildSendRequestFunc(defer, sendSignedTx, sendTxCallback) - const isGasPriceInputMissing = isSendTx && _.isObject(payload.params[0]) && payload.params[0].gasPrice === undefined + // isSendTx can determine only for "send"Transaction request. + // For sign transaction request, we also need to fill up the optional values. + const isSignTx = method.name.includes('signTransaction') + let isGasPriceInputMissing = false + if ((isSendTx || isSignTx) && _.isObject(payload.params[0]) && payload.params[0].gasPrice === undefined) { + isGasPriceInputMissing = true + } // The TxTypeEthereumDynamicFee transaction does not use the gasPrice field, // so we need to check `maxPriorityFeePerGas` and `maxFeePerGas` field instead of `gasPrice`. - const isDynamicFeeTx = isSendTx && payload.params[0].type === TX_TYPE_STRING.TxTypeEthereumDynamicFee + const isDynamicFeeTx = (isSendTx || isSignTx) && payload.params[0].type === TX_TYPE_STRING.TxTypeEthereumDynamicFee const filledDynamicGasFeeTx = isDynamicFeeTx && payload.params[0].maxPriorityFeePerGas !== undefined && payload.params[0].maxFeePerGas !== undefined @@ -519,6 +525,8 @@ const buildSendFunc = (method, isSendTx) => async (...args) => { } } + // Format gas price parameters(gasPrice, maxPriorityFeePerGas, maxFeePerGas) + formatGasParametersToHex(payload.params[0]) sendRequest(payload, method) /** * attaching `.on('receipt')` is possible by returning defer.eventEmitter @@ -526,6 +534,20 @@ const buildSendFunc = (method, isSendTx) => async (...args) => { return defer.eventEmitter } +// A function to change the format to a hex string after randomly filling the default gasPrice value +// with the API (personal_sendValueTransfer, personal_sendAccountUpdate) that does not use a transaction object. +function formatGasParametersToHex(txObject) { + if (txObject.gasPrice !== undefined && !utils.isHexStrict(txObject.gasPrice)) { + txObject.gasPrice = utils.toHex(txObject.gasPrice) + } + if (txObject.maxPriorityFeePerGas !== undefined && !utils.isHexStrict(txObject.maxPriorityFeePerGas)) { + txObject.maxPriorityFeePerGas = utils.toHex(txObject.maxPriorityFeePerGas) + } + if (txObject.maxFeePerGas !== undefined && !utils.isHexStrict(txObject.maxFeePerGas)) { + txObject.maxFeePerGas = utils.toHex(txObject.maxFeePerGas) + } +} + function buildCall() { const method = this const isSendTx = From 793eaf03c7b213269cf1c126bf1737000b86d891 Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 8 Jul 2022 09:29:42 +0900 Subject: [PATCH 16/42] Fixed testing errors with dynamic base fee --- package.json | 2 +- packages/caver-core-method/src/index.js | 2 +- test/dynamicBaseFee.js | 118 +- test/getTransactionReceipt.js | 8 +- .../caver.transaction/accountUpdate.js | 8 +- test/packages/caver.transaction/cancel.js | 8 +- .../caver.transaction/chainDataAnchoring.js | 8 +- .../caver.transaction/ethereumAccessList.js | 6 +- .../caver.transaction/ethereumDynamicFee.js | 10 +- .../feeDelegatedAccountUpdate.js | 8 +- .../feeDelegatedAccountUpdateWithRatio.js | 8 +- .../caver.transaction/feeDelegatedCancel.js | 8 +- .../feeDelegatedCancelWIthRatio.js | 8 +- .../feeDelegatedChainDataAnchoring.js | 8 +- ...feeDelegatedChainDataAnchoringWithRatio.js | 8 +- .../feeDelegatedSmartContractDeploy.js | 8 +- ...eeDelegatedSmartContractDeployWithRatio.js | 8 +- .../feeDelegatedSmartContractExecution.js | 8 +- ...elegatedSmartContractExecutionWithRatio.js | 8 +- .../feeDelegatedValueTransfer.js | 8 +- .../feeDelegatedValueTransferMemo.js | 8 +- .../feeDelegatedValueTransferMemoWithRatio.js | 8 +- .../feeDelegatedValueTransferWithRatio.js | 8 +- .../caver.transaction/legacyTransaction.js | 8 +- .../caver.transaction/smartContractDeploy.js | 8 +- .../smartContractExecution.js | 8 +- .../caver.transaction/valueTransfer.js | 8 +- .../caver.transaction/valueTransferMemo.js | 8 +- test/sendSignedTransaction.js | 217 +- test/transactionType/accountCreation.js | 2004 ----------------- test/transactionType/accountUpdate.js | 248 +- test/transactionType/cancelTransaction.js | 70 +- test/transactionType/contractDeploy.js | 74 +- test/transactionType/contractExecution.js | 86 +- .../feeDelegatedAccountUpdate.js | 272 +-- .../feeDelegatedAccountUpdateWithRatio.js | 262 +-- .../feeDelegatedCancelTransaction.js | 70 +- .../feeDelegatedCancelTransactionWithRatio.js | 76 +- .../feeDelegatedContractDeploy.js | 68 +- .../feeDelegatedContractDeployWithRatio.js | 66 +- .../feeDelegatedContractExecution.js | 66 +- .../feeDelegatedContractExecutionWithRatio.js | 66 +- .../feeDelegatedValueTransfer.js | 76 +- .../feeDelegatedValueTransferMemo.js | 74 +- .../feeDelegatedValueTransferMemoWithRatio.js | 74 +- .../feeDelegatedValueTransferWithRatio.js | 74 +- test/transactionType/legacyTransaction.js | 66 +- test/transactionType/valueTransfer.js | 74 +- test/transactionType/valueTransferWithMemo.js | 74 +- 49 files changed, 1283 insertions(+), 3196 deletions(-) delete mode 100644 test/transactionType/accountCreation.js diff --git a/package.json b/package.json index 74292be4..74f1744c 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "txUnitTest": "./node_modules/mocha/bin/mocha test/packages/caver.transaction/*.js && ./node_modules/mocha/bin/mocha test/createTest.js", "etcUnitTest": "./node_modules/mocha/bin/mocha test/decodeFunctionCall.js && ./node_modules/mocha/bin/mocha test/contractError.js && ./node_modules/mocha/bin/mocha test/contractOverloading.js && ./node_modules/mocha/bin/mocha ./test/contract.setWallet.js && ./node_modules/mocha/bin/mocha ./test/setRequestManager.js && ./node_modules/mocha/bin/mocha test/reconnectTest.js && ./node_modules/mocha/bin/mocha test/hashMessage.js && ./node_modules/mocha/bin/mocha test/iban.* && ./node_modules/mocha/bin/mocha test/randomHex.js && ./node_modules/mocha/bin/mocha test/sha3.js && ./node_modules/mocha/bin/mocha test/toChecksumAddress.js && ./node_modules/mocha/bin/mocha test/default*&& ./node_modules/mocha/bin/mocha test/getNodeInfo.js && ./node_modules/mocha/bin/mocha test/getNetworkType.js && ./node_modules/mocha/bin/mocha test/isContractDeployment.js && ./node_modules/mocha/bin/mocha test/multiProviderTest.js && ./node_modules/mocha/bin/mocha test/unitMap.js && ./node_modules/mocha/bin/mocha test/invalidResponse.js && ./node_modules/mocha/bin/mocha test/createTest.js && ./node_modules/mocha/bin/mocha test/setProvider.js && ./node_modules/mocha/bin/mocha test/contractOverloading.js && ./node_modules/mocha/bin/mocha test/supportsSubscriptions.js && ./node_modules/mocha/bin/mocha test/packages/caver.abi.js", "rpcTest": "./node_modules/mocha/bin/mocha test/packages/caver.rpc.js", - "txTest": "./node_modules/mocha/bin/mocha test/methodErrorHandling.js && ./node_modules/mocha/bin/mocha test/sendSignedTransaction.js && ./node_modules/mocha/bin/mocha test/estimateComputationCost.js && ./node_modules/mocha/bin/mocha test/getTransactionReceipt.js && ./node_modules/mocha/bin/mocha test/setNonceWithPendingTag.js && ./node_modules/mocha/bin/mocha test/getTransaction.js && ./node_modules/mocha/bin/mocha test/setContractOptions.js && ./node_modules/mocha/bin/mocha test/encodeContractDeploy.js && ./node_modules/mocha/bin/mocha test/accounts.signTransaction.js && ./node_modules/mocha/bin/mocha test/sendTransactionCallback.js && ./node_modules/mocha/bin/mocha test/signWithMultiSig.js && ./node_modules/mocha/bin/mocha test/transactionType/legacyTransaction.js && ./node_modules/mocha/bin/mocha test/transactionType/valueTransfer* && ./node_modules/mocha/bin/mocha test/transactionType/accountUpdate.js && ./node_modules/mocha/bin/mocha test/transactionType/contract* && ./node_modules/mocha/bin/mocha test/transactionType/cancelTransaction.js && ./node_modules/mocha/bin/mocha test/transactionType/feeDelegated*", + "txTest": "./node_modules/mocha/bin/mocha test/dynamicBaseFee.js && ./node_modules/mocha/bin/mocha test/methodErrorHandling.js && ./node_modules/mocha/bin/mocha test/sendSignedTransaction.js && ./node_modules/mocha/bin/mocha test/estimateComputationCost.js && ./node_modules/mocha/bin/mocha test/getTransactionReceipt.js && ./node_modules/mocha/bin/mocha test/setNonceWithPendingTag.js && ./node_modules/mocha/bin/mocha test/getTransaction.js && ./node_modules/mocha/bin/mocha test/setContractOptions.js && ./node_modules/mocha/bin/mocha test/encodeContractDeploy.js && ./node_modules/mocha/bin/mocha test/accounts.signTransaction.js && ./node_modules/mocha/bin/mocha test/sendTransactionCallback.js && ./node_modules/mocha/bin/mocha test/signWithMultiSig.js && ./node_modules/mocha/bin/mocha test/transactionType/*", "etcTest": "./node_modules/mocha/bin/mocha ./test/packages/caver.contract.js && ./node_modules/mocha/bin/mocha ./test/tupleTest.js && ./node_modules/mocha/bin/mocha test/confirmationListener.js && ./node_modules/mocha/bin/mocha test/eventEmitter.js && ./node_modules/mocha/bin/mocha test/personal.js && ./node_modules/mocha/bin/mocha test/subscription.js && ./node_modules/mocha/bin/mocha test/contract.once.js && ./node_modules/mocha/bin/mocha test/ipfsTest.js", "accountKeyTest": "./node_modules/mocha/bin/mocha test/scenarioTest/accountKeyPublic.js && ./node_modules/mocha/bin/mocha test/scenarioTest/accountKeyMultiSig.js && ./node_modules/mocha/bin/mocha test/scenarioTest/accountKeyRoleBased.js", "kctTest": "./node_modules/mocha/bin/mocha test/packages/caver.klay.KIP7.js && ./node_modules/mocha/bin/mocha test/packages/caver.klay.KIP17.js && ./node_modules/mocha/bin/mocha test/packages/caver.kct.kip37.js && ./node_modules/mocha/bin/mocha test/createTest.js", diff --git a/packages/caver-core-method/src/index.js b/packages/caver-core-method/src/index.js index 52accafe..fb631c98 100644 --- a/packages/caver-core-method/src/index.js +++ b/packages/caver-core-method/src/index.js @@ -534,7 +534,7 @@ const buildSendFunc = (method, isSendTx) => async (...args) => { return defer.eventEmitter } -// A function to change the format to a hex string after randomly filling the default gasPrice value +// A function to change the format to a hex string after randomly filling the default gasPrice value // with the API (personal_sendValueTransfer, personal_sendAccountUpdate) that does not use a transaction object. function formatGasParametersToHex(txObject) { if (txObject.gasPrice !== undefined && !utils.isHexStrict(txObject.gasPrice)) { diff --git a/test/dynamicBaseFee.js b/test/dynamicBaseFee.js index bc55e30a..cc53818d 100644 --- a/test/dynamicBaseFee.js +++ b/test/dynamicBaseFee.js @@ -50,56 +50,76 @@ before(() => { password = process.env.password ? process.env.password : 'password' }) -async function generateTxsBomb(num = 100) { - const txs = [] +async function fillKlay(amount) { + const filled = caver.wallet.keyring.generate() + + const tx = caver.transaction.valueTransfer.create({ + from: sender.address, + to: filled.address, + gas: 10000000, + value: caver.utils.convertToPeb(amount, 'KLAY'), + }) + await caver.wallet.sign(sender.address, tx) + await caver.rpc.klay.sendRawTransaction(tx) + + return filled +} + +async function generateTxsBomb(generator, num = 2000) { const input = '0x608060405234801561001057600080fd5b506101de806100206000396000f3006080604052600436106100615763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631a39d8ef81146100805780636353586b146100a757806370a08231146100ca578063fd6b7ef8146100f8575b3360009081526001602052604081208054349081019091558154019055005b34801561008c57600080fd5b5061009561010d565b60408051918252519081900360200190f35b6100c873ffffffffffffffffffffffffffffffffffffffff60043516610113565b005b3480156100d657600080fd5b5061009573ffffffffffffffffffffffffffffffffffffffff60043516610147565b34801561010457600080fd5b506100c8610159565b60005481565b73ffffffffffffffffffffffffffffffffffffffff1660009081526001602052604081208054349081019091558154019055565b60016020526000908152604090205481565b336000908152600160205260408120805490829055908111156101af57604051339082156108fc029083906000818181858888f193505050501561019c576101af565b3360009081526001602052604090208190555b505600a165627a7a72305820627ca46bb09478a015762806cc00c431230501118c7c26c30ac58c4e09e51c4f0029' - let senderNonce = caver.utils.hexToNumber(await caver.rpc.klay.getTransactionCount(sender.address)) + caver.wallet.add(generator) + + let senderNonce = caver.utils.hexToNumber(await caver.rpc.klay.getTransactionCount(generator.address, 'pending')) for (let i = 0; i < num; i++) { const tx = caver.transaction.smartContractDeploy.create({ - from: sender.address, + from: generator.address, input, gas: 10000000, nonce: senderNonce, }) - await caver.wallet.sign(sender.address, tx) - txs.push(tx.getRLPEncoding()) + await caver.wallet.sign(generator.address, tx) + caver.rpc.klay.sendRawTransaction(tx) senderNonce++ } - - await Promise.all( - Object.keys(txs).map(async signedTx => { - caver.rpc.klay.sendRawTransaction(signedTx) - }) - ) } async function validateGasFeeWithReceipt(receipt) { const gasPriceInReceipt = caver.utils.hexToNumber(receipt.gasPrice) - const gasPriceAtParentBlock = await caver.rpc.klay.getGasPriceAt(caver.utils.hexToNumber(receipt.blockNumber) - 1) // Klaytn will return baseFee const gasPriceAtReceiptBlock = await caver.rpc.klay.getGasPriceAt(receipt.blockNumber) // Klaytn will return baseFee + // console.log(`gasPriceInReceipt: ${gasPriceInReceipt} / gasPriceAtReceiptBlock: ${caver.utils.hexToNumber(gasPriceAtReceiptBlock)}`) // To process a transaction, the gasPrice of the tx should be equal or bigger than baseFee(effectiveGasPrice) - if (caver.utils.hexToNumber(receipt.effectiveGasPrice) > gasPriceInReceipt) return false + if (caver.utils.hexToNumber(receipt.effectiveGasPrice) > gasPriceInReceipt) { + // console.log(`caver.utils.hexToNumber(receipt.effectiveGasPrice)(${caver.utils.hexToNumber(receipt.effectiveGasPrice)}) > gasPriceInReceipt(${gasPriceInReceipt})`) + return false + } // effectiveGasPrice should be defined by baseFee used gas price when tx is processed - if (receipt.effectiveGasPrice !== gasPriceAtReceiptBlock) return false + if (receipt.effectiveGasPrice !== gasPriceAtReceiptBlock) { + // console.log(`receipt.effectiveGasPrice(${receipt.effectiveGasPrice}) !== gasPriceAtReceiptBlock(${gasPriceAtReceiptBlock})`) + return false + } - // Set gasPrice with `baseFee * 2` - if (caver.utils.hexToNumber(gasPriceAtParentBlock) * 2 !== gasPriceInReceipt) return false + // Set gasPrice with `baseFee * 2`, so should be bigger than gas price of the block + if (caver.utils.hexToNumber(gasPriceAtReceiptBlock) > gasPriceInReceipt) { + // console.log(`gasPriceAtReceiptBlock(${caver.utils.hexToNumber(gasPriceAtReceiptBlock)}) < gasPriceInReceipt(${gasPriceInReceipt})`) + return false + } return true } -async function validateDynamicFeeTxWithReceipt(tx, receipt) { +async function validateDynamicFeeTxWithReceipt(receipt) { const maxFeePerGas = caver.utils.hexToNumber(receipt.maxFeePerGas) - const gasPriceAtParentBlock = await caver.rpc.klay.getGasPriceAt(caver.utils.hexToNumber(receipt.blockNumber) - 1) // Klaytn will return baseFee + const gasPriceAtReceiptBlock = await caver.rpc.klay.getGasPriceAt(receipt.blockNumber) // Klaytn will return baseFee + // console.log(`maxFeePerGas: ${maxFeePerGas} / gasPriceAtReceiptBlock: ${caver.utils.hexToNumber(gasPriceAtReceiptBlock)}`) // To process a transaction, the maxFeePerGas of the tx should be equal or bigger than baseFee(effectiveGasPrice) if (caver.utils.hexToNumber(receipt.effectiveGasPrice) > maxFeePerGas) return false // Set gasPrice with `baseFee * 2` - if (caver.utils.hexToNumber(gasPriceAtParentBlock) * 2 !== maxFeePerGas) return false + if (caver.utils.hexToNumber(gasPriceAtReceiptBlock) > maxFeePerGas) return false return true } @@ -109,7 +129,7 @@ async function validateGasPrice(tx) { // If transaction type is TxTypeEthereumDynamicFee, // validate `maxPriorityFeePerGas` and `maxFeePerGas`. - if (tx.type.incldues('DynamicFee')) { + if (tx.type.includes('DynamicFee')) { const maxPriorityFeePerGas = await caver.rpc.klay.getMaxPriorityFeePerGas() if (tx.maxPriorityFeePerGas !== maxPriorityFeePerGas) return false // maxFeePerGas will be set with `baseFee * 2`, so maxFeePerGas cannnot be smaller than current base fee @@ -125,7 +145,7 @@ async function validateGasPrice(tx) { describe('Have to set correct value optional fields named gasPrice, maxFeePerGas or maxPriorityFeePerGas', () => { it('CAVERJS-UNIT-ETC-405: caver.contract operates with optional gasPrice value', async () => { // Generate many txs to increase baseFee - await generateTxsBomb() + generateTxsBomb(await fillKlay(100)) // Deploy a contract without optional gasPrice field const contract = caver.contract.create(kip7JsonInterface) @@ -150,7 +170,7 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas expect(isValid).to.be.true // Generate many txs to increase baseFee - await generateTxsBomb() + generateTxsBomb(await fillKlay(100)) // Execute a contract without optional gasPrice field contract.options.address = receipt.contractAddress @@ -161,7 +181,7 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas ) expect(minterAddedReceipt).not.to.be.undefined expect(minterAddedReceipt.status).to.equal(true) - expect(minterAddedReceipt.to).to.equal(receipt.contractAddress) + expect(minterAddedReceipt.to.toLowerCase()).to.equal(receipt.contractAddress.toLowerCase()) isValid = await validateGasFeeWithReceipt(minterAddedReceipt) expect(isValid).to.be.true @@ -219,7 +239,7 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas it('CAVERJS-UNIT-ETC-406: caver.klay.Contract operates with optional gasPrice value', async () => { // Generate many txs to increase baseFee - await generateTxsBomb() + generateTxsBomb(await fillKlay(100)) // Deploy a contract without optional gasPrice field const contract = new caver.klay.Contract(kip7JsonInterface) @@ -231,6 +251,7 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas .send({ from: sender.address, gas: 50000000, + value: 0, contractDeployFormatter: r => { return r }, @@ -242,7 +263,7 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas expect(isValid).to.be.true // Generate many txs to increase baseFee - await generateTxsBomb() + generateTxsBomb(await fillKlay(100)) // Execute a contract without optional gasPrice field contract.options.address = receipt.contractAddress @@ -251,14 +272,14 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas .send({ from: sender.address, gas: 50000000 }) expect(minterAddedReceipt).not.to.be.undefined expect(minterAddedReceipt.status).to.equal(true) - expect(minterAddedReceipt.to).to.equal(receipt.contractAddress) + expect(minterAddedReceipt.to.toLowerCase()).to.equal(receipt.contractAddress.toLowerCase()) isValid = await validateGasFeeWithReceipt(minterAddedReceipt) expect(isValid).to.be.true }).timeout(100000) it('CAVERJS-UNIT-TRANSACTION-556: caver.transaction sign and signAsFeePayer signs with optional gasPrice value', async () => { // Generate many txs to increase baseFee - await generateTxsBomb() + generateTxsBomb(await fillKlay(100)) // Test transaction.sign with basic tx let tx = caver.transaction.valueTransfer.create({ @@ -308,7 +329,7 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas it('CAVERJS-UNIT-WALLET-431: caver.wallet sign and signAsFeePayer signs with optional gasPrice value', async () => { // Generate many txs to increase baseFee - await generateTxsBomb() + generateTxsBomb(await fillKlay(100)) // Test caver.wallet.sign with basic tx let tx = caver.transaction.valueTransfer.create({ @@ -358,7 +379,7 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas it('CAVERJS-UNIT-RPC-030: caver.rpc.klay.sendTransaction sends a tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { // Generate many txs to increase baseFee - await generateTxsBomb() + generateTxsBomb(await fillKlay(100)) const isUnlock = await caver.klay.personal.unlockAccount(sender.address, password) expect(isUnlock).to.be.true @@ -387,7 +408,7 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas it('CAVERJS-UNIT-RPC-031: caver.rpc.klay.sendTransactionAsFeepayer sends a fee delegation tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { // Generate many txs to increase baseFee - await generateTxsBomb() + generateTxsBomb(await fillKlay(100)) const isUnlock = await caver.klay.personal.unlockAccount(feePayer.address, password) expect(isUnlock).to.be.true @@ -399,13 +420,16 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas gas: 2500000, feePayer: feePayer.address, }) - await caver.wallet.sign(sender, tx) + await caver.wallet.sign(sender.address, tx) const receipt = await caver.rpc.klay.sendTransactionAsFeePayer(tx) const isValid = await validateGasFeeWithReceipt(receipt) expect(isValid).to.be.true }).timeout(100000) it('CAVERJS-UNIT-RPC-032: caver.rpc.klay.signTransaction signs a tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { + // Generate many txs to increase baseFee + generateTxsBomb(await fillKlay(100)) + const isUnlock = await caver.klay.personal.unlockAccount(sender.address, password) expect(isUnlock).to.be.true @@ -434,6 +458,9 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas }).timeout(100000) it('CAVERJS-UNIT-RPC-033: caver.rpc.klay.signTransactionAsFeepayer signs a fee delegation tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { + // Generate many txs to increase baseFee + generateTxsBomb(await fillKlay(100)) + const isUnlock = await caver.klay.personal.unlockAccount(feePayer.address, password) expect(isUnlock).to.be.true @@ -444,13 +471,16 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas gas: 2500000, feePayer: feePayer.address, }) - const signed = await caver.rpc.klay.sendTransactionAsFeepayer(tx) + const signed = await caver.rpc.klay.signTransactionAsFeePayer(tx) const decodedTx = caver.transaction.decode(signed.raw) const isValid = await validateGasPrice(decodedTx) expect(isValid).to.be.true }).timeout(100000) it('CAVERJS-UNIT-WALLET-432: caver.klay.accounts.signTransaction signs with optional gasPrice value', async () => { + // Generate many txs to increase baseFee + generateTxsBomb(await fillKlay(100)) + const tx = { from: sender.address, to: caver.wallet.keyring.generate().address, @@ -468,6 +498,9 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas }).timeout(100000) it('CAVERJS-UNIT-WALLET-433: caver.klay.accounts.feePayerSignTransaction signs as fee payer with optional gasPrice value', async () => { + // Generate many txs to increase baseFee + generateTxsBomb(await fillKlay(100)) + const tx = { type: 'FEE_DELEGATED_VALUE_TRANSFER', from: sender.address, @@ -477,15 +510,15 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas gas: 2500000, } const feePayerAccount = caver.klay.accounts.wallet[feePayer.address] - const signed = await caver.klay.accounts.feePayerSignTransaction(tx, feePayerAccount.privateKey) + const signed = await caver.klay.accounts.feePayerSignTransaction(tx, feePayer.address, feePayerAccount.privateKey) const decodedTx = caver.transaction.decode(signed.rawTransaction) const isValid = await validateGasPrice(decodedTx) expect(isValid).to.be.true }).timeout(100000) - it('CAVERJS-UNIT-ETC-407: caver.klay.personal.sendTransaction sends a tx with optional gasPrice value', async () => { + it('CAVERJS-UNIT-ETC-407: caver.klay.personal.sendTransaction sends a tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { // Generate many txs to increase baseFee - await generateTxsBomb() + generateTxsBomb(await fillKlay(100)) let tx = caver.transaction.valueTransfer.create({ from: sender.address, @@ -509,9 +542,9 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas expect(isValid).to.be.true }).timeout(100000) - it('CAVERJS-UNIT-ETC-408: caver.klay.personal.sendValueTransfer sends a value transfer tx with optional gasPrice value', async () => { + it('CAVERJS-UNIT-ETC-408: caver.klay.personal.sendValueTransfer sends a value transfer tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { // Generate many txs to increase baseFee - await generateTxsBomb() + generateTxsBomb(await fillKlay(100)) const receipt = await caver.klay.personal.sendValueTransfer( { @@ -526,9 +559,9 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas expect(isValid).to.be.true }).timeout(100000) - it('CAVERJS-UNIT-ETC-409: caver.klay.personal.sendAccountUpdate sends a value transfer tx with optional gasPrice value', async () => { + it('CAVERJS-UNIT-ETC-409: caver.klay.personal.sendAccountUpdate sends a value transfer tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { // Generate many txs to increase baseFee - await generateTxsBomb() + generateTxsBomb(await fillKlay(100)) const receipt = await caver.klay.personal.sendAccountUpdate( { @@ -542,7 +575,10 @@ describe('Have to set correct value optional fields named gasPrice, maxFeePerGas expect(isValid).to.be.true }).timeout(100000) - it('CAVERJS-UNIT-RPC-034: caver.klay.sendTransaction sends a tx with optional gasPrice value', async () => { + it('CAVERJS-UNIT-RPC-034: caver.klay.sendTransaction sends a tx with optional gasPrice value (use keystore in Klaytn Node)', async () => { + // Generate many txs to increase baseFee + generateTxsBomb(await fillKlay(100)) + // Sign a tx with an account in the in-memory wallet and send to network. let tx = { from: sender.address, diff --git a/test/getTransactionReceipt.js b/test/getTransactionReceipt.js index d557e038..7813366a 100644 --- a/test/getTransactionReceipt.js +++ b/test/getTransactionReceipt.js @@ -16,6 +16,10 @@ along with the caver-js. If not, see . */ +const chai = require('chai') +const chaiAsPromised = require('chai-as-promised') + +chai.use(chaiAsPromised) const { expect } = require('chai') const Caver = require('../index') @@ -59,8 +63,8 @@ describe('get transaction receipt', () => { .catch(() => done()) }).timeout(100000) - it('should throw an error without parameter', () => { - expect(() => caver.klay.getTransactionReceipt()).to.throw() + it('should throw an error without parameter', async () => { + await expect(caver.klay.getTransactionReceipt()).to.be.rejected }).timeout(100000) it('CAVERJS-UNIT-TX-567 : After sending transction, getTransactionReceipt should return transaction infromation', async () => { diff --git a/test/packages/caver.transaction/accountUpdate.js b/test/packages/caver.transaction/accountUpdate.js index 72e980ed..53835ab7 100644 --- a/test/packages/caver.transaction/accountUpdate.js +++ b/test/packages/caver.transaction/accountUpdate.js @@ -265,6 +265,7 @@ before(() => { describe('TxTypeAccountUpdate', () => { let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy @@ -278,6 +279,8 @@ describe('TxTypeAccountUpdate', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1005,8 +1008,9 @@ describe('TxTypeAccountUpdate', () => { await tx.fillTransaction() expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce } - expect(getGasPriceSpy).to.have.been.callCount(Object.values(expectedValues).length) + expect(getHeaderSpy).to.have.been.callCount(Object.values(expectedValues).length) }).timeout(200000) it('CAVERJS-UNIT-TRANSACTION-196: fillTransaction should call klay_getTransactionCount to fill nonce when nonce is undefined', async () => { @@ -1016,6 +1020,7 @@ describe('TxTypeAccountUpdate', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce } expect(getNonceSpy).to.have.been.callCount(Object.values(expectedValues).length) @@ -1028,6 +1033,7 @@ describe('TxTypeAccountUpdate', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce } expect(getChainIdSpy).to.have.been.callCount(Object.values(expectedValues).length) diff --git a/test/packages/caver.transaction/cancel.js b/test/packages/caver.transaction/cancel.js index 60400fe0..ce868229 100644 --- a/test/packages/caver.transaction/cancel.js +++ b/test/packages/caver.transaction/cancel.js @@ -76,6 +76,7 @@ before(() => { describe('TxTypeCancel', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -87,6 +88,8 @@ describe('TxTypeCancel', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -699,7 +702,8 @@ describe('TxTypeCancel', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -710,6 +714,7 @@ describe('TxTypeCancel', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -720,6 +725,7 @@ describe('TxTypeCancel', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/chainDataAnchoring.js b/test/packages/caver.transaction/chainDataAnchoring.js index b9320651..90ec1d6b 100644 --- a/test/packages/caver.transaction/chainDataAnchoring.js +++ b/test/packages/caver.transaction/chainDataAnchoring.js @@ -81,6 +81,7 @@ before(() => { describe('TxTypeChainDataAnchoring', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -92,6 +93,8 @@ describe('TxTypeChainDataAnchoring', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -721,7 +724,8 @@ describe('TxTypeChainDataAnchoring', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -732,6 +736,7 @@ describe('TxTypeChainDataAnchoring', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -742,6 +747,7 @@ describe('TxTypeChainDataAnchoring', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/ethereumAccessList.js b/test/packages/caver.transaction/ethereumAccessList.js index 7e9007d7..a158b230 100644 --- a/test/packages/caver.transaction/ethereumAccessList.js +++ b/test/packages/caver.transaction/ethereumAccessList.js @@ -75,6 +75,7 @@ describe('TxTypeEthereumAccessList', () => { '0x7801f90109822710238505d21dba00829c4094c5fb1386b60160614a8151dcd4b0ae41325d1cb801b844a9059cbb0000000000000000000000008a4c9c443bb0645df646a2d5bb55def0ed1e885a0000000000000000000000000000000000000000000000000000000000003039f85bf859945430192ae264b3feff967fc08982b9c6f5694023f842a00000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000000701a05ac25e47591243af2d6b8e7f54d608e9e0e0aeb5194d34c17852bd7e376f4857a0095a40394f33e95cce9695d5badf4270f4cc8aff0b5395cefc3a0fe213be1f30' let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy @@ -119,6 +120,8 @@ describe('TxTypeEthereumAccessList', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -867,7 +870,8 @@ describe('TxTypeEthereumAccessList', () => { const tx = caver.transaction.ethereumAccessList.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/ethereumDynamicFee.js b/test/packages/caver.transaction/ethereumDynamicFee.js index cbdbff75..cdc6e5fe 100644 --- a/test/packages/caver.transaction/ethereumDynamicFee.js +++ b/test/packages/caver.transaction/ethereumDynamicFee.js @@ -127,7 +127,7 @@ describe('TxTypeEthereumDynamicFee', () => { getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') getChainIdSpy.returns('0x7e3') - baseFee = '0x0' + baseFee = '0x5d21dba00' getHeaderByNumberSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') getHeaderByNumberSpy.returns({ baseFeePerGas: baseFee }) maxPriorityFeePerGas = '0x5d21dba00' @@ -916,13 +916,7 @@ describe('TxTypeEthereumDynamicFee', () => { delete transactionObj.maxFeePerGas const tx = caver.transaction.ethereumDynamicFee.create(transactionObj) - let expectedMaxFeePerGas - const latestHeader = await caver.rpc.klay.getHeaderByNumber('latest') - if (latestHeader.baseFeePerGas && caver.utils.hexToNumber(latestHeader.baseFeePerGas) > 0) { - expectedMaxFeePerGas = caver.utils.toHex(caver.utils.hexToNumber(latestHeader.baseFeePerGas) * 2) - } else { - expectedMaxFeePerGas = await caver.rpc.klay.getGasPrice() - } + const expectedMaxFeePerGas = caver.utils.toHex(caver.utils.hexToNumber(baseFee) * 2) await tx.fillTransaction() diff --git a/test/packages/caver.transaction/feeDelegatedAccountUpdate.js b/test/packages/caver.transaction/feeDelegatedAccountUpdate.js index e26e835e..5a61f27b 100644 --- a/test/packages/caver.transaction/feeDelegatedAccountUpdate.js +++ b/test/packages/caver.transaction/feeDelegatedAccountUpdate.js @@ -330,6 +330,7 @@ before(() => { describe('TxTypeFeeDelegatedAccountUpdate', () => { let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy @@ -343,6 +344,8 @@ describe('TxTypeFeeDelegatedAccountUpdate', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1602,8 +1605,9 @@ describe('TxTypeFeeDelegatedAccountUpdate', () => { await tx.fillTransaction() expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce } - expect(getGasPriceSpy).to.have.been.callCount(Object.values(expectedValues).length) + expect(getHeaderSpy).to.have.been.callCount(Object.values(expectedValues).length) }).timeout(200000) it('CAVERJS-UNIT-TRANSACTIONFD-220: fillTransaction should call klay_getTransactionCount to fill nonce when nonce is undefined', async () => { @@ -1613,6 +1617,7 @@ describe('TxTypeFeeDelegatedAccountUpdate', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce } expect(getNonceSpy).to.have.been.callCount(Object.values(expectedValues).length) @@ -1625,6 +1630,7 @@ describe('TxTypeFeeDelegatedAccountUpdate', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce } expect(getChainIdSpy).to.have.been.callCount(Object.values(expectedValues).length) diff --git a/test/packages/caver.transaction/feeDelegatedAccountUpdateWithRatio.js b/test/packages/caver.transaction/feeDelegatedAccountUpdateWithRatio.js index d62c4195..df72e912 100644 --- a/test/packages/caver.transaction/feeDelegatedAccountUpdateWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedAccountUpdateWithRatio.js @@ -336,6 +336,7 @@ before(() => { describe('TxTypeFeeDelegatedAccountUpdateWithRatio', () => { let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy @@ -349,6 +350,8 @@ describe('TxTypeFeeDelegatedAccountUpdateWithRatio', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1640,8 +1643,9 @@ describe('TxTypeFeeDelegatedAccountUpdateWithRatio', () => { await tx.fillTransaction() expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce } - expect(getGasPriceSpy).to.have.been.callCount(Object.values(expectedValues).length) + expect(getHeaderSpy).to.have.been.callCount(Object.values(expectedValues).length) }).timeout(200000) it('CAVERJS-UNIT-TRANSACTIONFDR-223: fillTransaction should call klay_getTransactionCount to fill nonce when nonce is undefined', async () => { @@ -1651,6 +1655,7 @@ describe('TxTypeFeeDelegatedAccountUpdateWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce } expect(getNonceSpy).to.have.been.callCount(Object.values(expectedValues).length) @@ -1663,6 +1668,7 @@ describe('TxTypeFeeDelegatedAccountUpdateWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce } expect(getChainIdSpy).to.have.been.callCount(Object.values(expectedValues).length) diff --git a/test/packages/caver.transaction/feeDelegatedCancel.js b/test/packages/caver.transaction/feeDelegatedCancel.js index d6f4e5f7..f6800681 100644 --- a/test/packages/caver.transaction/feeDelegatedCancel.js +++ b/test/packages/caver.transaction/feeDelegatedCancel.js @@ -86,6 +86,7 @@ before(() => { describe('TxTypeFeeDelegatedCancel', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -97,6 +98,8 @@ describe('TxTypeFeeDelegatedCancel', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1175,7 +1178,8 @@ describe('TxTypeFeeDelegatedCancel', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1186,6 +1190,7 @@ describe('TxTypeFeeDelegatedCancel', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1196,6 +1201,7 @@ describe('TxTypeFeeDelegatedCancel', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedCancelWIthRatio.js b/test/packages/caver.transaction/feeDelegatedCancelWIthRatio.js index bd58113d..e3ce7ce8 100644 --- a/test/packages/caver.transaction/feeDelegatedCancelWIthRatio.js +++ b/test/packages/caver.transaction/feeDelegatedCancelWIthRatio.js @@ -86,6 +86,7 @@ before(() => { describe('TxTypeFeeDelegatedCancelWithRatio', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -98,6 +99,8 @@ describe('TxTypeFeeDelegatedCancelWithRatio', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1208,7 +1211,8 @@ describe('TxTypeFeeDelegatedCancelWithRatio', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1219,6 +1223,7 @@ describe('TxTypeFeeDelegatedCancelWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1229,6 +1234,7 @@ describe('TxTypeFeeDelegatedCancelWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedChainDataAnchoring.js b/test/packages/caver.transaction/feeDelegatedChainDataAnchoring.js index 37476c97..aea5c351 100644 --- a/test/packages/caver.transaction/feeDelegatedChainDataAnchoring.js +++ b/test/packages/caver.transaction/feeDelegatedChainDataAnchoring.js @@ -91,6 +91,7 @@ before(() => { describe('TxTypeFeeDelegatedChainDataAnchoring', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -102,6 +103,8 @@ describe('TxTypeFeeDelegatedChainDataAnchoring', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1187,7 +1190,8 @@ describe('TxTypeFeeDelegatedChainDataAnchoring', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1198,6 +1202,7 @@ describe('TxTypeFeeDelegatedChainDataAnchoring', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1208,6 +1213,7 @@ describe('TxTypeFeeDelegatedChainDataAnchoring', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedChainDataAnchoringWithRatio.js b/test/packages/caver.transaction/feeDelegatedChainDataAnchoringWithRatio.js index 162558b8..4945306d 100644 --- a/test/packages/caver.transaction/feeDelegatedChainDataAnchoringWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedChainDataAnchoringWithRatio.js @@ -92,6 +92,7 @@ before(() => { describe('TxTypeFeeDelegatedChainDataAnchoringWithRatio', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -104,6 +105,8 @@ describe('TxTypeFeeDelegatedChainDataAnchoringWithRatio', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1221,7 +1224,8 @@ describe('TxTypeFeeDelegatedChainDataAnchoringWithRatio', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1232,6 +1236,7 @@ describe('TxTypeFeeDelegatedChainDataAnchoringWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1242,6 +1247,7 @@ describe('TxTypeFeeDelegatedChainDataAnchoringWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedSmartContractDeploy.js b/test/packages/caver.transaction/feeDelegatedSmartContractDeploy.js index 8ccdab7e..6ad04563 100644 --- a/test/packages/caver.transaction/feeDelegatedSmartContractDeploy.js +++ b/test/packages/caver.transaction/feeDelegatedSmartContractDeploy.js @@ -94,6 +94,7 @@ before(() => { describe('TxTypeFeeDelegatedSmartContractDeploy', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -105,6 +106,8 @@ describe('TxTypeFeeDelegatedSmartContractDeploy', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1215,7 +1218,8 @@ describe('TxTypeFeeDelegatedSmartContractDeploy', () => { const tx = caver.transaction.feeDelegatedSmartContractDeploy.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1227,6 +1231,7 @@ describe('TxTypeFeeDelegatedSmartContractDeploy', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1238,6 +1243,7 @@ describe('TxTypeFeeDelegatedSmartContractDeploy', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedSmartContractDeployWithRatio.js b/test/packages/caver.transaction/feeDelegatedSmartContractDeployWithRatio.js index 6112f4fd..5351cfb8 100644 --- a/test/packages/caver.transaction/feeDelegatedSmartContractDeployWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedSmartContractDeployWithRatio.js @@ -95,6 +95,7 @@ before(() => { describe('TxTypeFeeDelegatedSmartContractDeployWithRatio', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -107,6 +108,8 @@ describe('TxTypeFeeDelegatedSmartContractDeployWithRatio', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1249,7 +1252,8 @@ describe('TxTypeFeeDelegatedSmartContractDeployWithRatio', () => { const tx = caver.transaction.feeDelegatedSmartContractDeployWithRatio.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1261,6 +1265,7 @@ describe('TxTypeFeeDelegatedSmartContractDeployWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1272,6 +1277,7 @@ describe('TxTypeFeeDelegatedSmartContractDeployWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedSmartContractExecution.js b/test/packages/caver.transaction/feeDelegatedSmartContractExecution.js index c3c73e56..15c2297b 100644 --- a/test/packages/caver.transaction/feeDelegatedSmartContractExecution.js +++ b/test/packages/caver.transaction/feeDelegatedSmartContractExecution.js @@ -91,6 +91,7 @@ before(() => { describe('TxTypeFeeDelegatedSmartContractExecution', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -103,6 +104,8 @@ describe('TxTypeFeeDelegatedSmartContractExecution', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1213,7 +1216,8 @@ describe('TxTypeFeeDelegatedSmartContractExecution', () => { const tx = caver.transaction.feeDelegatedSmartContractExecution.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1225,6 +1229,7 @@ describe('TxTypeFeeDelegatedSmartContractExecution', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1236,6 +1241,7 @@ describe('TxTypeFeeDelegatedSmartContractExecution', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedSmartContractExecutionWithRatio.js b/test/packages/caver.transaction/feeDelegatedSmartContractExecutionWithRatio.js index 5de1de9b..103c02d2 100644 --- a/test/packages/caver.transaction/feeDelegatedSmartContractExecutionWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedSmartContractExecutionWithRatio.js @@ -92,6 +92,7 @@ before(() => { describe('TxTypeFeeDelegatedSmartContractExecutionWithRatio', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -105,6 +106,8 @@ describe('TxTypeFeeDelegatedSmartContractExecutionWithRatio', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1247,7 +1250,8 @@ describe('TxTypeFeeDelegatedSmartContractExecutionWithRatio', () => { const tx = caver.transaction.feeDelegatedSmartContractExecutionWithRatio.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1259,6 +1263,7 @@ describe('TxTypeFeeDelegatedSmartContractExecutionWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1270,6 +1275,7 @@ describe('TxTypeFeeDelegatedSmartContractExecutionWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedValueTransfer.js b/test/packages/caver.transaction/feeDelegatedValueTransfer.js index eb7391d1..91c53c83 100644 --- a/test/packages/caver.transaction/feeDelegatedValueTransfer.js +++ b/test/packages/caver.transaction/feeDelegatedValueTransfer.js @@ -91,6 +91,7 @@ before(() => { describe('TxTypeFeeDelegatedValueTransfer', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -103,6 +104,8 @@ describe('TxTypeFeeDelegatedValueTransfer', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1213,7 +1216,8 @@ describe('TxTypeFeeDelegatedValueTransfer', () => { const tx = caver.transaction.feeDelegatedValueTransfer.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1225,6 +1229,7 @@ describe('TxTypeFeeDelegatedValueTransfer', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1236,6 +1241,7 @@ describe('TxTypeFeeDelegatedValueTransfer', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedValueTransferMemo.js b/test/packages/caver.transaction/feeDelegatedValueTransferMemo.js index 6edf54e2..04841c21 100644 --- a/test/packages/caver.transaction/feeDelegatedValueTransferMemo.js +++ b/test/packages/caver.transaction/feeDelegatedValueTransferMemo.js @@ -92,6 +92,7 @@ before(() => { describe('TxTypeFeeDelegatedValueTransferMemo', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -105,6 +106,8 @@ describe('TxTypeFeeDelegatedValueTransferMemo', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1221,7 +1224,8 @@ describe('TxTypeFeeDelegatedValueTransferMemo', () => { const tx = caver.transaction.feeDelegatedValueTransferMemo.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1233,6 +1237,7 @@ describe('TxTypeFeeDelegatedValueTransferMemo', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1244,6 +1249,7 @@ describe('TxTypeFeeDelegatedValueTransferMemo', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedValueTransferMemoWithRatio.js b/test/packages/caver.transaction/feeDelegatedValueTransferMemoWithRatio.js index e39220c1..b634c7d1 100644 --- a/test/packages/caver.transaction/feeDelegatedValueTransferMemoWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedValueTransferMemoWithRatio.js @@ -93,6 +93,7 @@ before(() => { describe('TxTypeFeeDelegatedValueTransferMemoWithRatio', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -107,6 +108,8 @@ describe('TxTypeFeeDelegatedValueTransferMemoWithRatio', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1255,7 +1258,8 @@ describe('TxTypeFeeDelegatedValueTransferMemoWithRatio', () => { const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1267,6 +1271,7 @@ describe('TxTypeFeeDelegatedValueTransferMemoWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1278,6 +1283,7 @@ describe('TxTypeFeeDelegatedValueTransferMemoWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedValueTransferWithRatio.js b/test/packages/caver.transaction/feeDelegatedValueTransferWithRatio.js index f0f4956d..5ba4ab6e 100644 --- a/test/packages/caver.transaction/feeDelegatedValueTransferWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedValueTransferWithRatio.js @@ -92,6 +92,7 @@ before(() => { describe('TxTypeFeeDelegatedValueTransferWithRatio', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -105,6 +106,8 @@ describe('TxTypeFeeDelegatedValueTransferWithRatio', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -1247,7 +1250,8 @@ describe('TxTypeFeeDelegatedValueTransferWithRatio', () => { const tx = caver.transaction.feeDelegatedValueTransferWithRatio.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1259,6 +1263,7 @@ describe('TxTypeFeeDelegatedValueTransferWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -1270,6 +1275,7 @@ describe('TxTypeFeeDelegatedValueTransferWithRatio', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/legacyTransaction.js b/test/packages/caver.transaction/legacyTransaction.js index af539ba4..c3b927fa 100644 --- a/test/packages/caver.transaction/legacyTransaction.js +++ b/test/packages/caver.transaction/legacyTransaction.js @@ -55,6 +55,7 @@ before(() => { describe('TxTypeLegacyTransaction', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -69,6 +70,8 @@ describe('TxTypeLegacyTransaction', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -774,7 +777,8 @@ describe('TxTypeLegacyTransaction', () => { const tx = caver.transaction.legacyTransaction.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -786,6 +790,7 @@ describe('TxTypeLegacyTransaction', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -797,6 +802,7 @@ describe('TxTypeLegacyTransaction', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/smartContractDeploy.js b/test/packages/caver.transaction/smartContractDeploy.js index a8ae52a2..ddff73e1 100644 --- a/test/packages/caver.transaction/smartContractDeploy.js +++ b/test/packages/caver.transaction/smartContractDeploy.js @@ -84,6 +84,7 @@ before(() => { describe('TxTypeSmartContractDeploy', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -95,6 +96,8 @@ describe('TxTypeSmartContractDeploy', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -737,7 +740,8 @@ describe('TxTypeSmartContractDeploy', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -748,6 +752,7 @@ describe('TxTypeSmartContractDeploy', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -758,6 +763,7 @@ describe('TxTypeSmartContractDeploy', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/smartContractExecution.js b/test/packages/caver.transaction/smartContractExecution.js index 2121c7d5..0a99cb8e 100644 --- a/test/packages/caver.transaction/smartContractExecution.js +++ b/test/packages/caver.transaction/smartContractExecution.js @@ -85,6 +85,7 @@ before(() => { describe('TxTypeSmartContractExecution', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -98,6 +99,8 @@ describe('TxTypeSmartContractExecution', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -740,7 +743,8 @@ describe('TxTypeSmartContractExecution', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -751,6 +755,7 @@ describe('TxTypeSmartContractExecution', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -761,6 +766,7 @@ describe('TxTypeSmartContractExecution', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/valueTransfer.js b/test/packages/caver.transaction/valueTransfer.js index 88aa383f..fa25b8b8 100644 --- a/test/packages/caver.transaction/valueTransfer.js +++ b/test/packages/caver.transaction/valueTransfer.js @@ -81,6 +81,7 @@ before(() => { describe('TxTypeValueTransfer', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -93,6 +94,8 @@ describe('TxTypeValueTransfer', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -740,7 +743,8 @@ describe('TxTypeValueTransfer', () => { const tx = caver.transaction.valueTransfer.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -752,6 +756,7 @@ describe('TxTypeValueTransfer', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -763,6 +768,7 @@ describe('TxTypeValueTransfer', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/valueTransferMemo.js b/test/packages/caver.transaction/valueTransferMemo.js index 4ad4e06a..5044bdaa 100644 --- a/test/packages/caver.transaction/valueTransferMemo.js +++ b/test/packages/caver.transaction/valueTransferMemo.js @@ -82,6 +82,7 @@ before(() => { describe('TxTypeValueTransferMemo', () => { let transactionObj let getGasPriceSpy + let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { @@ -95,6 +96,8 @@ describe('TxTypeValueTransferMemo', () => { getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') getGasPriceSpy.returns('0x5d21dba00') + getHeaderSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') + getHeaderSpy.returns({ baseFeePerGas: '0x5d21dba00' }) getNonceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getTransactionCount') getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') @@ -750,7 +753,8 @@ describe('TxTypeValueTransferMemo', () => { const tx = caver.transaction.valueTransferMemo.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).to.have.been.calledOnce + expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -762,6 +766,7 @@ describe('TxTypeValueTransferMemo', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -773,6 +778,7 @@ describe('TxTypeValueTransferMemo', () => { await tx.fillTransaction() expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).to.have.been.calledOnce }).timeout(200000) diff --git a/test/sendSignedTransaction.js b/test/sendSignedTransaction.js index 0718d20b..cc090f0e 100644 --- a/test/sendSignedTransaction.js +++ b/test/sendSignedTransaction.js @@ -47,6 +47,44 @@ before(() => { receiver = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) +async function receiptKeyCheck(receipt) { + const keys = [ + 'blockHash', + 'blockNumber', + 'contractAddress', + 'from', + 'gas', + 'gasPrice', + 'gasUsed', + 'logs', + 'logsBloom', + 'nonce', + 'senderTxHash', + 'signatures', + 'status', + 'to', + 'transactionHash', + 'transactionIndex', + 'type', + 'typeInt', + 'value', + ] + if (!keys.every(k => Object.prototype.hasOwnProperty.call(receipt, k))) return false + + const baseFee = caver.utils.hexToNumber((await caver.rpc.klay.getHeader('latest')).baseFeePerGas || '0x0') + if (baseFee > 0 && !Object.prototype.hasOwnProperty.call(receipt, 'effectiveGasPrice')) return false + if (receipt.type.includes('FeeDelegated')) { + const fdKeys = ['feePayer', 'feePayerSignatures'] + if (receipt.type.includes('WithRatio')) fdKeys.push('feeRatio') + if (!fdKeys.every(k => Object.prototype.hasOwnProperty.call(receipt, k))) return false + } + if (receipt.type.includes('Legacy') || receipt.type.includes('Ethereum') || receipt.type.includes('Contract')) { + if (!Object.prototype.hasOwnProperty.call(receipt, 'input')) return false + } + + return true +} + describe('CAVERJS-UNIT-TX-581: caver.klay.sendSignedTransaction with valid non fee delegated transaction raw string', () => { it('should send successfully with valid rawTransaction', async () => { const txObj = { @@ -61,32 +99,9 @@ describe('CAVERJS-UNIT-TX-581: caver.klay.sendSignedTransaction with valid non f expect(receipt).not.to.null - const keys = [ - 'blockHash', - 'blockNumber', - 'contractAddress', - 'from', - 'gas', - 'gasPrice', - 'gasUsed', - 'input', - 'logs', - 'logsBloom', - 'nonce', - 'senderTxHash', - 'signatures', - 'status', - 'to', - 'transactionHash', - 'transactionIndex', - 'type', - 'typeInt', - 'value', - ] - expect(Object.getOwnPropertyNames(receipt)).to.deep.equal(keys) - expect(receipt.status).to.equals(true) expect(receipt.senderTxHash).to.equals(receipt.transactionHash) + expect(await receiptKeyCheck(receipt)).to.be.true }).timeout(100000) }) @@ -107,33 +122,9 @@ describe('CAVERJS-UNIT-TX-582: caver.klay.sendSignedTransaction with valid fee d expect(receipt).not.to.null - const keys = [ - 'blockHash', - 'blockNumber', - 'contractAddress', - 'feePayer', - 'feePayerSignatures', - 'from', - 'gas', - 'gasPrice', - 'gasUsed', - 'logs', - 'logsBloom', - 'nonce', - 'senderTxHash', - 'signatures', - 'status', - 'to', - 'transactionHash', - 'transactionIndex', - 'type', - 'typeInt', - 'value', - ] - expect(Object.getOwnPropertyNames(receipt)).to.deep.equal(keys) - expect(receipt.status).to.equals(true) expect(receipt.senderTxHash).not.to.equals(receipt.transactionHash) + expect(await receiptKeyCheck(receipt)).to.be.true }).timeout(100000) }) @@ -151,32 +142,9 @@ describe('CAVERJS-UNIT-TX-583: caver.klay.sendSignedTransaction with object whic expect(receipt).not.to.null - const keys = [ - 'blockHash', - 'blockNumber', - 'contractAddress', - 'from', - 'gas', - 'gasPrice', - 'gasUsed', - 'input', - 'logs', - 'logsBloom', - 'nonce', - 'senderTxHash', - 'signatures', - 'status', - 'to', - 'transactionHash', - 'transactionIndex', - 'type', - 'typeInt', - 'value', - ] - expect(Object.getOwnPropertyNames(receipt)).to.deep.equal(keys) - expect(receipt.status).to.equals(true) expect(receipt.senderTxHash).to.equals(receipt.transactionHash) + expect(await receiptKeyCheck(receipt)).to.be.true }).timeout(100000) }) @@ -197,33 +165,9 @@ describe('CAVERJS-UNIT-TX-584: caver.klay.sendSignedTransaction with object whic expect(receipt).not.to.null - const keys = [ - 'blockHash', - 'blockNumber', - 'contractAddress', - 'feePayer', - 'feePayerSignatures', - 'from', - 'gas', - 'gasPrice', - 'gasUsed', - 'logs', - 'logsBloom', - 'nonce', - 'senderTxHash', - 'signatures', - 'status', - 'to', - 'transactionHash', - 'transactionIndex', - 'type', - 'typeInt', - 'value', - ] - expect(Object.getOwnPropertyNames(receipt)).to.deep.equal(keys) - expect(receipt.status).to.equals(true) expect(receipt.senderTxHash).not.to.equals(receipt.transactionHash) + expect(await receiptKeyCheck(receipt)).to.be.true }).timeout(100000) }) @@ -243,32 +187,9 @@ describe('CAVERJS-UNIT-TX-585: caver.klay.sendSignedTransaction with transaction expect(receipt).not.to.null - const keys = [ - 'blockHash', - 'blockNumber', - 'contractAddress', - 'from', - 'gas', - 'gasPrice', - 'gasUsed', - 'input', - 'logs', - 'logsBloom', - 'nonce', - 'senderTxHash', - 'signatures', - 'status', - 'to', - 'transactionHash', - 'transactionIndex', - 'type', - 'typeInt', - 'value', - ] - expect(Object.getOwnPropertyNames(receipt)).to.deep.equal(keys) - expect(receipt.status).to.equals(true) expect(receipt.senderTxHash).to.equals(receipt.transactionHash) + expect(await receiptKeyCheck(receipt)).to.be.true }).timeout(100000) }) @@ -293,33 +214,9 @@ describe('CAVERJS-UNIT-TX-586: caver.klay.sendSignedTransaction with transaction expect(receipt).not.to.null - const keys = [ - 'blockHash', - 'blockNumber', - 'contractAddress', - 'feePayer', - 'feePayerSignatures', - 'from', - 'gas', - 'gasPrice', - 'gasUsed', - 'logs', - 'logsBloom', - 'nonce', - 'senderTxHash', - 'signatures', - 'status', - 'to', - 'transactionHash', - 'transactionIndex', - 'type', - 'typeInt', - 'value', - ] - expect(Object.getOwnPropertyNames(receipt)).to.deep.equal(keys) - expect(receipt.status).to.equals(true) expect(receipt.senderTxHash).not.to.equals(receipt.transactionHash) + expect(await receiptKeyCheck(receipt)).to.be.true }).timeout(100000) }) @@ -346,32 +243,8 @@ describe('CAVERJS-UNIT-TX-587: caver.klay.sendSignedTransaction with fee payer t expect(receipt).not.to.null - const keys = [ - 'blockHash', - 'blockNumber', - 'contractAddress', - 'feePayer', - 'feePayerSignatures', - 'from', - 'gas', - 'gasPrice', - 'gasUsed', - 'logs', - 'logsBloom', - 'nonce', - 'senderTxHash', - 'signatures', - 'status', - 'to', - 'transactionHash', - 'transactionIndex', - 'type', - 'typeInt', - 'value', - ] - expect(Object.getOwnPropertyNames(receipt)).to.deep.equal(keys) - expect(receipt.status).to.equals(true) expect(receipt.senderTxHash).not.to.equals(receipt.transactionHash) + expect(await receiptKeyCheck(receipt)).to.be.true }).timeout(100000) }) diff --git a/test/transactionType/accountCreation.js b/test/transactionType/accountCreation.js deleted file mode 100644 index a642f271..00000000 --- a/test/transactionType/accountCreation.js +++ /dev/null @@ -1,2004 +0,0 @@ -/* - Copyright 2018 The caver-js Authors - This file is part of the caver-js library. - - The caver-js library is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - The caver-js library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with the caver-js. If not, see . -*/ - -const { expect, assert } = require('../extendedChai') - -const testRPCURL = require('../testrpc') -const Caver = require('../../index') - -let caver -let senderPrvKey -let senderAddress -let testAccount - -before(() => { - caver = new Caver(testRPCURL) - senderPrvKey = - process.env.privateKey && String(process.env.privateKey).indexOf('0x') === -1 - ? `0x${process.env.privateKey}` - : process.env.privateKey - - caver.klay.accounts.wallet.add(senderPrvKey) - - const sender = caver.klay.accounts.privateKeyToAccount(senderPrvKey) - senderAddress = sender.address -}) - -describe('ACCOUNT_CREATION transaction', () => { - let accountCreationObject - const pubKey1 = - '0x82e50e05ae21d4d35cf41856ec665b70ddb65fa3570f71f50b236f221fbd57598cfac224fee0b41f6152484060a608110757caf4eb7e7fbbd7a097244539e2e7' - const pubKey2 = - '0x8e9cc1d6826761c492160378022740368d256a7d697e84875d268711702e084c165f4a4823d4a8256f8141df5f377344d9dfb6e684e3cb7e91b7e928010d6508' - const pubKey3 = - '0x6d545db2dcba5a9f4201e4199ac5308b3e4f31033a9be3ebc0944e2d2fb0b7622f903f53e0ea5d0e20ce748a3da08052e6533107acaad0c14aba8c54f40154a3' - const pubKey4 = - '0xdff805352a763474506f1d4d288f5e5484335e32b378d8f4436b34affe3af661047fd41074f863b2c4d157891b2574fce6a735743f0442ac5b1d86bd55ed67ae' - const multisig = { - threshold: 3, - keys: [ - { weight: 1, publicKey: pubKey1 }, - { weight: 1, publicKey: pubKey2 }, - { weight: 1, publicKey: pubKey3 }, - { weight: 1, publicKey: pubKey4 }, - ], - } - beforeEach(() => { - testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) - accountCreationObject = { - type: 'ACCOUNT_CREATION', - from: senderAddress, - to: testAccount.address, - value: 1, - gas: 900000, - } - }) - - // Error from missing - it('CAVERJS-UNIT-TX-109 : If transaction object missing from, signTransaction should throw error', async () => { - const tx = { publicKey: pubKey1, ...accountCreationObject } - delete tx.from - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-109 : If transaction object missing from, sendTransaction should throw error', () => { - const tx = { publicKey: pubKey1, ...accountCreationObject } - delete tx.from - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // Error to missing - it('CAVERJS-UNIT-TX-110 : If transaction object missing to, signTransaction should throw error', async () => { - const tx = { publicKey: pubKey1, ...accountCreationObject } - delete tx.to - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-110 : If transaction object missing to, sendTransaction should throw error', () => { - const tx = { publicKey: pubKey1, ...accountCreationObject } - delete tx.to - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // Error value missing - it('CAVERJS-UNIT-TX-111 : If transaction object missing value, signTransaction should throw error', async () => { - const tx = { publicKey: pubKey1, ...accountCreationObject } - delete tx.value - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-111 : If transaction object missing value, sendTransaction should throw error', () => { - const tx = { publicKey: pubKey1, ...accountCreationObject } - delete tx.value - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // Error gas and gasLimit missing - it('CAVERJS-UNIT-TX-112 : If transaction object missing gas and gasLimit, signTransaction should throw error', async () => { - const tx = { publicKey: pubKey1, ...accountCreationObject } - delete tx.gas - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-112 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { - const tx = { publicKey: pubKey1, ...accountCreationObject } - delete tx.gas - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // MissingKey - it('CAVERJS-UNIT-TX-113 : If transaction object missing key information, signTransaction should throw error', async () => { - const tx = { ...accountCreationObject } - - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => assert(false)) - .catch(err => { - expect(err.message).to.equals('Missing key information with ACCOUNT_CREATION transaction') - }) - }).timeout(200000) - - it('CAVERJS-UNIT-TX-113 : If transaction object missing key information, sendTransaction should throw error', () => { - const tx = { ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws('Missing key information with ACCOUNT_CREATION transaction') - }).timeout(200000) - - // Creation with publicKey. - it('CAVERJS-UNIT-TX-114 : If transaction object has publicKey, create account with publicKey', async () => { - const tx = { publicKey: pubKey1, ...accountCreationObject } - - let result - await caver.klay - .sendTransaction(tx) - .then(async () => { - await caver.klay - .getAccountKey(tx.to) - .then(key => { - expect(key.keyType).to.equals(2) - result = true - }) - .catch(() => (result = false)) - }) - .catch(() => (result = false)) - - expect(result).to.be.true - }).timeout(200000) - - // PublicKeyLength64 - it('CAVERJS-UNIT-TX-116 : If compressed publicKey length is not 64, signTransaction should return error', async () => { - const tx = { publicKey: caver.utils.randomHex(32), ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-116 : If compressed publicKey length is not 64, sendTransaction should return error', async () => { - const tx = { publicKey: caver.utils.randomHex(32), ...accountCreationObject } - - let result - await caver.klay - .sendTransaction(tx) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - // PublicKeyLength126 - it('CAVERJS-UNIT-TX-117 : If uncompressed publicKey length is 126, signTransaction should return error', async () => { - const tx = { publicKey: caver.utils.randomHex(63), ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-117 : If uncompressed publicKey length is 126, sendTransaction should return error', async () => { - const tx = { publicKey: caver.utils.randomHex(63), ...accountCreationObject } - - let result - await caver.klay - .sendTransaction(tx) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - // Creation with multisig. - it('CAVERJS-UNIT-TX-118 : If transaction object has multisig, create account with multisig', async () => { - const tx = { multisig, ...accountCreationObject } - - let result - await caver.klay - .sendTransaction(tx) - .then(async () => { - await caver.klay - .getAccountKey(tx.to) - .then(key => { - expect(key.keyType).to.equals(4) - result = true - }) - .catch(() => (result = false)) - }) - .catch(() => (result = false)) - - expect(result).to.be.true - }).timeout(200000) - - // Creation with multisig and publicKey. - it('CAVERJS-UNIT-TX-119 : If transaction object has multisig and publicKey, signTransaction should throw error', async () => { - const tx = { publicKey: pubKey1, multisig, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-119 : If transaction object has multisig and publicKey, sendTransaction should throw error', () => { - const tx = { publicKey: pubKey1, multisig, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // Creation with roleTransactionKey. - it('CAVERJS-UNIT-TX-120 : If transaction object has roleTransactionKey, create account with roleTransactionKey', async () => { - const tx = { roleTransactionKey: { publicKey: pubKey1 }, ...accountCreationObject } - - let result - await caver.klay - .sendTransaction(tx) - .then(async () => { - await caver.klay - .getAccountKey(tx.to) - .then(key => { - const expectedXY = caver.utils.xyPointFromPublicKey(pubKey1) - expect(key.keyType).to.equals(5) - expect(key.key.length).to.equals(1) - expect(key.key[0].keyType).to.equals(2) - expect(key.key[0].key.x).to.equals(expectedXY[0]) - expect(key.key[0].key.y).to.equals(expectedXY[1]) - result = true - }) - .catch((result = false)) - }) - .catch((result = false)) - - expect(result).to.be.true - }).timeout(200000) - - // Creation with roleTransactionKey and publicKey. - it('CAVERJS-UNIT-TX-121 : If transaction object has roleTransactionKey and publicKey, signTransaction should throw error', async () => { - const tx = { roleTransactionKey: { publicKey: pubKey1 }, publicKey: pubKey1, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-121 : If transaction object has roleTransactionKey and publicKey, sendTransaction should throw error', () => { - const tx = { roleTransactionKey: { publicKey: pubKey1 }, publicKey: pubKey1, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // Creation with roleTransactionKey and multisig. - it('CAVERJS-UNIT-TX-122 : If transaction object has roleTransactionKey and multisig, signTransaction should throw error', async () => { - const tx = { roleTransactionKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-122 : If transaction object has roleTransactionKey and multisig, sendTransaction should throw error', () => { - const tx = { roleTransactionKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // Creation with roleTransactionKey and multisig and publicKey. - it('CAVERJS-UNIT-TX-123 : If transaction object has roleTransactionKey and multisig and publicKey, signTransaction should throw error', async () => { - const tx = { roleTransactionKey: { publicKey: pubKey1 }, multisig, publicKey: pubKey1, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-123 : If transaction object has roleTransactionKey and multisig and publicKey, sendTransaction should throw error', () => { - const tx = { roleTransactionKey: { publicKey: pubKey1 }, multisig, publicKey: pubKey1, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleAccountUpdateKey without roleTransactionKey - it('CAVERJS-UNIT-TX-124 : If transaction object has only roleAccountUpdateKey, signTransaction should throw error', async () => { - const tx = { roleAccountUpdateKey: { publicKey: pubKey1 }, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-124 : If transaction object has only roleAccountUpdateKey, sendTransaction should throw error', () => { - const tx = { roleAccountUpdateKey: { publicKey: pubKey1 }, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleAccountUpdateKey with roleTransactionKey - it('CAVERJS-UNIT-TX-125 : If transaction object has roleAccountUpdateKey and roleTransactionKey, create account with roleTransactionKey and roleAccountUpdateKey', async () => { - const tx = { - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - ...accountCreationObject, - } - - let result - await caver.klay - .sendTransaction(tx) - .then(async receipt => { - expect(receipt.to).to.equals(tx.to) - await caver.klay - .getAccountKey(receipt.to) - .then(key => { - const expectedTransactionKey = caver.utils.xyPointFromPublicKey(pubKey1) - const expectedUpdateKey = caver.utils.xyPointFromPublicKey(pubKey2) - expect(key.keyType).to.equals(5) - expect(key.key.length).to.equals(2) - expect(key.key[0].keyType).to.equals(2) - expect(key.key[0].key.x).to.equals(expectedTransactionKey[0]) - expect(key.key[0].key.y).to.equals(expectedTransactionKey[1]) - expect(key.key[1].keyType).to.equals(2) - expect(key.key[1].key.x).to.equals(expectedUpdateKey[0]) - expect(key.key[1].key.y).to.equals(expectedUpdateKey[1]) - result = true - }) - .catch((result = false)) - }) - .catch((result = false)) - - expect(result).to.be.true - }).timeout(200000) - - // RoleAccountUpdateKey with publicKey - it('CAVERJS-UNIT-TX-126 : If transaction object has roleAccountUpdateKey and publicKey, signTransaction should throw error', async () => { - const tx = { roleAccountUpdateKey: { publicKey: pubKey1 }, publicKey: pubKey1, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-126 : If transaction object has roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { - const tx = { roleAccountUpdateKey: { publicKey: pubKey1 }, publicKey: pubKey1, ...accountCreationObject } - // Throw error from formatter validation - - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleAccountUpdateKey with multisig - it('CAVERJS-UNIT-TX-127 : If transaction object has roleAccountUpdateKey and multisig, signTransaction should throw error', async () => { - const tx = { roleAccountUpdateKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-127 : If transaction object has roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { - const tx = { roleAccountUpdateKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleAccountUpdateKey with multisig and publicKey - it('CAVERJS-UNIT-TX-128 : If transaction object has roleAccountUpdateKey, multisig and publicKey, signTransaction should throw error', async () => { - const tx = { roleAccountUpdateKey: { publicKey: pubKey1 }, multisig, publicKey: pubKey1, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-128 : If transaction object has roleAccountUpdateKey, multisig and publicKey, sendTransaction should throw error', () => { - const tx = { roleAccountUpdateKey: { publicKey: pubKey1 }, multisig, publicKey: pubKey1, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleAccountUpdateKey with roleTransactionKey and publicKey - it('CAVERJS-UNIT-TX-129 : If transaction object has roleAccountUpdateKey, roleTransactionKey and publicKey, signTransaction should throw error', async () => { - const tx = { - roleAccountUpdateKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - publicKey: pubKey1, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-129 : If transaction object has roleAccountUpdateKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { - const tx = { - roleAccountUpdateKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - publicKey: pubKey1, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleAccountUpdateKey with roleTransactionKey and multisig - it('CAVERJS-UNIT-TX-130 : If transaction object has roleAccountUpdateKey, roleTransactionKey and multisig, signTransaction should throw error', async () => { - const tx = { - roleAccountUpdateKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-130 : If transaction object has roleAccountUpdateKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { - const tx = { - roleAccountUpdateKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleAccountUpdateKey with roleTransactionKey, multisig and publicKey - it('CAVERJS-UNIT-TX-131 : If transaction object has roleAccountUpdateKey, roleTransactionKey, multisig and publicKey, signTransaction should throw error', async () => { - const tx = { - roleAccountUpdateKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - multisig, - publicKey: pubKey1, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-131 : If transaction object has roleAccountUpdateKey, roleTransactionKey, multisig and publicKey, sendTransaction should throw error', () => { - const tx = { - roleAccountUpdateKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - multisig, - publicKey: pubKey1, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey without roleTransactionKey and roleAccountUpdateKey - it('CAVERJS-UNIT-TX-132 : If transaction object has only roleFeePayerKey, signTransaction should throw error', async () => { - const tx = { roleFeePayerKey: { publicKey: pubKey1 }, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-132 : If transaction object has only roleFeePayerKey, sendTransaction should throw error', () => { - const tx = { roleFeePayerKey: { publicKey: pubKey1 }, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleTransactionKey - it('CAVERJS-UNIT-TX-133 : If transaction object has roleFeePayerKey and roleTransactionKey, signTransaction should throw error', async () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-133 : If transaction object has roleFeePayerKey and roleTransactionKey, sendTransaction should throw error', () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleAccountUpdateKey - it('CAVERJS-UNIT-TX-134 : If transaction object has roleFeePayerKey and roleAccountUpdateKey, signTransaction should throw error', async () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-134 : If transaction object has roleFeePayerKey and roleAccountUpdateKey, sendTransaction should throw error', () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleAccountUpdateKey and roleTransactionKey - it('CAVERJS-UNIT-TX-135 : If transaction object has roleFeePayerKey, roleTransactionKey and roleAccountUpdateKey, create account with roleTransactionKey, roleAccountUpdateKey and roleFeePayerKey', async () => { - const tx = { - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - ...accountCreationObject, - } - - let result - await caver.klay - .sendTransaction(tx) - .then(async receipt => { - expect(receipt.to).to.equals(tx.to) - await caver.klay - .getAccountKey(receipt.to) - .then(key => { - const expectedTransactionKey = caver.utils.xyPointFromPublicKey(pubKey1) - const expectedUpdateKey = caver.utils.xyPointFromPublicKey(pubKey2) - const expectedFeePayerKey = caver.utils.xyPointFromPublicKey(pubKey3) - expect(key.keyType).to.equals(5) - expect(key.key.length).to.equals(3) - expect(key.key[0].keyType).to.equals(2) - expect(key.key[0].key.x).to.equals(expectedTransactionKey[0]) - expect(key.key[0].key.y).to.equals(expectedTransactionKey[1]) - expect(key.key[1].keyType).to.equals(2) - expect(key.key[1].key.x).to.equals(expectedUpdateKey[0]) - expect(key.key[1].key.y).to.equals(expectedUpdateKey[1]) - expect(key.key[2].keyType).to.equals(2) - expect(key.key[2].key.x).to.equals(expectedFeePayerKey[0]) - expect(key.key[2].key.y).to.equals(expectedFeePayerKey[1]) - result = true - }) - .catch((result = false)) - }) - .catch((result = false)) - - expect(result).to.be.true - }).timeout(200000) - - // RoleFeePayerKey with publicKey - it('CAVERJS-UNIT-TX-136 : If transaction object has roleFeePayerKey and publicKey, signTransaction should throw error', async () => { - const tx = { roleFeePayerKey: { publicKey: pubKey1 }, publicKey: pubKey2, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-136 : If transaction object has roleFeePayerKey and publicKey, sendTransaction should throw error', () => { - const tx = { roleFeePayerKey: { publicKey: pubKey1 }, publicKey: pubKey2, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with multisig - it('CAVERJS-UNIT-TX-137 : If transaction object has roleFeePayerKey and publicKey, signTransaction should throw error', async () => { - const tx = { roleFeePayerKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-137 : If transaction object has roleFeePayerKey and publicKey, sendTransaction should throw error', () => { - const tx = { roleFeePayerKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with publicKey and multisig - it('CAVERJS-UNIT-TX-138 : If transaction object has roleFeePayerKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { roleFeePayerKey: { publicKey: pubKey1 }, multisig, publicKey: pubKey2, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-138 : If transaction object has roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { roleFeePayerKey: { publicKey: pubKey1 }, multisig, publicKey: pubKey2, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleTransactionKey and publicKey - it('CAVERJS-UNIT-TX-139 : If transaction object has roleFeePayerKey, roleTransactionKey and publicKey, signTransaction should throw error', async () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - publicKey: pubKey3, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-139 : If transaction object has roleFeePayerKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - publicKey: pubKey3, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleTransactionKey and multisig - it('CAVERJS-UNIT-TX-140 : If transaction object has roleFeePayerKey, roleTransactionKey and multisig, signTransaction should throw error', async () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-140 : If transaction object has roleFeePayerKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleTransactionKey, publicKey and multisig - it('CAVERJS-UNIT-TX-141 : If transaction object has roleFeePayerKey, roleTransactionKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - publicKey: pubKey3, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-141 : If transaction object has roleFeePayerKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - publicKey: pubKey3, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleAccountUpdateKey and publicKey - it('CAVERJS-UNIT-TX-142 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and publicKey, signTransaction should throw error', async () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - publicKey: pubKey3, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-142 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - publicKey: pubKey3, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleAccountUpdateKey and multisig - it('CAVERJS-UNIT-TX-143 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and multisig, signTransaction should throw error', async () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-143 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleAccountUpdateKey, publicKey and multisig - it('CAVERJS-UNIT-TX-144 : If transaction object has roleFeePayerKey, roleAccountUpdateKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - publicKey: pubKey3, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-144 : If transaction object has roleFeePayerKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - publicKey: pubKey3, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleTransactionKey, roleAccountUpdateKey and publicKey - it('CAVERJS-UNIT-TX-145 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and publicKey, signTransaction should throw error', async () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - roleAccountUpdateKey: { publicKey: pubKey3 }, - publicKey: pubKey4, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-145 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - roleAccountUpdateKey: { publicKey: pubKey3 }, - publicKey: pubKey4, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleTransactionKey, roleAccountUpdateKey and multisig - it('CAVERJS-UNIT-TX-146 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and multisig, signTransaction should throw error', async () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - roleAccountUpdateKey: { publicKey: pubKey3 }, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-146 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - roleAccountUpdateKey: { publicKey: pubKey3 }, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // RoleFeePayerKey with roleTransactionKey, roleAccountUpdateKey, publicKey and multisig - it('CAVERJS-UNIT-TX-147 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - roleAccountUpdateKey: { publicKey: pubKey3 }, - publicKey: pubKey4, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-147 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { - roleFeePayerKey: { publicKey: pubKey1 }, - roleTransactionKey: { publicKey: pubKey2 }, - roleAccountUpdateKey: { publicKey: pubKey3 }, - publicKey: pubKey4, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // Create account with failKey - it('CAVERJS-UNIT-TX-148 : If transaction object has only failKey, create account with failKey', async () => { - const tx = { failKey: true, ...accountCreationObject } - - let result - await caver.klay - .sendTransaction(tx) - .then(async receipt => { - expect(receipt.to).to.equals(tx.to) - await caver.klay - .getAccountKey(receipt.to) - .then(key => { - expect(key.keyType).to.equals(3) - result = true - }) - .catch((result = false)) - }) - .catch((result = false)) - - expect(result).to.be.true - }).timeout(200000) - - // FailKey with publicKey - it('CAVERJS-UNIT-TX-149 : If transaction object has failKey and publicKey, signTransaction should throw error', async () => { - const tx = { failKey: true, publicKey: pubKey1, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-149 : If transaction object has failKey and publicKey, sendTransaction should throw error', () => { - const tx = { failKey: true, publicKey: pubKey1, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with multisig - it('CAVERJS-UNIT-TX-150 : If transaction object has failKey and multisig, signTransaction should throw error', async () => { - const tx = { failKey: true, multisig, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-150 : If transaction object has failKey and multisig, sendTransaction should throw error', () => { - const tx = { failKey: true, multisig, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with publicKey and multisig - it('CAVERJS-UNIT-TX-151 : If transaction object has failKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { failKey: true, publicKey: pubKey1, multisig, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-151 : If transaction object has failKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { failKey: true, publicKey: pubKey1, multisig, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey - it('CAVERJS-UNIT-TX-152 : If transaction object has failKey and roleTransactionKey, signTransaction should throw error', async () => { - const tx = { failKey: true, roleTransactionKey: { publicKey: pubKey1 }, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-152 : If transaction object has failKey and roleTransactionKey, sendTransaction should throw error', () => { - const tx = { failKey: true, roleTransactionKey: { publicKey: pubKey1 }, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey and publicKey - it('CAVERJS-UNIT-TX-153 : If transaction object has failKey, roleTransactionKey and publicKey, signTransaction should throw error', async () => { - const tx = { failKey: true, roleTransactionKey: { publicKey: pubKey1 }, publicKey: pubKey1, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-153 : If transaction object has failKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { - const tx = { failKey: true, roleTransactionKey: { publicKey: pubKey1 }, publicKey: pubKey1, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey and multisig - it('CAVERJS-UNIT-TX-154 : If transaction object has failKey, roleTransactionKey and multisig, signTransaction should throw error', async () => { - const tx = { failKey: true, roleTransactionKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-154 : If transaction object has failKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { - const tx = { failKey: true, roleTransactionKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey, publicKey and multisig - it('CAVERJS-UNIT-TX-155 : If transaction object has failKey, roleTransactionKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-155 : If transaction object has failKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleAccountUpdateKey - it('CAVERJS-UNIT-TX-156 : If transaction object has failKey and roleAccountUpdateKey, signTransaction should throw error', async () => { - const tx = { failKey: true, roleAccountUpdateKey: { publicKey: pubKey1 }, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-156 : If transaction object has failKey and roleAccountUpdateKey, sendTransaction should throw error', () => { - const tx = { failKey: true, roleAccountUpdateKey: { publicKey: pubKey1 }, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleAccountUpdateKey and publicKey - it('CAVERJS-UNIT-TX-157 : If transaction object has failKey, roleAccountUpdateKey and publicKey, signTransaction should throw error', async () => { - const tx = { failKey: true, roleAccountUpdateKey: { publicKey: pubKey1 }, publicKey: pubKey1, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-157 : If transaction object has failKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { - const tx = { failKey: true, roleAccountUpdateKey: { publicKey: pubKey1 }, publicKey: pubKey1, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleAccountUpdateKey and multisig - it('CAVERJS-UNIT-TX-158 : If transaction object has failKey, roleAccountUpdateKey and multisig, signTransaction should throw error', async () => { - const tx = { failKey: true, roleAccountUpdateKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-158 : If transaction object has failKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { - const tx = { failKey: true, roleAccountUpdateKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleAccountUpdateKey, publicKey and multisig - it('CAVERJS-UNIT-TX-159 : If transaction object has failKey, roleAccountUpdateKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleAccountUpdateKey: { publicKey: pubKey1 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-159 : If transaction object has failKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleAccountUpdateKey: { publicKey: pubKey1 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleFeePayerKey - it('CAVERJS-UNIT-TX-160 : If transaction object has failKey and roleFeePayerKey, signTransaction should throw error', async () => { - const tx = { failKey: true, roleFeePayerKey: { publicKey: pubKey1 }, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-160 : If transaction object has failKey and roleFeePayerKey, sendTransaction should throw error', () => { - const tx = { failKey: true, roleFeePayerKey: { publicKey: pubKey1 }, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleFeePayerKey and publicKey - it('CAVERJS-UNIT-TX-161 : If transaction object has failKey, roleFeePayerKey and publicKey, signTransaction should throw error', async () => { - const tx = { failKey: true, roleFeePayerKey: { publicKey: pubKey1 }, publicKey: pubKey1, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-161 : If transaction object has failKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { - const tx = { failKey: true, roleFeePayerKey: { publicKey: pubKey1 }, publicKey: pubKey1, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleFeePayerKey and multisig - it('CAVERJS-UNIT-TX-162 : If transaction object has failKey, roleFeePayerKey and multisig, signTransaction should throw error', async () => { - const tx = { failKey: true, roleFeePayerKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-162 : If transaction object has failKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { - const tx = { failKey: true, roleFeePayerKey: { publicKey: pubKey1 }, multisig, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleFeePayerKey, publicKey and multisig - it('CAVERJS-UNIT-TX-163 : If transaction object has failKey, roleFeePayerKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleFeePayerKey: { publicKey: pubKey1 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-163 : If transaction object has failKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleFeePayerKey: { publicKey: pubKey1 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey, roleAccountUpdateKey and publicKey - it('CAVERJS-UNIT-TX-164 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and publicKey, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - publicKey: pubKey1, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-164 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - publicKey: pubKey1, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey, roleAccountUpdateKey and multisig - it('CAVERJS-UNIT-TX-165 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and multisig, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-165 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey, roleAccountUpdateKey, publicKey and multisig - it('CAVERJS-UNIT-TX-166 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-166 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey, roleFeePayerKey and publicKey - it('CAVERJS-UNIT-TX-167 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and publicKey, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleFeePayerKey: { publicKey: pubKey2 }, - publicKey: pubKey1, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-167 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleFeePayerKey: { publicKey: pubKey2 }, - publicKey: pubKey1, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey, roleFeePayerKey and multisig - it('CAVERJS-UNIT-TX-168 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and multisig, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleFeePayerKey: { publicKey: pubKey2 }, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-168 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleFeePayerKey: { publicKey: pubKey2 }, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey, roleFeePayerKey, publicKey and multisig - it('CAVERJS-UNIT-TX-169 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleFeePayerKey: { publicKey: pubKey2 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-169 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleFeePayerKey: { publicKey: pubKey2 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleAccountUpdateKey, roleFeePayerKey and publicKey - it('CAVERJS-UNIT-TX-170 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - publicKey: pubKey1, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-170 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - publicKey: pubKey1, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleAccountUpdateKey, roleFeePayerKey and multisig - it('CAVERJS-UNIT-TX-171 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and multisig, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-171 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig - it('CAVERJS-UNIT-TX-172 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-172 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and publicKey - it('CAVERJS-UNIT-TX-173 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - publicKey: pubKey1, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-173 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - publicKey: pubKey1, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and multisig - it('CAVERJS-UNIT-TX-174 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and multisig, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-174 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // FailKey with roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig - it('CAVERJS-UNIT-TX-175 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, signTransaction should throw error', async () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-175 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { - const tx = { - failKey: true, - roleTransactionKey: { publicKey: pubKey1 }, - roleAccountUpdateKey: { publicKey: pubKey2 }, - roleFeePayerKey: { publicKey: pubKey3 }, - publicKey: pubKey1, - multisig, - ...accountCreationObject, - } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // UnnecessaryData - it('CAVERJS-UNIT-TX-176 : If transaction object has data, signTransaction should throw error', async () => { - const tx = { publicKey: pubKey1, data: '0x68656c6c6f', ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-176 : If transaction object has data, sendTransaction should throw error', () => { - const tx = { publicKey: pubKey1, data: '0x68656c6c6f', ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // UnnecessaryFeePayer - it('CAVERJS-UNIT-TX-177 : If transaction object has feePayer, signTransaction should throw error', async () => { - const payer = caver.klay.accounts.create() - const tx = { publicKey: pubKey1, feePayer: payer.address, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-177 : If transaction object has data, sendTransaction should throw error', () => { - const payer = caver.klay.accounts.create() - const tx = { publicKey: pubKey1, feePayer: payer.address, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // UnnecessaryFeeRatio - it('CAVERJS-UNIT-TX-178 : If transaction object has feeRatio, signTransaction should throw error', async () => { - const tx = { publicKey: pubKey1, feeRatio: 20, ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-178 : If transaction object has feeRatio, sendTransaction should throw error', () => { - const tx = { publicKey: pubKey1, feeRatio: 20, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // UnnecessaryCodeFormat - it('CAVERJS-UNIT-TX-179 : If transaction object has codeFormat, signTransaction should throw error', async () => { - const tx = { publicKey: pubKey1, codeFormat: 'EVM', ...accountCreationObject } - - let result - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => (result = false)) - .catch(() => (result = true)) - - expect(result).to.be.true - }).timeout(200000) - - it('CAVERJS-UNIT-TX-179 : If transaction object has codeFormat, sendTransaction should throw error', () => { - const tx = { publicKey: pubKey1, codeFormat: 'EVM', ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() - }).timeout(200000) - - // Create account with legacyKey - it('CAVERJS-UNIT-TX-180 : If transaction object has only legacyKey, create account with legacyKey', async () => { - const tx = { legacyKey: true, ...accountCreationObject } - - const receipt = await caver.klay.sendTransaction(tx) - expect(receipt.to).to.equals(tx.to) - - const key = await caver.klay.getAccountKey(receipt.to) - expect(key.keyType).to.equals(1) - }).timeout(200000) - - // LegacyKey with publicKey - it('CAVERJS-UNIT-TX-181 : If transaction object has legacyKey and publicKey, signTransaction should throw error', async () => { - const tx = { legacyKey: true, publicKey: pubKey1, ...accountCreationObject } - - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => assert(false)) - .catch(err => { - expect(err.message).to.equals('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }) - }).timeout(200000) - - it('CAVERJS-UNIT-TX-181 : If transaction object has legacyKey and publicKey, sendTransaction should throw error', () => { - const tx = { legacyKey: true, publicKey: pubKey1, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }).timeout(200000) - - // LegacyKey with multisig - it('CAVERJS-UNIT-TX-182 : If transaction object has legacyKey and multisig, signTransaction should throw error', async () => { - const tx = { legacyKey: true, multisig, ...accountCreationObject } - - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => assert(false)) - .catch(err => { - expect(err.message).to.equals('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }) - }).timeout(200000) - - it('CAVERJS-UNIT-TX-182 : If transaction object has legacyKey and multisig, sendTransaction should throw error', () => { - const tx = { legacyKey: true, multisig, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }).timeout(200000) - - // LegacyKey with failKey - it('CAVERJS-UNIT-TX-183 : If transaction object has legacyKey and failKey, signTransaction should throw error', async () => { - const tx = { legacyKey: true, failKey: true, ...accountCreationObject } - - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => assert(false)) - .catch(err => { - expect(err.message).to.equals('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }) - }).timeout(200000) - - it('CAVERJS-UNIT-TX-183 : If transaction object has legacyKey and failKey, sendTransaction should throw error', () => { - const tx = { legacyKey: true, failKey: true, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }).timeout(200000) - - // LegacyKey with roleTransactionKey - it('CAVERJS-UNIT-TX-184 : If transaction object has legacyKey and roleTransactionKey, signTransaction should throw error', async () => { - const tx = { legacyKey: true, roleTransactionKey: { publicKey: pubKey1 }, ...accountCreationObject } - - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => assert(false)) - .catch(err => { - expect(err.message).to.equals('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }) - }).timeout(200000) - - it('CAVERJS-UNIT-TX-184 : If transaction object has legacyKey and roleTransactionKey, sendTransaction should throw error', () => { - const tx = { legacyKey: true, roleTransactionKey: { publicKey: pubKey1 }, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }).timeout(200000) - - // LegacyKey with roleAccountUpdateKey - it('CAVERJS-UNIT-TX-185 : If transaction object has legacyKey and roleAccountUpdateKey, signTransaction should throw error', async () => { - const tx = { legacyKey: true, roleAccountUpdateKey: { publicKey: pubKey1 }, ...accountCreationObject } - - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => assert(false)) - .catch(err => { - expect(err.message).to.equals('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }) - }).timeout(200000) - - it('CAVERJS-UNIT-TX-185 : If transaction object has legacyKey and roleAccountUpdateKey, sendTransaction should throw error', () => { - const tx = { legacyKey: true, roleAccountUpdateKey: { publicKey: pubKey1 }, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }).timeout(200000) - - // LegacyKey with roleFeePayerKey - it('CAVERJS-UNIT-TX-186 : If transaction object has legacyKey and roleFeePayerKey, signTransaction should throw error', async () => { - const tx = { legacyKey: true, roleFeePayerKey: { publicKey: pubKey1 }, ...accountCreationObject } - - await caver.klay.accounts - .signTransaction(tx, senderPrvKey) - .then(() => assert(false)) - .catch(err => { - expect(err.message).to.equals('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }) - }).timeout(200000) - - it('CAVERJS-UNIT-TX-186 : If transaction object has legacyKey and roleFeePayerKey, sendTransaction should throw error', () => { - const tx = { legacyKey: true, roleFeePayerKey: { publicKey: pubKey1 }, ...accountCreationObject } - - // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws('The key parameter to be used for ACCOUNT_CREATION is duplicated.') - }).timeout(200000) -}) diff --git a/test/transactionType/accountUpdate.js b/test/transactionType/accountUpdate.js index ae89a9e8..ab331a07 100644 --- a/test/transactionType/accountUpdate.js +++ b/test/transactionType/accountUpdate.js @@ -26,7 +26,7 @@ let senderPrvKey let senderAddress let testAccount -describe('ACCOUNT_UPDATE transaction', () => { +describe('ACCOUNT_UPDATE transaction', async () => { let accountUpdateObject let publicKey let publicKey2 @@ -98,12 +98,12 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-187 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-187 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.from // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // UnnecessaryTo @@ -119,11 +119,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-188 : If transaction object has to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-188 : If transaction object has to, sendTransaction should throw error', async () => { const tx = { publicKey, to: senderAddress, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // UnnecessaryValue @@ -139,11 +139,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-189 : If transaction object has value, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-189 : If transaction object has value, sendTransaction should throw error', async () => { const tx = { publicKey, value: 1, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // MissingGas @@ -160,12 +160,12 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-190 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-190 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.gas // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // MissingKey @@ -180,7 +180,7 @@ describe('ACCOUNT_UPDATE transaction', () => { }) }).timeout(200000) - it('CAVERJS-UNIT-TX-191 : If transaction object missing key information, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-191 : If transaction object missing key information, sendTransaction should throw error', async () => { const tx = { ...accountUpdateObject } // Throw error from formatter validation @@ -287,11 +287,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-197 : If transaction object has multisig and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-197 : If transaction object has multisig and publicKey, sendTransaction should throw error', async () => { const tx = { publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleTransactionKey. @@ -337,11 +337,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-199 : If transaction object has roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-199 : If transaction object has roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleTransactionKey and multisig. @@ -357,11 +357,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-200 : If transaction object has roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-200 : If transaction object has roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleTransactionKey, publicKey and multisig. @@ -377,11 +377,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-201 : If transaction object has roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-201 : If transaction object has roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleAccountUpdateKey. @@ -457,11 +457,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-204 : If transaction object has roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-204 : If transaction object has roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleAccountUpdateKey and multisig. @@ -477,11 +477,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-205 : If transaction object has roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-205 : If transaction object has roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleAccountUpdateKey, publicKey and multisig. @@ -497,11 +497,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-206 : If transaction object has roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-206 : If transaction object has roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleAccountUpdateKey, roleTransactionKey and publicKey. @@ -517,11 +517,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-207 : If transaction object has roleAccountUpdateKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-207 : If transaction object has roleAccountUpdateKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleAccountUpdateKey, roleTransactionKey and multisig. @@ -537,11 +537,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-208 : If transaction object has roleAccountUpdateKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-208 : If transaction object has roleAccountUpdateKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleAccountUpdateKey, roleTransactionKey, publicKey and multisig. @@ -563,7 +563,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-209 : If transaction object has roleAccountUpdateKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-209 : If transaction object has roleAccountUpdateKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -573,7 +573,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey. @@ -713,11 +713,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-214 : If transaction object has roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-214 : If transaction object has roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey and multisig. @@ -733,11 +733,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-215 : If transaction object has roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-215 : If transaction object has roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey, publicKey and multisig. @@ -753,11 +753,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-216 : If transaction object has roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-216 : If transaction object has roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey and publicKey. @@ -773,11 +773,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-217 : If transaction object has roleFeePayerKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-217 : If transaction object has roleFeePayerKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey and multisig. @@ -793,11 +793,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-218 : If transaction object has roleFeePayerKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-218 : If transaction object has roleFeePayerKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey, publicKey and multisig. @@ -819,7 +819,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-219 : If transaction object has roleFeePayerKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-219 : If transaction object has roleFeePayerKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, @@ -829,7 +829,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey, roleAccountUpdateKey and publicKey. @@ -845,11 +845,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-220 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-220 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey, roleAccountUpdateKey and multisig. @@ -865,11 +865,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-221 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-221 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey, roleAccountUpdateKey, publicKey and multisig. @@ -891,7 +891,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-222 : If transaction object has roleFeePayerKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-222 : If transaction object has roleFeePayerKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, @@ -901,7 +901,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and publicKey. @@ -923,7 +923,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-223 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-223 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -933,7 +933,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and multisig. @@ -955,7 +955,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-224 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-224 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -965,7 +965,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig. @@ -988,7 +988,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-225 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-225 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -999,7 +999,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey. @@ -1027,11 +1027,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-227 : If transaction object has failKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-227 : If transaction object has failKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey and multisig. @@ -1047,11 +1047,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-228 : If transaction object has failKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-228 : If transaction object has failKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, publicKey and multisig. @@ -1067,11 +1067,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-229 : If transaction object has failKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-229 : If transaction object has failKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey and roleTransactionKey. @@ -1087,11 +1087,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-230 : If transaction object has failKey and roleTransactionKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-230 : If transaction object has failKey and roleTransactionKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey and publicKey. @@ -1107,11 +1107,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-231 : If transaction object has failKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-231 : If transaction object has failKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey and multisig. @@ -1127,11 +1127,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-232 : If transaction object has failKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-232 : If transaction object has failKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey, publicKey and multisig. @@ -1147,11 +1147,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-233 : If transaction object has failKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-233 : If transaction object has failKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey and roleAccountUpdateKey. @@ -1167,11 +1167,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-234 : If transaction object has failKey and roleAccountUpdateKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-234 : If transaction object has failKey and roleAccountUpdateKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleAccountUpdateKey and publicKey. @@ -1187,11 +1187,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-235 : If transaction object has failKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-235 : If transaction object has failKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleAccountUpdateKey and multisig. @@ -1207,11 +1207,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-236 : If transaction object has failKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-236 : If transaction object has failKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleAccountUpdateKey, publicKey and multisig. @@ -1227,11 +1227,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-237 : If transaction object has failKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-237 : If transaction object has failKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey and roleFeePayerKey. @@ -1247,11 +1247,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-238 : If transaction object has failKey and roleFeePayerKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-238 : If transaction object has failKey and roleFeePayerKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleFeePayerKey and publicKey. @@ -1267,11 +1267,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-239 : If transaction object has failKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-239 : If transaction object has failKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleFeePayerKey and multisig. @@ -1287,11 +1287,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-240 : If transaction object has failKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-240 : If transaction object has failKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleFeePayerKey, publicKey and multisig. @@ -1307,11 +1307,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-241 : If transaction object has failKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-241 : If transaction object has failKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey and publicKey. @@ -1333,7 +1333,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-242 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-242 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1343,7 +1343,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey and multisig. @@ -1365,7 +1365,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-243 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-243 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1375,7 +1375,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig. @@ -1398,7 +1398,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-244 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-244 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1409,7 +1409,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey, roleFeePayerKey and publicKey. @@ -1431,7 +1431,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-245 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-245 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1441,7 +1441,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey, roleFeePayerKey and multisig. @@ -1463,7 +1463,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-246 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-246 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1473,7 +1473,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey, roleFeePayerKey, publicKey and multisig. @@ -1496,7 +1496,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-247 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-247 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1507,7 +1507,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleAccountUpdateKey, roleFeePayerKey and publicKey. @@ -1529,7 +1529,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-248 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-248 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, @@ -1539,7 +1539,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleAccountUpdateKey, roleFeePayerKey and multisig. @@ -1561,7 +1561,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-249 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-249 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, @@ -1571,7 +1571,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig. @@ -1594,7 +1594,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-250 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-250 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, @@ -1605,7 +1605,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and publicKey. @@ -1628,7 +1628,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-251 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-251 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1639,7 +1639,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and multisig. @@ -1662,7 +1662,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-252 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-252 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1673,7 +1673,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig. @@ -1697,7 +1697,7 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-253 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-253 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1709,7 +1709,7 @@ describe('ACCOUNT_UPDATE transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // UnnecessaryData @@ -1725,11 +1725,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-254 : If transaction object has data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-254 : If transaction object has data, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // UnnecessaryFeePayer @@ -1745,11 +1745,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-255 : If transaction object has feePayer, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-255 : If transaction object has feePayer, sendTransaction should throw error', async () => { const tx = { feePayer: caver.klay.accounts.create().address, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // UnnecessaryFeeRatio @@ -1765,11 +1765,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-256 : If transaction object has feeRatio, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-256 : If transaction object has feeRatio, sendTransaction should throw error', async () => { const tx = { feeRatio: 20, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // UnnecessaryCodeFormat @@ -1785,11 +1785,11 @@ describe('ACCOUNT_UPDATE transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-257 : If transaction object has codeFormat, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-257 : If transaction object has codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Update account with legacyKey @@ -1827,7 +1827,7 @@ describe('ACCOUNT_UPDATE transaction', () => { }) }).timeout(200000) - it('CAVERJS-UNIT-TX-259 : If transaction object has legacyKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-259 : If transaction object has legacyKey and publicKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, publicKey, ...accountUpdateObject } // Throw error from formatter validation @@ -1846,7 +1846,7 @@ describe('ACCOUNT_UPDATE transaction', () => { }) }).timeout(200000) - it('CAVERJS-UNIT-TX-260 : If transaction object has legacyKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-260 : If transaction object has legacyKey and multisig, sendTransaction should throw error', async () => { const tx = { legacyKey: true, multisig, ...accountUpdateObject } // Throw error from formatter validation @@ -1865,7 +1865,7 @@ describe('ACCOUNT_UPDATE transaction', () => { }) }).timeout(200000) - it('CAVERJS-UNIT-TX-261 : If transaction object has legacyKey and failKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-261 : If transaction object has legacyKey and failKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, failKey: true, ...accountUpdateObject } // Throw error from formatter validation @@ -1884,7 +1884,7 @@ describe('ACCOUNT_UPDATE transaction', () => { }) }).timeout(200000) - it('CAVERJS-UNIT-TX-262 : If transaction object has legacyKey and roleTransactionKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-262 : If transaction object has legacyKey and roleTransactionKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, roleTransactionKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation @@ -1903,7 +1903,7 @@ describe('ACCOUNT_UPDATE transaction', () => { }) }).timeout(200000) - it('CAVERJS-UNIT-TX-263 : If transaction object has legacyKey and roleAccountUpdateKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-263 : If transaction object has legacyKey and roleAccountUpdateKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, roleAccountUpdateKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation @@ -1922,7 +1922,7 @@ describe('ACCOUNT_UPDATE transaction', () => { }) }).timeout(200000) - it('CAVERJS-UNIT-TX-264 : If transaction object has legacyKey and roleFeePayerKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-264 : If transaction object has legacyKey and roleFeePayerKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, roleFeePayerKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation @@ -1939,7 +1939,7 @@ describe('ACCOUNT_UPDATE transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-588: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-588: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { publicKey, ...accountUpdateObject } tx.from = 'invalidAddress' @@ -1958,7 +1958,7 @@ describe('ACCOUNT_UPDATE transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-589: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-589: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const tx = { publicKey, feePayerSignatures: [['0x01', '0x', '0x']], ...accountUpdateObject } const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` diff --git a/test/transactionType/cancelTransaction.js b/test/transactionType/cancelTransaction.js index d6d26e17..9fb799c8 100644 --- a/test/transactionType/cancelTransaction.js +++ b/test/transactionType/cancelTransaction.js @@ -41,7 +41,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('CANCEL transaction', () => { +describe('CANCEL transaction', async () => { let cancelObject beforeEach(() => { @@ -63,11 +63,11 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"from" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-511 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-511 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...cancelObject } delete tx.from - expect(() => caver.klay.sendTransaction(tx)).to.throws('The send transactions "from" field must be defined!') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') }).timeout(200000) // UnnecessaryTo @@ -80,10 +80,10 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"to" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-512 : If transaction object has unnecessary to field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-512 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: testAccount.address, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"to" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryValue @@ -96,10 +96,10 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"value" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-513 : If transaction object has unnecessary value field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-513 : If transaction object has unnecessary value field, sendTransaction should throw error', async () => { const tx = { value: 1, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"value" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"value" cannot be used with CANCEL transaction') }).timeout(200000) // MissingGas @@ -113,11 +113,11 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"gas" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-514 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-514 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...cancelObject } delete tx.gas - expect(() => caver.klay.sendTransaction(tx)).to.throws('"gas" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') }).timeout(200000) // UnnecessaryData @@ -130,10 +130,10 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"data" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-515 : If transaction object has unnecessary data field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-515 : If transaction object has unnecessary data field, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"data" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryFeePayer @@ -146,10 +146,10 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"feePayer" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-516 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-516 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', async () => { const tx = { feePayer: testAccount.address, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feePayer" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feePayer" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryFeeRatio @@ -162,10 +162,10 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"feeRatio" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-517 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-517 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feeRatio" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryPublicKey @@ -182,14 +182,14 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"publicKey" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-518 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-518 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', ...cancelObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"publicKey" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"publicKey" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryMultisig @@ -227,7 +227,7 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"multisig" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-519 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-519 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -255,7 +255,7 @@ describe('CANCEL transaction', () => { } const tx = { multisig, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"multisig" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"multisig" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryRoleTransactionKey @@ -272,14 +272,14 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"roleTransactionKey" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-520 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-520 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleTransactionKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"roleTransactionKey" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"roleTransactionKey" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryRoleAccountUpdateKey @@ -296,14 +296,14 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"roleAccountUpdateKey" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-521 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-521 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleAccountUpdateKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"roleAccountUpdateKey" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"roleAccountUpdateKey" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryRoleFeePayerKey @@ -320,14 +320,14 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"roleFeePayerKey" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-522 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-522 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleFeePayerKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"roleFeePayerKey" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"roleFeePayerKey" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryFailKey @@ -340,10 +340,10 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"failKey" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-523 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-523 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"failKey" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"failKey" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryCodeFormat @@ -356,10 +356,10 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"codeFormat" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-524 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-524 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"codeFormat" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"codeFormat" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryLegacyKey @@ -372,10 +372,10 @@ describe('CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"legacyKey" cannot be used with CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-525 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-525 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"legacyKey" cannot be used with CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with CANCEL transaction') }).timeout(200000) // Invalid from address @@ -388,14 +388,14 @@ describe('CANCEL transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-590: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-590: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...cancelObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -407,13 +407,13 @@ describe('CANCEL transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-591: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-591: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const tx = { feePayerSignatures: [['0x01', '0x', '0x']], ...cancelObject } const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) it('CAVERJS-UNIT-TX-712: sendTransaction should throw error when try to use an account in Node with not LEGACY transaction', async () => { diff --git a/test/transactionType/contractDeploy.js b/test/transactionType/contractDeploy.js index 5adc36d8..3ebf1ef0 100644 --- a/test/transactionType/contractDeploy.js +++ b/test/transactionType/contractDeploy.js @@ -47,7 +47,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('SMART_CONTRACT_DEPLOY transaction', () => { +describe('SMART_CONTRACT_DEPLOY transaction', async () => { let deployObject beforeEach(() => { @@ -72,11 +72,11 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"from" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-423 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-423 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.from - expect(() => caver.klay.sendTransaction(tx)).to.throws('The send transactions "from" field must be defined!') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') }).timeout(200000) // MissingValue @@ -90,11 +90,11 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"value" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-424 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-424 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.value - expect(() => caver.klay.sendTransaction(tx)).to.throws('"value" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"value" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -108,11 +108,11 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"gas" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-425 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-425 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.gas - expect(() => caver.klay.sendTransaction(tx)).to.throws('"gas" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') }).timeout(200000) // MissingData @@ -126,11 +126,11 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"data" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-426 : If transaction object missing data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-426 : If transaction object missing data, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.data - expect(() => caver.klay.sendTransaction(tx)).to.throws('"data" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') }).timeout(200000) // InvalidCodeFormat @@ -143,10 +143,10 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('The codeFormat(InvalidCodeFormat) is invalid.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-427 : If transaction object has invalid codeFormat, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-427 : If transaction object has invalid codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'InvalidCodeFormat', ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('The codeFormat(InvalidCodeFormat) is invalid.') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The codeFormat(InvalidCodeFormat) is invalid.') }).timeout(200000) // UnnecessaryFeePayer @@ -159,11 +159,11 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"feePayer" cannot be used with SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-428 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-428 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', async () => { const tx = { feePayer: testAccount.address, ...deployObject } // This error return from formatter. Because in formatter discriminate fee delegation through feePayer and senderRawTransaction - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feePayer" cannot be used with SMART_CONTRACT_DEPLOY transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feePayer" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryFeeRatio @@ -176,10 +176,10 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"feeRatio" cannot be used with SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-429 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-429 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feeRatio" cannot be used with SMART_CONTRACT_DEPLOY transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryPublicKey @@ -196,14 +196,14 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"publicKey" cannot be used with SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-430 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-430 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', ...deployObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"publicKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"publicKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryMultisig @@ -241,7 +241,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"multisig" cannot be used with SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-431 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-431 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -269,7 +269,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { } const tx = { multisig, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"multisig" cannot be used with SMART_CONTRACT_DEPLOY transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"multisig" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryRoleTransactionKey @@ -286,14 +286,16 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"roleTransactionKey" cannot be used with SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-432 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-432 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleTransactionKey, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"roleTransactionKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"roleTransactionKey" cannot be used with SMART_CONTRACT_DEPLOY transaction' + ) }).timeout(200000) // UnnecessaryRoleAccountUpdateKey @@ -310,14 +312,14 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"roleAccountUpdateKey" cannot be used with SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-433 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-433 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleAccountUpdateKey, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleAccountUpdateKey" cannot be used with SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -336,14 +338,16 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"roleFeePayerKey" cannot be used with SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-434 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-434 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleFeePayerKey, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"roleFeePayerKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"roleFeePayerKey" cannot be used with SMART_CONTRACT_DEPLOY transaction' + ) }).timeout(200000) // UnnecessaryFailKey @@ -356,10 +360,10 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"failKey" cannot be used with SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-435 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-435 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"failKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"failKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryLegacyKey @@ -372,10 +376,10 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"legacyKey" cannot be used with SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-436 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-436 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"legacyKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryTo @@ -388,10 +392,10 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"to" cannot be used with SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-569 : If transaction object has unnecessary to field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-569 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: '0x5e008646fde91fb6eda7b1fdabc7d84649125cf5', ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"to" cannot be used with SMART_CONTRACT_DEPLOY transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) it('CAVERJS-UNIT-TX-577: If data field of transaction is not 0x-hex prefixed, signTransaction should formatting and sign', async () => { @@ -423,14 +427,14 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-592: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-592: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...deployObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -442,13 +446,13 @@ describe('SMART_CONTRACT_DEPLOY transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-593: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-593: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const tx = { feePayerSignatures: [['0x01', '0x', '0x']], ...deployObject } const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) it('CAVERJS-UNIT-TX-713: sendTransaction should throw error when try to use an account in Node with not LEGACY transaction', async () => { diff --git a/test/transactionType/contractExecution.js b/test/transactionType/contractExecution.js index 9fa1e826..49f0ac78 100644 --- a/test/transactionType/contractExecution.js +++ b/test/transactionType/contractExecution.js @@ -26,7 +26,7 @@ let senderPrvKey let senderAddress let testAccount -describe('SMART_CONTRACT_EXECUTION transaction', () => { +describe('SMART_CONTRACT_EXECUTION transaction', async () => { let executionObject let contractAddress @@ -76,11 +76,11 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"from" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-467 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-467 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.from - expect(() => caver.klay.sendTransaction(tx)).to.throws('The send transactions "from" field must be defined!') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') }).timeout(200000) // MissingTo @@ -94,11 +94,11 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"to" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-468 : If transaction object missing to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-468 : If transaction object missing to, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.to - expect(() => caver.klay.sendTransaction(tx)).to.throws('"to" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -112,11 +112,11 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"gas" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-469 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-469 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.gas - expect(() => caver.klay.sendTransaction(tx)).to.throws('"gas" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') }).timeout(200000) // MissingData @@ -130,11 +130,11 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"data" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-470 : If transaction object missing data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-470 : If transaction object missing data, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.data - expect(() => caver.klay.sendTransaction(tx)).to.throws('"data" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') }).timeout(200000) // UnnecessaryFeePayer @@ -147,11 +147,13 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"feePayer" cannot be used with SMART_CONTRACT_EXECUTION transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-471 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-471 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', async () => { const tx = { feePayer: testAccount.address, ...executionObject } // This error return from formatter. Because in formatter discriminate fee delegation through feePayer and senderRawTransaction - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feePayer" cannot be used with SMART_CONTRACT_EXECUTION transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"feePayer" cannot be used with SMART_CONTRACT_EXECUTION transaction' + ) }).timeout(200000) // UnnecessaryFeeRatio @@ -164,10 +166,12 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"feeRatio" cannot be used with SMART_CONTRACT_EXECUTION transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-472 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-472 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feeRatio" cannot be used with SMART_CONTRACT_EXECUTION transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"feeRatio" cannot be used with SMART_CONTRACT_EXECUTION transaction' + ) }).timeout(200000) // UnnecessaryPublicKey @@ -184,14 +188,16 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"publicKey" cannot be used with SMART_CONTRACT_EXECUTION transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-473 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-473 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', ...executionObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"publicKey" cannot be used with SMART_CONTRACT_EXECUTION transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"publicKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' + ) }).timeout(200000) // UnnecessaryMultisig @@ -229,7 +235,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"multisig" cannot be used with SMART_CONTRACT_EXECUTION transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-474 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-474 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -257,7 +263,9 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { } const tx = { multisig, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"multisig" cannot be used with SMART_CONTRACT_EXECUTION transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"multisig" cannot be used with SMART_CONTRACT_EXECUTION transaction' + ) }).timeout(200000) // UnnecessaryRoleTransactionKey @@ -274,14 +282,14 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"roleTransactionKey" cannot be used with SMART_CONTRACT_EXECUTION transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-475 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-475 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleTransactionKey, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleTransactionKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -300,14 +308,14 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"roleAccountUpdateKey" cannot be used with SMART_CONTRACT_EXECUTION transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-476 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-476 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleAccountUpdateKey, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleAccountUpdateKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -326,14 +334,16 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"roleFeePayerKey" cannot be used with SMART_CONTRACT_EXECUTION transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-477 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-477 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleFeePayerKey, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"roleFeePayerKey" cannot be used with SMART_CONTRACT_EXECUTION transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"roleFeePayerKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' + ) }).timeout(200000) // UnnecessaryFailKey @@ -346,10 +356,12 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"failKey" cannot be used with SMART_CONTRACT_EXECUTION transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-478 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-478 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"failKey" cannot be used with SMART_CONTRACT_EXECUTION transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"failKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' + ) }).timeout(200000) // UnnecessaryCodeFormat @@ -362,10 +374,12 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"codeFormat" cannot be used with SMART_CONTRACT_EXECUTION transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-479 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-479 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"codeFormat" cannot be used with SMART_CONTRACT_EXECUTION transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"codeFormat" cannot be used with SMART_CONTRACT_EXECUTION transaction' + ) }).timeout(200000) // UnnecessaryLegacyKey @@ -378,10 +392,12 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"legacyKey" cannot be used with SMART_CONTRACT_EXECUTION transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-480 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-480 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"legacyKey" cannot be used with SMART_CONTRACT_EXECUTION transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"legacyKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' + ) }).timeout(200000) // Invalid from address @@ -394,14 +410,14 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-594: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-594: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...executionObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -413,13 +429,13 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-595: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-595: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const tx = { feePayerSignatures: [['0x01', '0x', '0x']], ...executionObject } const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // InvalidTo @@ -433,7 +449,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, senderPrvKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-596: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-596: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const invalidTo = 'invalid' const tx = { ...executionObject } tx.to = invalidTo @@ -441,7 +457,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) it('CAVERJS-UNIT-TX-714: sendTransaction should throw error when try to use an account in Node with not LEGACY transaction', async () => { diff --git a/test/transactionType/feeDelegatedAccountUpdate.js b/test/transactionType/feeDelegatedAccountUpdate.js index 4cb2fafd..0cdc0683 100644 --- a/test/transactionType/feeDelegatedAccountUpdate.js +++ b/test/transactionType/feeDelegatedAccountUpdate.js @@ -28,7 +28,7 @@ let senderAddress let payerAddress let testAccount -describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { +describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { let accountUpdateObject let publicKey let publicKey2 @@ -105,11 +105,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('"from" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-265 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-265 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.from - expect(() => caver.klay.sendTransaction(tx)).to.throws('The send transactions "from" field must be defined!') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') }).timeout(200000) // UnnecessaryTo @@ -122,10 +122,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('"to" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-266 : If transaction object has to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-266 : If transaction object has to, sendTransaction should throw error', async () => { const tx = { publicKey, to: senderAddress, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"to" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') }).timeout(200000) // UnnecessaryValue @@ -138,10 +138,12 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('"value" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-267 : If transaction object has value, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-267 : If transaction object has value, sendTransaction should throw error', async () => { const tx = { publicKey, value: 1, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"value" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"value" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' + ) }).timeout(200000) // MissingGas @@ -155,11 +157,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('"gas" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-268 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-268 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.gas - expect(() => caver.klay.sendTransaction(tx)).to.throws('"gas" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') }).timeout(200000) // MissingKey @@ -172,10 +174,12 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('Missing key information with FEE_DELEGATED_ACCOUNT_UPDATE transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-269 : If transaction object missing key information, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-269 : If transaction object missing key information, sendTransaction should throw error', async () => { const tx = { ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('Missing key information with FEE_DELEGATED_ACCOUNT_UPDATE transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + 'Missing key information with FEE_DELEGATED_ACCOUNT_UPDATE transaction' + ) }).timeout(200000) // PublicKey @@ -274,10 +278,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-275 : If transaction object has multisig and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-275 : If transaction object has multisig and publicKey, sendTransaction should throw error', async () => { const tx = { publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -329,10 +333,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-277 : If transaction object has roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-277 : If transaction object has roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -347,10 +351,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-278 : If transaction object has roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-278 : If transaction object has roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -365,10 +369,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-279 : If transaction object has roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-279 : If transaction object has roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -457,10 +461,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-282 : If transaction object has roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-282 : If transaction object has roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -475,10 +479,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-283 : If transaction object has roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-283 : If transaction object has roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -493,10 +497,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-284 : If transaction object has roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-284 : If transaction object has roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -511,10 +515,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-285 : If transaction object has roleAccountUpdateKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-285 : If transaction object has roleAccountUpdateKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -529,10 +533,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-286 : If transaction object has roleAccountUpdateKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-286 : If transaction object has roleAccountUpdateKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -553,7 +557,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-287 : If transaction object has roleAccountUpdateKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-287 : If transaction object has roleAccountUpdateKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -562,7 +566,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -728,10 +732,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-292 : If transaction object has roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-292 : If transaction object has roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -746,10 +750,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-293 : If transaction object has roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-293 : If transaction object has roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -764,10 +768,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-294 : If transaction object has roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-294 : If transaction object has roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -782,10 +786,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-295 : If transaction object has roleFeePayerKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-295 : If transaction object has roleFeePayerKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -800,10 +804,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-296 : If transaction object has roleFeePayerKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-296 : If transaction object has roleFeePayerKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -824,7 +828,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-297 : If transaction object has roleFeePayerKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-297 : If transaction object has roleFeePayerKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, @@ -833,7 +837,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -848,10 +852,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-298 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-298 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -866,10 +870,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-299 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-299 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -890,7 +894,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-300 : If transaction object has roleFeePayerKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-300 : If transaction object has roleFeePayerKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, @@ -899,7 +903,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -920,7 +924,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-301 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-301 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -929,7 +933,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -950,7 +954,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-302 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-302 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -959,7 +963,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -981,7 +985,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-303 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-303 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -991,7 +995,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1023,10 +1027,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-305 : If transaction object has failKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-305 : If transaction object has failKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1041,10 +1045,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-306 : If transaction object has failKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-306 : If transaction object has failKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1059,10 +1063,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-307 : If transaction object has failKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-307 : If transaction object has failKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1077,10 +1081,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-308 : If transaction object has failKey and roleTransactionKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-308 : If transaction object has failKey and roleTransactionKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1095,10 +1099,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-309 : If transaction object has failKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-309 : If transaction object has failKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1113,10 +1117,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-310 : If transaction object has failKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-310 : If transaction object has failKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1131,10 +1135,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-311 : If transaction object has failKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-311 : If transaction object has failKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1149,10 +1153,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-312 : If transaction object has failKey and roleAccountUpdateKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-312 : If transaction object has failKey and roleAccountUpdateKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1167,10 +1171,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-313 : If transaction object has failKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-313 : If transaction object has failKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1185,10 +1189,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-314 : If transaction object has failKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-314 : If transaction object has failKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1203,10 +1207,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-315 : If transaction object has failKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-315 : If transaction object has failKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1221,10 +1225,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-316 : If transaction object has failKey and roleFeePayerKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-316 : If transaction object has failKey and roleFeePayerKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1239,10 +1243,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-317 : If transaction object has failKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-317 : If transaction object has failKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1257,10 +1261,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-318 : If transaction object has failKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-318 : If transaction object has failKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1275,10 +1279,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-319 : If transaction object has failKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-319 : If transaction object has failKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1299,7 +1303,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-320 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-320 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1308,7 +1312,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1329,7 +1333,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-321 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-321 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1338,7 +1342,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1360,7 +1364,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-322 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-322 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1370,7 +1374,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1391,7 +1395,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-323 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-323 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1400,7 +1404,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1421,7 +1425,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-324 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-324 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1430,7 +1434,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1452,7 +1456,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-325 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-325 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1462,7 +1466,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1483,7 +1487,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-326 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-326 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, @@ -1492,7 +1496,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1513,7 +1517,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-327 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-327 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, @@ -1522,7 +1526,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1544,7 +1548,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-328 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-328 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, @@ -1554,7 +1558,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1576,7 +1580,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-329 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-329 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1586,7 +1590,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1608,7 +1612,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-330 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-330 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1618,7 +1622,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1641,7 +1645,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-331 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-331 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1652,7 +1656,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1667,10 +1671,12 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('"data" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-332 : If transaction object has data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-332 : If transaction object has data, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"data" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"data" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' + ) }).timeout(200000) // Error feePayer missing (A check on the feePayer is performed when the feePayer attempts to sign the rawTransaction after sender signed.) @@ -1693,10 +1699,12 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('"feeRatio" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-335 : If transaction object has feeRatio, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-335 : If transaction object has feeRatio, sendTransaction should throw error', async () => { const tx = { feeRatio: 20, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feeRatio" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"feeRatio" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' + ) }).timeout(200000) // UnnecessaryCodeFormat @@ -1709,10 +1717,12 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('"codeFormat" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-336 : If transaction object has codeFormat, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-336 : If transaction object has codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"codeFormat" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"codeFormat" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' + ) }).timeout(200000) // Update account with legacyKey @@ -1741,11 +1751,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-338 : If transaction object has legacyKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-338 : If transaction object has legacyKey and publicKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1760,11 +1770,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-339 : If transaction object has legacyKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-339 : If transaction object has legacyKey and multisig, sendTransaction should throw error', async () => { const tx = { legacyKey: true, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1779,11 +1789,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-340 : If transaction object has legacyKey and failKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-340 : If transaction object has legacyKey and failKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, failKey: true, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1798,11 +1808,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-341 : If transaction object has legacyKey and roleTransactionKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-341 : If transaction object has legacyKey and roleTransactionKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, roleTransactionKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1817,11 +1827,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-342 : If transaction object has legacyKey and roleAccountUpdateKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-342 : If transaction object has legacyKey and roleAccountUpdateKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, roleAccountUpdateKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1836,11 +1846,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { .catch(err => expect(err.message).to.equals('The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-343 : If transaction object has legacyKey and roleFeePayerKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-343 : If transaction object has legacyKey and roleFeePayerKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, roleFeePayerKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1855,14 +1865,14 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-597: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-597: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { publicKey, ...accountUpdateObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -1893,7 +1903,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -1926,7 +1936,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedAccountUpdateWithRatio.js b/test/transactionType/feeDelegatedAccountUpdateWithRatio.js index 36447fff..1b0e1a83 100644 --- a/test/transactionType/feeDelegatedAccountUpdateWithRatio.js +++ b/test/transactionType/feeDelegatedAccountUpdateWithRatio.js @@ -23,7 +23,7 @@ const Caver = require('../../index') let caver -describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { +describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { let accountUpdateObject let senderAddress @@ -108,11 +108,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"from" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-344 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-344 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.from - expect(() => caver.klay.sendTransaction(tx)).to.throws('The send transactions "from" field must be defined!') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') }).timeout(200000) // UnnecessaryTo @@ -125,10 +125,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"to" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-345 : If transaction object has to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-345 : If transaction object has to, sendTransaction should throw error', async () => { const tx = { publicKey, to: senderAddress, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"to" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction' ) }).timeout(200000) @@ -143,10 +143,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"value" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-346 : If transaction object has value, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-346 : If transaction object has value, sendTransaction should throw error', async () => { const tx = { publicKey, value: 1, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"value" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction' ) }).timeout(200000) @@ -162,11 +162,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"gas" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-347 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-347 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.gas - expect(() => caver.klay.sendTransaction(tx)).to.throws('"gas" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') }).timeout(200000) // MissingKey @@ -179,10 +179,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('Missing key information with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-348 : If transaction object missing key information, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-348 : If transaction object missing key information, sendTransaction should throw error', async () => { const tx = { ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'Missing key information with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction' ) }).timeout(200000) @@ -285,10 +285,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-354 : If transaction object has multisig and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-354 : If transaction object has multisig and publicKey, sendTransaction should throw error', async () => { const tx = { publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -343,10 +343,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-356 : If transaction object has roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-356 : If transaction object has roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -363,10 +363,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-357 : If transaction object has roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-357 : If transaction object has roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -383,10 +383,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-358 : If transaction object has roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-358 : If transaction object has roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -479,10 +479,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-361 : If transaction object has roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-361 : If transaction object has roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -499,10 +499,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-362 : If transaction object has roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-362 : If transaction object has roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -519,10 +519,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-363 : If transaction object has roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-363 : If transaction object has roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -539,10 +539,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-364 : If transaction object has roleAccountUpdateKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-364 : If transaction object has roleAccountUpdateKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -559,10 +559,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-365 : If transaction object has roleAccountUpdateKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-365 : If transaction object has roleAccountUpdateKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -585,7 +585,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-366 : If transaction object has roleAccountUpdateKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-366 : If transaction object has roleAccountUpdateKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -594,7 +594,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -765,10 +765,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-371 : If transaction object has roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-371 : If transaction object has roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -785,10 +785,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-372 : If transaction object has roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-372 : If transaction object has roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -805,10 +805,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-373 : If transaction object has roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-373 : If transaction object has roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -825,10 +825,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-374 : If transaction object has roleFeePayerKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-374 : If transaction object has roleFeePayerKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -845,10 +845,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-375 : If transaction object has roleFeePayerKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-375 : If transaction object has roleFeePayerKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -871,7 +871,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-376 : If transaction object has roleFeePayerKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-376 : If transaction object has roleFeePayerKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, @@ -880,7 +880,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -897,10 +897,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-377 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-377 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -917,10 +917,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-378 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-378 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -943,7 +943,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-379 : If transaction object has roleFeePayerKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-379 : If transaction object has roleFeePayerKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, @@ -952,7 +952,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -975,7 +975,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-380 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-380 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -984,7 +984,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1007,7 +1007,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-381 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-381 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -1016,7 +1016,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1040,7 +1040,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-382 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-382 : If transaction object has roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, @@ -1050,7 +1050,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1084,10 +1084,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-384 : If transaction object has failKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-384 : If transaction object has failKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1104,10 +1104,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-385 : If transaction object has failKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-385 : If transaction object has failKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1124,10 +1124,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-386 : If transaction object has failKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-386 : If transaction object has failKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1144,10 +1144,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-387 : If transaction object has failKey and roleTransactionKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-387 : If transaction object has failKey and roleTransactionKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1164,10 +1164,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-388 : If transaction object has failKey, roleTransactionKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-388 : If transaction object has failKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1184,10 +1184,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-389 : If transaction object has failKey, roleTransactionKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-389 : If transaction object has failKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1204,10 +1204,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-390 : If transaction object has failKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-390 : If transaction object has failKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1224,10 +1224,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-391 : If transaction object has failKey and roleAccountUpdateKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-391 : If transaction object has failKey and roleAccountUpdateKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1244,10 +1244,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-392 : If transaction object has failKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-392 : If transaction object has failKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1264,10 +1264,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-393 : If transaction object has failKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-393 : If transaction object has failKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1284,10 +1284,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-394 : If transaction object has failKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-394 : If transaction object has failKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1304,10 +1304,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-395 : If transaction object has failKey and roleFeePayerKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-395 : If transaction object has failKey and roleFeePayerKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1324,10 +1324,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-396 : If transaction object has failKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-396 : If transaction object has failKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1344,10 +1344,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-397 : If transaction object has failKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-397 : If transaction object has failKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1364,10 +1364,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-398 : If transaction object has failKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-398 : If transaction object has failKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1390,7 +1390,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-399 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-399 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1399,7 +1399,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1422,7 +1422,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-400 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-400 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1431,7 +1431,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1455,7 +1455,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-401 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-401 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1465,7 +1465,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1488,7 +1488,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-402 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-402 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1497,7 +1497,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1520,7 +1520,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-403 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-403 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1529,7 +1529,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1553,7 +1553,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-404 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-404 : If transaction object has failKey, roleTransactionKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1563,7 +1563,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1586,7 +1586,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-405 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-405 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, @@ -1595,7 +1595,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1618,7 +1618,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-406 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-406 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, @@ -1627,7 +1627,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1651,7 +1651,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-407 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-407 : If transaction object has failKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, @@ -1661,7 +1661,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1685,7 +1685,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-408 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-408 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1695,7 +1695,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1719,7 +1719,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-409 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-409 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1729,7 +1729,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1754,7 +1754,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-410 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-410 : If transaction object has failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, @@ -1765,7 +1765,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ...accountUpdateObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1780,10 +1780,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"data" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-411 : If transaction object has data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-411 : If transaction object has data, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"data" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction' ) }).timeout(200000) @@ -1809,11 +1809,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"feeRatio" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-414 : If transaction object has feeRatio, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-414 : If transaction object has feeRatio, sendTransaction should throw error', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.feeRatio - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feeRatio" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" is missing') }).timeout(200000) // UnnecessaryCodeFormat @@ -1828,10 +1828,10 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-415 : If transaction object has codeFormat, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-415 : If transaction object has codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"codeFormat" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction' ) }).timeout(200000) @@ -1864,11 +1864,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-417 : If transaction object has legacyKey and publicKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-417 : If transaction object has legacyKey and publicKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, publicKey, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1885,11 +1885,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-418 : If transaction object has legacyKey and multisig, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-418 : If transaction object has legacyKey and multisig, sendTransaction should throw error', async () => { const tx = { legacyKey: true, multisig, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1906,11 +1906,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-419 : If transaction object has legacyKey and failKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-419 : If transaction object has legacyKey and failKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, failKey: true, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1927,11 +1927,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-420 : If transaction object has legacyKey and roleTransactionKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-420 : If transaction object has legacyKey and roleTransactionKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, roleTransactionKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1948,11 +1948,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-421 : If transaction object has legacyKey and roleAccountUpdateKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-421 : If transaction object has legacyKey and roleAccountUpdateKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, roleAccountUpdateKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1969,11 +1969,11 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-422 : If transaction object has legacyKey and roleFeePayerKey, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-422 : If transaction object has legacyKey and roleFeePayerKey, sendTransaction should throw error', async () => { const tx = { legacyKey: true, roleFeePayerKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1988,14 +1988,14 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-602: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-602: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { publicKey, ...accountUpdateObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -2026,7 +2026,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -2059,7 +2059,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedCancelTransaction.js b/test/transactionType/feeDelegatedCancelTransaction.js index 5fb45315..3df06aa8 100644 --- a/test/transactionType/feeDelegatedCancelTransaction.js +++ b/test/transactionType/feeDelegatedCancelTransaction.js @@ -45,7 +45,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('FEE_DELEGATED_CANCEL transaction', () => { +describe('FEE_DELEGATED_CANCEL transaction', async () => { let cancelObject beforeEach(() => { @@ -67,11 +67,11 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"from" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-526 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-526 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...cancelObject } delete tx.from - expect(() => caver.klay.sendTransaction(tx)).to.throws('The send transactions "from" field must be defined!') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') }).timeout(200000) // UnnecessaryTo @@ -84,10 +84,10 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"to" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-527 : If transaction object has unnecessary to field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-527 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: testAccount.address, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"to" cannot be used with FEE_DELEGATED_CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryValue @@ -100,10 +100,10 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"value" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-528 : If transaction object has unnecessary value field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-528 : If transaction object has unnecessary value field, sendTransaction should throw error', async () => { const tx = { value: 1, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"value" cannot be used with FEE_DELEGATED_CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"value" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // MissingGas @@ -117,11 +117,11 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"gas" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-529 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-529 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...cancelObject } delete tx.gas - expect(() => caver.klay.sendTransaction(tx)).to.throws('"gas" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') }).timeout(200000) // UnnecessaryData @@ -134,10 +134,10 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"data" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-530 : If transaction object has unnecessary data field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-530 : If transaction object has unnecessary data field, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"data" cannot be used with FEE_DELEGATED_CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // MissingFeePayer @@ -162,10 +162,10 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"feeRatio" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-533 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-533 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feeRatio" cannot be used with FEE_DELEGATED_CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryPublicKey @@ -182,14 +182,14 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"publicKey" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-534 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-534 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', ...cancelObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"publicKey" cannot be used with FEE_DELEGATED_CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"publicKey" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryMultisig @@ -227,7 +227,7 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"multisig" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-535 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-535 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -255,7 +255,7 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { } const tx = { multisig, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"multisig" cannot be used with FEE_DELEGATED_CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"multisig" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryRoleTransactionKey @@ -272,14 +272,16 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"roleTransactionKey" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-536 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-536 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleTransactionKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"roleTransactionKey" cannot be used with FEE_DELEGATED_CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"roleTransactionKey" cannot be used with FEE_DELEGATED_CANCEL transaction' + ) }).timeout(200000) // UnnecessaryRoleAccountUpdateKey @@ -296,14 +298,14 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-537 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-537 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleAccountUpdateKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_CANCEL transaction' ) }).timeout(200000) @@ -322,14 +324,16 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"roleFeePayerKey" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-538 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-538 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleFeePayerKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"roleFeePayerKey" cannot be used with FEE_DELEGATED_CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"roleFeePayerKey" cannot be used with FEE_DELEGATED_CANCEL transaction' + ) }).timeout(200000) // UnnecessaryFailKey @@ -342,10 +346,10 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"failKey" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-539 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-539 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"failKey" cannot be used with FEE_DELEGATED_CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"failKey" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryCodeFormat @@ -358,10 +362,10 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"codeFormat" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-540 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-540 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"codeFormat" cannot be used with FEE_DELEGATED_CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"codeFormat" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryLegacyKey @@ -374,10 +378,10 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { .catch(err => expect(err.message).to.equals('"legacyKey" cannot be used with FEE_DELEGATED_CANCEL transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-541 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-541 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"legacyKey" cannot be used with FEE_DELEGATED_CANCEL transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // Invalid from address @@ -390,14 +394,14 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-607: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-607: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...cancelObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -429,7 +433,7 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -463,7 +467,7 @@ describe('FEE_DELEGATED_CANCEL transaction', () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedCancelTransactionWithRatio.js b/test/transactionType/feeDelegatedCancelTransactionWithRatio.js index fb8e2610..c2d3b6c9 100644 --- a/test/transactionType/feeDelegatedCancelTransactionWithRatio.js +++ b/test/transactionType/feeDelegatedCancelTransactionWithRatio.js @@ -45,7 +45,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { +describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { let cancelObject beforeEach(() => { @@ -68,11 +68,11 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"from" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-542 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-542 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...cancelObject } delete tx.from - expect(() => caver.klay.sendTransaction(tx)).to.throws('The send transactions "from" field must be defined!') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') }).timeout(200000) // UnnecessaryTo @@ -85,10 +85,12 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"to" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-543 : If transaction object has unnecessary to field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-543 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: testAccount.address, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"to" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"to" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' + ) }).timeout(200000) // UnnecessaryValue @@ -101,10 +103,12 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"value" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-544 : If transaction object has unnecessary value field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-544 : If transaction object has unnecessary value field, sendTransaction should throw error', async () => { const tx = { value: 1, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"value" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"value" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' + ) }).timeout(200000) // MissingGas @@ -118,11 +122,11 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"gas" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-545 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-545 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...cancelObject } delete tx.gas - expect(() => caver.klay.sendTransaction(tx)).to.throws('"gas" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') }).timeout(200000) // UnnecessaryData @@ -135,10 +139,12 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"data" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-546 : If transaction object has unnecessary data field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-546 : If transaction object has unnecessary data field, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"data" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"data" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' + ) }).timeout(200000) // MissingFeePayer @@ -162,11 +168,11 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"feeRatio" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-549 : If transaction object missing feeRatio, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-549 : If transaction object missing feeRatio, sendTransaction should throw error', async () => { const tx = { ...cancelObject } delete tx.feeRatio - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feeRatio" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" is missing') }).timeout(200000) // UnnecessaryPublicKey @@ -183,14 +189,14 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"publicKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-550 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-550 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', ...cancelObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"publicKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -230,7 +236,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"multisig" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-551 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-551 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -258,7 +264,9 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { } const tx = { multisig, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"multisig" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"multisig" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' + ) }).timeout(200000) // UnnecessaryRoleTransactionKey @@ -277,14 +285,14 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-552 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-552 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleTransactionKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleTransactionKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -305,14 +313,14 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-553 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-553 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleAccountUpdateKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -333,14 +341,14 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-554 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-554 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleFeePayerKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleFeePayerKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -355,10 +363,12 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"failKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-555 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-555 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"failKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"failKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' + ) }).timeout(200000) // UnnecessaryCodeFormat @@ -371,10 +381,10 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"codeFormat" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-556 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-556 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"codeFormat" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -389,10 +399,10 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"legacyKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-557 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-557 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"legacyKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -407,14 +417,14 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-612: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-612: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...cancelObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -445,7 +455,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -478,7 +488,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedContractDeploy.js b/test/transactionType/feeDelegatedContractDeploy.js index 08714f68..54e1851f 100644 --- a/test/transactionType/feeDelegatedContractDeploy.js +++ b/test/transactionType/feeDelegatedContractDeploy.js @@ -54,7 +54,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { +describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { let deployObject beforeEach(() => { @@ -79,11 +79,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"from" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-437 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-437 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.from - expect(() => caver.klay.sendTransaction(tx)).to.throws('The send transactions "from" field must be defined!') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') }).timeout(200000) // MissingValue @@ -97,11 +97,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"value" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-438 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-438 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.value - expect(() => caver.klay.sendTransaction(tx)).to.throws('"value" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"value" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -115,11 +115,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"gas" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-439 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-439 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.gas - expect(() => caver.klay.sendTransaction(tx)).to.throws('"gas" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') }).timeout(200000) // MissingData @@ -133,11 +133,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"data" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-440 : If transaction object missing data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-440 : If transaction object missing data, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.data - expect(() => caver.klay.sendTransaction(tx)).to.throws('"data" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') }).timeout(200000) // InvalidCodeFormat @@ -150,10 +150,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('The codeFormat(InvalidCodeFormat) is invalid.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-441 : If transaction object has invalid codeFormat, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-441 : If transaction object has invalid codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'InvalidCodeFormat', ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('The codeFormat(InvalidCodeFormat) is invalid.') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The codeFormat(InvalidCodeFormat) is invalid.') }).timeout(200000) // MissingFeePayer @@ -177,10 +177,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"feeRatio" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-444 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-444 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"feeRatio" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -199,14 +199,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"publicKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-445 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-445 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', ...deployObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"publicKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -246,7 +246,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"multisig" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-446 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-446 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -274,7 +274,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { } const tx = { multisig, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"multisig" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -295,14 +295,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-447 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-447 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleTransactionKey, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleTransactionKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -323,14 +323,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-448 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-448 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleAccountUpdateKey, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -351,14 +351,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-449 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-449 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleFeePayerKey, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleFeePayerKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -373,10 +373,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"failKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-450 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-450 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"failKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -391,10 +391,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"legacyKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-451 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-451 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"legacyKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -409,10 +409,12 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { .catch(err => expect(err.message).to.equals('"to" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-570 : If transaction object has unnecessary to field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-570 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: '0x5e008646fde91fb6eda7b1fdabc7d84649125cf5', ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"to" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"to" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' + ) }).timeout(200000) it('CAVERJS-UNIT-TX-579: If data field of transaction is not 0x-hex prefixed, signTransaction should formatting and sign', async () => { @@ -439,14 +441,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-617: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-617: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...deployObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -477,7 +479,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -510,7 +512,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedContractDeployWithRatio.js b/test/transactionType/feeDelegatedContractDeployWithRatio.js index a6dc7b02..12c06d4a 100644 --- a/test/transactionType/feeDelegatedContractDeployWithRatio.js +++ b/test/transactionType/feeDelegatedContractDeployWithRatio.js @@ -54,7 +54,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { +describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () => { let deployObject beforeEach(() => { @@ -80,11 +80,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"from" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-452 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-452 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.from - expect(() => caver.klay.sendTransaction(tx)).to.throws('The send transactions "from" field must be defined!') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') }).timeout(200000) // MissingValue @@ -98,11 +98,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"value" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-453 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-453 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.value - expect(() => caver.klay.sendTransaction(tx)).to.throws('"value" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"value" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -116,11 +116,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"gas" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-454 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-454 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.gas - expect(() => caver.klay.sendTransaction(tx)).to.throws('"gas" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') }).timeout(200000) // MissingData @@ -134,11 +134,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"data" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-455 : If transaction object missing data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-455 : If transaction object missing data, sendTransaction should throw error', async () => { const tx = { ...deployObject } delete tx.data - expect(() => caver.klay.sendTransaction(tx)).to.throws('"data" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') }).timeout(200000) // InvalidCodeFormat @@ -151,10 +151,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('The codeFormat(InvalidCodeFormat) is invalid.')) }).timeout(200000) - it('CAVERJS-UNIT-TX-456 : If transaction object has invalid codeFormat, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-456 : If transaction object has invalid codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'InvalidCodeFormat', ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('The codeFormat(InvalidCodeFormat) is invalid.') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The codeFormat(InvalidCodeFormat) is invalid.') }).timeout(200000) // MissingFeePayer @@ -179,11 +179,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { .catch(err => expect(err.message).to.equals('"feeRatio" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-459 : If transaction object missing feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-459 : If transaction object missing feeRatio field, sendTransaction should throw error', async () => { const tx = Object.assign(deployObject) delete tx.feeRatio - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feeRatio" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" is missing') }).timeout(200000) // UnnecessaryPublicKey @@ -202,14 +202,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-460 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-460 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', ...deployObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"publicKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -251,7 +251,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-461 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-461 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -279,7 +279,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { } const tx = { multisig, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"multisig" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -302,14 +302,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-462 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-462 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleTransactionKey, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleTransactionKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -332,14 +332,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-463 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-463 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleAccountUpdateKey, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -362,14 +362,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-464 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-464 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleFeePayerKey, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleFeePayerKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -386,10 +386,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-465 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-465 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"failKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -406,10 +406,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-466 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-466 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"legacyKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -426,10 +426,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-571 : If transaction object has unnecessary to field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-571 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: '0x5e008646fde91fb6eda7b1fdabc7d84649125cf5', ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"to" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -458,14 +458,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-622: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-622: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...deployObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -496,7 +496,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -529,7 +529,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedContractExecution.js b/test/transactionType/feeDelegatedContractExecution.js index b37f8e82..98796e5d 100644 --- a/test/transactionType/feeDelegatedContractExecution.js +++ b/test/transactionType/feeDelegatedContractExecution.js @@ -27,7 +27,7 @@ let senderPrvKey let payerPrvKey let testAccount -describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { +describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { let executionObject let contractAddress @@ -84,11 +84,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"from" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-481 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-481 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.from - expect(() => caver.klay.sendTransaction(tx)).to.throws('The send transactions "from" field must be defined!') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') }).timeout(200000) // MissingTo @@ -102,11 +102,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"to" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-482 : If transaction object missing to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-482 : If transaction object missing to, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.to - expect(() => caver.klay.sendTransaction(tx)).to.throws('"to" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -120,11 +120,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"gas" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-483 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-483 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.gas - expect(() => caver.klay.sendTransaction(tx)).to.throws('"gas" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') }).timeout(200000) // MissingData @@ -138,11 +138,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"data" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-484 : If transaction object missing data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-484 : If transaction object missing data, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.data - expect(() => caver.klay.sendTransaction(tx)).to.throws('"data" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') }).timeout(200000) // MissingFeePayer @@ -167,10 +167,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-487 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-487 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"feeRatio" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -191,14 +191,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-488 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-488 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', ...executionObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"publicKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -240,7 +240,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-489 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-489 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -268,7 +268,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { } const tx = { multisig, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"multisig" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -289,14 +289,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-490 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-490 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleTransactionKey, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleTransactionKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -319,14 +319,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-491 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-491 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleAccountUpdateKey, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -347,14 +347,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-492 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-492 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleFeePayerKey, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleFeePayerKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -369,10 +369,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { .catch(err => expect(err.message).to.equals('"failKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-493 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-493 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"failKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -389,10 +389,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-494 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-494 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"codeFormat" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -409,10 +409,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-495 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-495 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"legacyKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -427,14 +427,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-627: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-627: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...executionObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -465,7 +465,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -498,7 +498,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // InvalidTo @@ -512,7 +512,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, senderPrvKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-630: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-630: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const invalidTo = 'invalid' const tx = { ...executionObject } tx.to = invalidTo @@ -520,7 +520,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedContractExecutionWithRatio.js b/test/transactionType/feeDelegatedContractExecutionWithRatio.js index 25879013..a79151bf 100644 --- a/test/transactionType/feeDelegatedContractExecutionWithRatio.js +++ b/test/transactionType/feeDelegatedContractExecutionWithRatio.js @@ -27,7 +27,7 @@ let senderPrvKey let payerPrvKey let testAccount -describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => { +describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async () => { let executionObject let contractAddress @@ -85,11 +85,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => .catch(err => expect(err.message).to.equals('"from" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-496 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-496 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.from - expect(() => caver.klay.sendTransaction(tx)).to.throws('The send transactions "from" field must be defined!') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') }).timeout(200000) // MissingTo @@ -103,11 +103,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => .catch(err => expect(err.message).to.equals('"to" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-497 : If transaction object missing to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-497 : If transaction object missing to, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.to - expect(() => caver.klay.sendTransaction(tx)).to.throws('"to" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -121,11 +121,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => .catch(err => expect(err.message).to.equals('"gas" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-498 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-498 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.gas - expect(() => caver.klay.sendTransaction(tx)).to.throws('"gas" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') }).timeout(200000) // MissingData @@ -139,11 +139,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => .catch(err => expect(err.message).to.equals('"data" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-499 : If transaction object missing data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-499 : If transaction object missing data, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.data - expect(() => caver.klay.sendTransaction(tx)).to.throws('"data" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') }).timeout(200000) // MissingFeePayer @@ -167,11 +167,11 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => .catch(err => expect(err.message).to.equals('"feeRatio" is missing')) }).timeout(200000) - it('CAVERJS-UNIT-TX-502 : If transaction object missing feeRatio, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-502 : If transaction object missing feeRatio, sendTransaction should throw error', async () => { const tx = { ...executionObject } delete tx.feeRatio - expect(() => caver.klay.sendTransaction(tx)).to.throws('"feeRatio" is missing') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" is missing') }).timeout(200000) // UnnecessaryPublicKey @@ -192,14 +192,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => ) }).timeout(200000) - it('CAVERJS-UNIT-TX-503 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-503 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', ...executionObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"publicKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -243,7 +243,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => ) }).timeout(200000) - it('CAVERJS-UNIT-TX-504 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-504 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -271,7 +271,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => } const tx = { multisig, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"multisig" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -294,14 +294,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => ) }).timeout(200000) - it('CAVERJS-UNIT-TX-505 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-505 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleTransactionKey, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleTransactionKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -324,14 +324,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => ) }).timeout(200000) - it('CAVERJS-UNIT-TX-506 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-506 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleAccountUpdateKey, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -354,14 +354,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => ) }).timeout(200000) - it('CAVERJS-UNIT-TX-507 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-507 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', } const tx = { roleFeePayerKey, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"roleFeePayerKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -378,10 +378,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => ) }).timeout(200000) - it('CAVERJS-UNIT-TX-508 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-508 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"failKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -400,10 +400,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => ) }).timeout(200000) - it('CAVERJS-UNIT-TX-509 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-509 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"codeFormat" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -422,10 +422,10 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => ) }).timeout(200000) - it('CAVERJS-UNIT-TX-510 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-510 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"legacyKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -440,14 +440,14 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-633: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-633: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...executionObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -478,7 +478,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -511,7 +511,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // InvalidTo @@ -525,7 +525,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => await expect(caver.klay.accounts.signTransaction(tx, senderPrvKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-636: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-636: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const invalidTo = 'invalid' const tx = { ...executionObject } tx.to = invalidTo @@ -533,7 +533,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', () => const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedValueTransfer.js b/test/transactionType/feeDelegatedValueTransfer.js index 8badf3ab..c66f50d5 100644 --- a/test/transactionType/feeDelegatedValueTransfer.js +++ b/test/transactionType/feeDelegatedValueTransfer.js @@ -50,7 +50,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { +describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { let feeDelegatedValueTransferObject beforeEach(() => { @@ -97,12 +97,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-035 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-035 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferObject } delete tx.from // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error to missing @@ -118,12 +118,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-036 : If transaction object missing to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-036 : If transaction object missing to, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferObject } delete tx.to // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error value missing @@ -139,12 +139,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-037 : If transaction object missing value, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-037 : If transaction object missing value, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferObject } delete tx.value // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error gas and gasLimit missing @@ -160,16 +160,16 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-038 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-038 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferObject } delete tx.gas // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error feePayer missing (A check on the feePayer is performed when the feePayer attempts to sign the rawTransaction after sender signed.) - it('CAVERJS-UNIT-TX-039 : If transaction object missing feePayer, signTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-039 : If transaction object missing feePayer, signTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferObject } caver.klay.accounts.signTransaction(tx, senderPrvKey).then(ret => { @@ -178,7 +178,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { }).timeout(200000) // Error senderRawTransaction missing (A check on the senderRawTransaction is performed when the feePayer attempts to sign the rawTransaction after sender signed.) - it('CAVERJS-UNIT-TX-040 : If transaction object missing senderRawTransaction, signTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-040 : If transaction object missing senderRawTransaction, signTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferObject } caver.klay.accounts.signTransaction(tx, senderPrvKey).then(() => { @@ -198,11 +198,11 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-041 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-041 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 20, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary publicKey @@ -221,7 +221,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-042 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-042 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', @@ -229,7 +229,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary multisig @@ -269,7 +269,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-043 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-043 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -298,7 +298,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { const tx = { multisig, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -317,7 +317,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-044 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-044 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -325,7 +325,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { const tx = { roleTransactionKey, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -344,7 +344,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-045 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-045 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -352,7 +352,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { const tx = { roleAccountUpdateKey, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -371,7 +371,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-046 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-046 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -379,7 +379,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { const tx = { roleFeePayerKey, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary failKey @@ -394,11 +394,11 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-047 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-047 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary codeFormat @@ -413,11 +413,11 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-048 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-048 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...feeDelegatedValueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary data @@ -434,13 +434,13 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-049 : If transaction object has unnecessary data field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-049 : If transaction object has unnecessary data field, sendTransaction should throw error', async () => { const data = '0x6080604052348015600f57600080fd5b5060e98061001e6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063954ab4b2146044575b600080fd5b348015604f57600080fd5b5060566058565b005b7f90a042becc42ba1b13a5d545701bf5ceff20b24d9e5cc63b67f96ef814d80f0933604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a15600a165627a7a723058200ebb53e9d575350ceb2d92263b7d4920888706b5221f024e7bbc10e3dbb8e18d0029' const tx = { data, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // UnnecessaryLegacyKey @@ -453,10 +453,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { .catch(err => expect(err.message).to.equals('"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-560 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-560 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...feeDelegatedValueTransferObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + '"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER transaction' + ) }).timeout(200000) // Invalid from address @@ -469,14 +471,14 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-639: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-639: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -507,7 +509,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -540,7 +542,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // InvalidTo @@ -554,7 +556,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, senderPrvKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-642: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-642: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const invalidTo = 'invalid' const tx = { ...feeDelegatedValueTransferObject } tx.to = invalidTo @@ -562,7 +564,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedValueTransferMemo.js b/test/transactionType/feeDelegatedValueTransferMemo.js index 4c857957..41371e5c 100644 --- a/test/transactionType/feeDelegatedValueTransferMemo.js +++ b/test/transactionType/feeDelegatedValueTransferMemo.js @@ -50,7 +50,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { +describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { let feeDelegatedValueTransferMemoObject beforeEach(() => { @@ -98,12 +98,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-079 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-079 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoObject } delete tx.from // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error to missing @@ -120,12 +120,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-080 : If transaction object missing to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-080 : If transaction object missing to, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoObject } delete tx.to // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error value missing @@ -142,12 +142,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-081 : If transaction object missing value, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-081 : If transaction object missing value, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoObject } delete tx.value // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error gas and gasLimit missing @@ -164,12 +164,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-082 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-082 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoObject } delete tx.gas // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error data missing @@ -186,16 +186,16 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-083 : If transaction object missing data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-083 : If transaction object missing data, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoObject } delete tx.data // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error feePayer missing (A check on the feePayer is performed when the feePayer attempts to sign the rawTransaction after sender signed.) - it('CAVERJS-UNIT-TX-084 : If transaction object missing feePayer, signTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-084 : If transaction object missing feePayer, signTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoObject } caver.klay.accounts.signTransaction(tx, senderPrvKey).then(ret => { @@ -204,7 +204,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { }).timeout(200000) // Error senderRawTransaction missing (A check on the senderRawTransaction is performed when the feePayer attempts to sign the rawTransaction after sender signed.) - it('CAVERJS-UNIT-TX-085 : If transaction object missing senderRawTransaction, signTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-085 : If transaction object missing senderRawTransaction, signTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoObject } caver.klay.accounts.signTransaction(tx, senderPrvKey).then(() => { @@ -225,11 +225,11 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-086 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-086 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 20, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary publicKey @@ -249,7 +249,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-087 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-087 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', @@ -257,7 +257,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary multisig @@ -298,7 +298,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-088 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-088 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -327,7 +327,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { const tx = { multisig, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -347,7 +347,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-089 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-089 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -355,7 +355,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { const tx = { roleTransactionKey, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -375,7 +375,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-090 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-090 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -383,7 +383,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { const tx = { roleAccountUpdateKey, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -403,7 +403,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-091 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-091 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -411,7 +411,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { const tx = { roleFeePayerKey, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary failKey @@ -427,11 +427,11 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-092 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-092 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary codeFormat @@ -447,11 +447,11 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-093 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-093 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // UnnecessaryLegacyKey @@ -464,10 +464,10 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { .catch(err => expect(err.message).to.equals('"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-563 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-563 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...feeDelegatedValueTransferMemoObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction' ) }).timeout(200000) @@ -482,14 +482,14 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-651: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-651: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -521,7 +521,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -554,7 +554,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // InvalidTo @@ -568,7 +568,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, senderPrvKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-654: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-654: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const invalidTo = 'invalid' const tx = { ...feeDelegatedValueTransferMemoObject } tx.to = invalidTo @@ -576,7 +576,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedValueTransferMemoWithRatio.js b/test/transactionType/feeDelegatedValueTransferMemoWithRatio.js index 3fe52f5d..2b502546 100644 --- a/test/transactionType/feeDelegatedValueTransferMemoWithRatio.js +++ b/test/transactionType/feeDelegatedValueTransferMemoWithRatio.js @@ -50,7 +50,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { +describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => { let feeDelegatedValueTransferMemoWithRatioObject beforeEach(() => { @@ -99,12 +99,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-094 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-094 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoWithRatioObject } delete tx.from // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error to missing @@ -121,12 +121,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-095 : If transaction object missing to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-095 : If transaction object missing to, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoWithRatioObject } delete tx.to // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error value missing @@ -143,12 +143,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-096 : If transaction object missing value, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-096 : If transaction object missing value, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoWithRatioObject } delete tx.value // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error gas and gasLimit missing @@ -165,12 +165,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-097 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-097 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoWithRatioObject } delete tx.gas // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error data missing @@ -187,16 +187,16 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-098 : If transaction object missing data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-098 : If transaction object missing data, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoWithRatioObject } delete tx.data // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error feePayer missing (A check on the feePayer is performed when the feePayer attempts to sign the rawTransaction after sender signed.) - it('CAVERJS-UNIT-TX-099 : If transaction object missing feePayer, signTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-099 : If transaction object missing feePayer, signTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoWithRatioObject } caver.klay.accounts.signTransaction(tx, senderPrvKey).then(ret => { @@ -205,7 +205,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { }).timeout(200000) // Error senderRawTransaction missing (A check on the senderRawTransaction is performed when the feePayer attempts to sign the rawTransaction after sender signed.) - it('CAVERJS-UNIT-TX-100 : If transaction object missing senderRawTransaction, signTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-100 : If transaction object missing senderRawTransaction, signTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoWithRatioObject } caver.klay.accounts.signTransaction(tx, senderPrvKey).then(() => { @@ -227,12 +227,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-101 : If transaction object missing feeRatio, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-101 : If transaction object missing feeRatio, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoWithRatioObject } delete tx.feeRatio // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary publicKey @@ -252,7 +252,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-102 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-102 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', @@ -260,7 +260,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary multisig @@ -301,7 +301,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-103 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-103 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -330,7 +330,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { const tx = { multisig, ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -350,7 +350,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-104 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-104 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -358,7 +358,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { const tx = { roleTransactionKey, ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -378,7 +378,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-105 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-105 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -386,7 +386,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { const tx = { roleAccountUpdateKey, ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -406,7 +406,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-106 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-106 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -414,7 +414,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { const tx = { roleFeePayerKey, ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary failKey @@ -430,11 +430,11 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-107 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-107 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary codeFormat @@ -450,11 +450,11 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-108 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-108 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // UnnecessaryLegacyKey @@ -469,10 +469,10 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-564 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-564 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...feeDelegatedValueTransferMemoWithRatioObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction' ) }).timeout(200000) @@ -487,14 +487,14 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-657: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-657: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferMemoWithRatioObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -526,7 +526,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -559,7 +559,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // InvalidTo @@ -573,7 +573,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, senderPrvKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-660: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-660: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const invalidTo = 'invalid' const tx = { ...feeDelegatedValueTransferMemoWithRatioObject } tx.to = invalidTo @@ -581,7 +581,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedValueTransferWithRatio.js b/test/transactionType/feeDelegatedValueTransferWithRatio.js index dc3ed8b2..8b2f8a00 100644 --- a/test/transactionType/feeDelegatedValueTransferWithRatio.js +++ b/test/transactionType/feeDelegatedValueTransferWithRatio.js @@ -50,7 +50,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { +describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { let feeDelegatedValueTransferWithRatioObject beforeEach(() => { @@ -98,12 +98,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-050 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-050 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferWithRatioObject } delete tx.from // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error to missing @@ -120,12 +120,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-051 : If transaction object missing to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-051 : If transaction object missing to, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferWithRatioObject } delete tx.to // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error value missing @@ -142,12 +142,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-052 : If transaction object missing value, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-052 : If transaction object missing value, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferWithRatioObject } delete tx.value // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error gas and gasLimit missing @@ -164,16 +164,16 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-053 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-053 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferWithRatioObject } delete tx.gas // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error feePayer missing (A check on the feePayer is performed when the feePayer attempts to sign the rawTransaction after sender signed.) - it('CAVERJS-UNIT-TX-054 : If transaction object missing feePayer, signTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-054 : If transaction object missing feePayer, signTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferWithRatioObject } caver.klay.accounts.signTransaction(tx, senderPrvKey).then(ret => { @@ -182,7 +182,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { }).timeout(200000) // Error senderRawTransaction missing (A check on the senderRawTransaction is performed when the feePayer attempts to sign the rawTransaction after sender signed.) - it('CAVERJS-UNIT-TX-055 : If transaction object missing senderRawTransaction, signTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-055 : If transaction object missing senderRawTransaction, signTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferWithRatioObject } caver.klay.accounts.signTransaction(tx, senderPrvKey).then(() => { @@ -204,12 +204,12 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-056 : If transaction object missing feeRatio, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-056 : If transaction object missing feeRatio, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferWithRatioObject } delete tx.feeRatio // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary publicKey @@ -229,7 +229,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-057 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-057 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', @@ -237,7 +237,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary multisig @@ -278,7 +278,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-058 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-058 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -307,7 +307,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { const tx = { multisig, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -327,7 +327,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-059 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-059 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -335,7 +335,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { const tx = { roleTransactionKey, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -355,7 +355,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-060 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-060 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -363,7 +363,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { const tx = { roleAccountUpdateKey, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -383,7 +383,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-061 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-061 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -391,7 +391,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { const tx = { roleFeePayerKey, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary failKey @@ -407,11 +407,11 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-062 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-062 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary codeFormat @@ -427,11 +427,11 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-063 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-063 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary data @@ -449,13 +449,13 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-064 : If transaction object has unnecessary data field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-064 : If transaction object has unnecessary data field, sendTransaction should throw error', async () => { const data = '0x6080604052348015600f57600080fd5b5060e98061001e6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063954ab4b2146044575b600080fd5b348015604f57600080fd5b5060566058565b005b7f90a042becc42ba1b13a5d545701bf5ceff20b24d9e5cc63b67f96ef814d80f0933604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a15600a165627a7a723058200ebb53e9d575350ceb2d92263b7d4920888706b5221f024e7bbc10e3dbb8e18d0029' const tx = { data, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // UnnecessaryLegacyKey @@ -470,10 +470,10 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { ) }).timeout(200000) - it('CAVERJS-UNIT-TX-561 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-561 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...feeDelegatedValueTransferWithRatioObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws( + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( '"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction' ) }).timeout(200000) @@ -488,14 +488,14 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-645: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-645: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...feeDelegatedValueTransferWithRatioObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -527,7 +527,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -560,7 +560,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // InvalidTo @@ -574,7 +574,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, senderPrvKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-648: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-648: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const invalidTo = 'invalid' const tx = { ...feeDelegatedValueTransferWithRatioObject } tx.to = invalidTo @@ -582,7 +582,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/legacyTransaction.js b/test/transactionType/legacyTransaction.js index a63769d6..b4126b19 100644 --- a/test/transactionType/legacyTransaction.js +++ b/test/transactionType/legacyTransaction.js @@ -41,7 +41,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('LEGACY transaction', () => { +describe('LEGACY transaction', async () => { let legacyObject beforeEach(() => { @@ -93,12 +93,12 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-009 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-009 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...legacyObject } delete tx.from // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error gas and gasLimit missing @@ -114,12 +114,12 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-010 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-010 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...legacyObject } delete tx.gas // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error to and data missing @@ -136,13 +136,13 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-011 : If transaction object missing to and data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-011 : If transaction object missing to and data, sendTransaction should throw error', async () => { const tx = { ...legacyObject } delete tx.to delete tx.data // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary feePayer @@ -157,11 +157,11 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-012 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-012 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', async () => { const tx = { feePayer: testAccount.address, ...legacyObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary feeRatio @@ -176,11 +176,11 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-013 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-013 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 20, ...legacyObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary publicKey @@ -199,7 +199,7 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-014 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-014 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', @@ -207,7 +207,7 @@ describe('LEGACY transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary multisig @@ -247,7 +247,7 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-015 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-015 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -276,7 +276,7 @@ describe('LEGACY transaction', () => { const tx = { multisig, ...legacyObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -295,7 +295,7 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-016 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-016 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -303,7 +303,7 @@ describe('LEGACY transaction', () => { const tx = { roleTransactionKey, ...legacyObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -322,7 +322,7 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-017 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-017 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -330,7 +330,7 @@ describe('LEGACY transaction', () => { const tx = { roleAccountUpdateKey, ...legacyObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -349,7 +349,7 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-018 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-018 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -357,7 +357,7 @@ describe('LEGACY transaction', () => { const tx = { roleFeePayerKey, ...legacyObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary failKey @@ -372,11 +372,11 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-019 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-019 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...legacyObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary codeFormat @@ -391,11 +391,11 @@ describe('LEGACY transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-020 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-020 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...legacyObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // UnnecessaryLegacyKey @@ -408,11 +408,11 @@ describe('LEGACY transaction', () => { .catch(err => expect(err.message).to.equals('"legacyKey" cannot be used with LEGACY transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-558 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-558 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...legacyObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws('"legacyKey" cannot be used with LEGACY transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with LEGACY transaction') }).timeout(200000) // Invalid from address @@ -425,14 +425,14 @@ describe('LEGACY transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-663: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-663: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...legacyObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -444,13 +444,13 @@ describe('LEGACY transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-664: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-664: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const tx = { feePayerSignatures: [['0x01', '0x', '0x']], ...legacyObject } const expectedError = '"feePayerSignatures" cannot be used with LEGACY transaction' // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // InvalidTo @@ -464,7 +464,7 @@ describe('LEGACY transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, senderPrvKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-665: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-665: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const invalidTo = 'invalid' const tx = { ...legacyObject } tx.to = invalidTo @@ -472,6 +472,6 @@ describe('LEGACY transaction', () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) }) diff --git a/test/transactionType/valueTransfer.js b/test/transactionType/valueTransfer.js index 01efb759..d391f3a3 100644 --- a/test/transactionType/valueTransfer.js +++ b/test/transactionType/valueTransfer.js @@ -79,12 +79,12 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-021 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-021 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...valueTransferObject } delete tx.from // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error to missing @@ -100,12 +100,12 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-022 : If transaction object missing to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-022 : If transaction object missing to, sendTransaction should throw error', async () => { const tx = { ...valueTransferObject } delete tx.to // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error value missing @@ -121,12 +121,12 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-023 : If transaction object missing value, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-023 : If transaction object missing value, sendTransaction should throw error', async () => { const tx = { ...valueTransferObject } delete tx.value // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error gas and gasLimit missing @@ -142,12 +142,12 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-024 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-024 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...valueTransferObject } delete tx.gas // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error unnecessary feePayer @@ -162,11 +162,11 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-025 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-025 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', async () => { const tx = { feePayer: testAccount.address, ...valueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error unnecessary feeRatio @@ -181,11 +181,11 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-026 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-026 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 20, ...valueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error unnecessary publicKey @@ -204,7 +204,7 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-027 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-027 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', @@ -212,7 +212,7 @@ describe('VALUE_TRANSFER transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error unnecessary multisig @@ -252,7 +252,7 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-028 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-028 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -281,7 +281,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { multisig, ...valueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error unnecessary roleTransactionKey @@ -300,7 +300,7 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-029 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-029 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -308,7 +308,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { roleTransactionKey, ...valueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -327,7 +327,7 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-030 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-030 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -335,7 +335,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { roleAccountUpdateKey, ...valueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -354,7 +354,7 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-031 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-031 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -362,7 +362,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { roleFeePayerKey, ...valueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error unnecessary failKey @@ -377,11 +377,11 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-032 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-032 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...valueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error unnecessary codeFormat @@ -396,11 +396,11 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-033 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-033 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...valueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // Error unnecessary data @@ -417,13 +417,13 @@ describe('VALUE_TRANSFER transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-034 : If transaction object has unnecessary data field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-034 : If transaction object has unnecessary data field, sendTransaction should throw error', async () => { const data = '0x6080604052348015600f57600080fd5b5060e98061001e6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063954ab4b2146044575b600080fd5b348015604f57600080fd5b5060566058565b005b7f90a042becc42ba1b13a5d545701bf5ceff20b24d9e5cc63b67f96ef814d80f0933604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a15600a165627a7a723058200ebb53e9d575350ceb2d92263b7d4920888706b5221f024e7bbc10e3dbb8e18d0029' const tx = { data, ...valueTransferObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejected }).timeout(200000) // UnnecessaryLegacyKey @@ -436,10 +436,10 @@ describe('VALUE_TRANSFER transaction', () => { .catch(err => expect(err.message).to.equals('"legacyKey" cannot be used with VALUE_TRANSFER transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-559 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-559 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...valueTransferObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"legacyKey" cannot be used with VALUE_TRANSFER transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with VALUE_TRANSFER transaction') }).timeout(200000) // Invalid from address @@ -452,14 +452,14 @@ describe('VALUE_TRANSFER transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-666: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-666: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...valueTransferObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -468,16 +468,16 @@ describe('VALUE_TRANSFER transaction', () => { const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` - await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-667: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-667: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const tx = { feePayerSignatures: [['0x01', '0x', '0x']], ...valueTransferObject } const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // InvalidTo @@ -491,7 +491,7 @@ describe('VALUE_TRANSFER transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, senderPrvKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-668: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-668: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const invalidTo = 'invalid' const tx = { ...valueTransferObject } tx.to = invalidTo @@ -499,7 +499,7 @@ describe('VALUE_TRANSFER transaction', () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) it('CAVERJS-UNIT-TX-727: sendTransaction should throw error when try to use an account in Node with not LEGACY transaction', async () => { diff --git a/test/transactionType/valueTransferWithMemo.js b/test/transactionType/valueTransferWithMemo.js index 4abfdf54..de5aeb7c 100644 --- a/test/transactionType/valueTransferWithMemo.js +++ b/test/transactionType/valueTransferWithMemo.js @@ -41,7 +41,7 @@ before(() => { testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) }) -describe('VALUE_TRANSFER_MEMO transaction', () => { +describe('VALUE_TRANSFER_MEMO transaction', async () => { let valueTransferMemoObject beforeEach(() => { @@ -79,12 +79,12 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-065 : If transaction object missing from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-065 : If transaction object missing from, sendTransaction should throw error', async () => { const tx = { ...valueTransferMemoObject } delete tx.from // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error to missing @@ -100,12 +100,12 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-066 : If transaction object missing to, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-066 : If transaction object missing to, sendTransaction should throw error', async () => { const tx = { ...valueTransferMemoObject } delete tx.to // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error value missing @@ -121,12 +121,12 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-067 : If transaction object missing value, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-067 : If transaction object missing value, sendTransaction should throw error', async () => { const tx = { ...valueTransferMemoObject } delete tx.value // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error gas and gasLimit missing @@ -142,12 +142,12 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-068 : If transaction object missing gas and gasLimit, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-068 : If transaction object missing gas and gasLimit, sendTransaction should throw error', async () => { const tx = { ...valueTransferMemoObject } delete tx.gas // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error data missing @@ -163,12 +163,12 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-069 : If transaction object missing data, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-069 : If transaction object missing data, sendTransaction should throw error', async () => { const tx = { ...valueTransferMemoObject } delete tx.data // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary feePayer @@ -183,11 +183,11 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-070 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-070 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', async () => { const tx = { feePayer: testAccount.address, ...valueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary feeRatio @@ -202,11 +202,11 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-071 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-071 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 20, ...valueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary publicKey @@ -225,7 +225,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-072 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-072 : If transaction object has unnecessary publicKey field, sendTransaction should throw error', async () => { const tx = { publicKey: '0x006dc19d50bbc8a8e4b0f26c0dd3e78978f5f691a6161c41e3b0e4d1aa2d60fad62f37912b59f484b2e05bd3c9c3b4d93b0ca570d6d4421eee544e7da99e9de4', @@ -233,7 +233,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary multisig @@ -273,7 +273,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-073 : If transaction object has unnecessary multisig field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-073 : If transaction object has unnecessary multisig field, sendTransaction should throw error', async () => { const multisig = { threshold: 3, keys: [ @@ -302,7 +302,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { const tx = { multisig, ...valueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -321,7 +321,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-074 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-074 : If transaction object has unnecessary roleTransactionKey field, sendTransaction should throw error', async () => { const roleTransactionKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -329,7 +329,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { const tx = { roleTransactionKey, ...valueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -348,7 +348,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-075 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-075 : If transaction object has unnecessary roleAccountUpdateKey field, sendTransaction should throw error', async () => { const roleAccountUpdateKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -356,7 +356,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { const tx = { roleAccountUpdateKey, ...valueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -375,7 +375,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-076 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-076 : If transaction object has unnecessary roleFeePayerKey field, sendTransaction should throw error', async () => { const roleFeePayerKey = { publicKey: '0xf4fa613bf44e5fa7505ad196605a1f32d3eb695f41916fb50f6c3ce65d345a059ebc2dc69629808c2a7c98eb0f2daad68f0b39f0a49141318fe59b777e6b8d1c', @@ -383,7 +383,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { const tx = { roleFeePayerKey, ...valueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary failKey @@ -398,11 +398,11 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-077 : If transaction object has unnecessary failKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-077 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...valueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // Error unnecessary codeFormat @@ -417,11 +417,11 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { expect(result).to.be.true }).timeout(200000) - it('CAVERJS-UNIT-TX-078 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-078 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...valueTransferMemoObject } // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws() + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() }).timeout(200000) // UnnecessaryLegacyKey @@ -434,10 +434,10 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { .catch(err => expect(err.message).to.equals('"legacyKey" cannot be used with VALUE_TRANSFER_MEMO transaction')) }).timeout(200000) - it('CAVERJS-UNIT-TX-562 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-562 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...valueTransferMemoObject } - expect(() => caver.klay.sendTransaction(tx)).to.throws('"legacyKey" cannot be used with VALUE_TRANSFER_MEMO transaction') + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with VALUE_TRANSFER_MEMO transaction') }).timeout(200000) // Invalid from address @@ -450,14 +450,14 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-669: If transaction object has invalid from, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-669: If transaction object has invalid from, sendTransaction should throw error', async () => { const tx = { ...valueTransferMemoObject } tx.from = 'invalidAddress' const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -469,13 +469,13 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, testAccount.privateKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-670: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-670: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const tx = { feePayerSignatures: [['0x01', '0x', '0x']], ...valueTransferMemoObject } const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) // InvalidTo @@ -489,7 +489,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { await expect(caver.klay.accounts.signTransaction(tx, senderPrvKey)).to.be.rejectedWith(expectedError) }).timeout(200000) - it('CAVERJS-UNIT-TX-671: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', () => { + it('CAVERJS-UNIT-TX-671: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { const invalidTo = 'invalid' const tx = { ...valueTransferMemoObject } tx.to = invalidTo @@ -497,7 +497,7 @@ describe('VALUE_TRANSFER_MEMO transaction', () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - expect(() => caver.klay.sendTransaction(tx)).to.throws(expectedError) + await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) }).timeout(200000) it('CAVERJS-UNIT-TX-728: sendTransaction should throw error when try to use an account in Node with not LEGACY transaction', async () => { From 2d3af9a5542b3a7634b019c8c2c5c6ad5e0f4787 Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 8 Jul 2022 10:14:56 +0900 Subject: [PATCH 17/42] Use callback function in the method --- packages/caver-core-method/src/index.js | 62 +++++++++++++------------ 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/packages/caver-core-method/src/index.js b/packages/caver-core-method/src/index.js index fb631c98..48531240 100644 --- a/packages/caver-core-method/src/index.js +++ b/packages/caver-core-method/src/index.js @@ -449,7 +449,7 @@ const buildSendRequestFunc = (defer, sendSignedTx, sendTxCallback) => (payload, return method.requestManager.send(payload, sendTxCallback) } -const buildSendFunc = (method, isSendTx) => async (...args) => { +const buildSendFunc = (method, isSendTx) => (...args) => { const defer = utils.promiEvent(!isSendTx) const payload = method.toPayload(args) @@ -496,38 +496,42 @@ const buildSendFunc = (method, isSendTx) => async (...args) => { params: 0, }).createFunction(method.requestManager) - const header = await getHeader('latest') - const bf = utils.hexToNumber(header.baseFeePerGas || '0x0') - - // The baseFeePerGas is bigger than 0 means that Klaytn uses dynamic gas price. - if (bf > 0) { - if (!isDynamicFeeTx) { - payload.params[0].gasPrice = bf * 2 - } else { - // If maxFeePerGas is undefined, set maxFeePerGas with `baseFee * 2`. - payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || bf * 2 - // If maxPriorityFeePerGas is undefined, call `klay_maxPriorityFeePerGas`. - if (payload.params[0].maxPriorityFeePerGas === undefined) { - const maxPriorityFeePerGas = await getMaxPriorityFeePerGas() - payload.params[0].maxPriorityFeePerGas = maxPriorityFeePerGas + getHeader('latest', (err, header) => { + // Get baseFee(`baseFeePerGas`) from block header + const baseFee = utils.hexToNumber(header.baseFeePerGas || '0x0') + + // The baseFeePerGas is bigger than 0 means that Klaytn uses dynamic gas price. + if (baseFee > 0) { + if (!isDynamicFeeTx) { + payload.params[0].gasPrice = baseFee * 2 + } else { + // If maxFeePerGas is undefined, set maxFeePerGas with `baseFee * 2`. + payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || baseFee * 2 + // If maxPriorityFeePerGas is undefined, call `klay_maxPriorityFeePerGas`. + if (payload.params[0].maxPriorityFeePerGas === undefined) { + getMaxPriorityFeePerGas((err, maxPriorityFeePerGas) => { + payload.params[0].maxPriorityFeePerGas = maxPriorityFeePerGas + }) + } } - } - } else { - // If baseFeePerGas is not defined or 0, we need to use unit price for the `gasPrice` field. - const gp = await getGasPrice() - // The TxTypeEthereumDynamicFee transaction does not use the gasPrice field, - // so the gas price default is not set for TxTypeEthereumDynamicFee. - if (!isDynamicFeeTx) { - payload.params[0].gasPrice = payload.params[0].gasPrice || gp } else { - payload.params[0].maxPriorityFeePerGas = payload.params[0].maxPriorityFeePerGas || gp - payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || gp + // If baseFeePerGas is not defined or 0, we need to use unit price for the `gasPrice` field. + getGasPrice((err, gp) => { + // The TxTypeEthereumDynamicFee transaction does not use the gasPrice field, + // so the gas price default is not set for TxTypeEthereumDynamicFee. + if (!isDynamicFeeTx) { + payload.params[0].gasPrice = payload.params[0].gasPrice || gp + } else { + payload.params[0].maxPriorityFeePerGas = payload.params[0].maxPriorityFeePerGas || gp + payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || gp + } + }) } - } + // Format gas price parameters(gasPrice, maxPriorityFeePerGas, maxFeePerGas) + formatGasParametersToHex(payload.params[0]) + sendRequest(payload, method) + }) - // Format gas price parameters(gasPrice, maxPriorityFeePerGas, maxFeePerGas) - formatGasParametersToHex(payload.params[0]) - sendRequest(payload, method) /** * attaching `.on('receipt')` is possible by returning defer.eventEmitter */ From be40982150c0e7f212886d0f6c6bf9f5ca7e70a5 Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 8 Jul 2022 11:02:00 +0900 Subject: [PATCH 18/42] Put SendRequest in the callback function --- packages/caver-core-method/src/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/caver-core-method/src/index.js b/packages/caver-core-method/src/index.js index 48531240..81240eda 100644 --- a/packages/caver-core-method/src/index.js +++ b/packages/caver-core-method/src/index.js @@ -509,14 +509,17 @@ const buildSendFunc = (method, isSendTx) => (...args) => { payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || baseFee * 2 // If maxPriorityFeePerGas is undefined, call `klay_maxPriorityFeePerGas`. if (payload.params[0].maxPriorityFeePerGas === undefined) { - getMaxPriorityFeePerGas((err, maxPriorityFeePerGas) => { + return getMaxPriorityFeePerGas((err, maxPriorityFeePerGas) => { payload.params[0].maxPriorityFeePerGas = maxPriorityFeePerGas + // Format gas price parameters(gasPrice, maxPriorityFeePerGas, maxFeePerGas) + formatGasParametersToHex(payload.params[0]) + sendRequest(payload, method) }) } } } else { // If baseFeePerGas is not defined or 0, we need to use unit price for the `gasPrice` field. - getGasPrice((err, gp) => { + return getGasPrice((err, gp) => { // The TxTypeEthereumDynamicFee transaction does not use the gasPrice field, // so the gas price default is not set for TxTypeEthereumDynamicFee. if (!isDynamicFeeTx) { @@ -525,6 +528,9 @@ const buildSendFunc = (method, isSendTx) => (...args) => { payload.params[0].maxPriorityFeePerGas = payload.params[0].maxPriorityFeePerGas || gp payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || gp } + // Format gas price parameters(gasPrice, maxPriorityFeePerGas, maxFeePerGas) + formatGasParametersToHex(payload.params[0]) + sendRequest(payload, method) }) } // Format gas price parameters(gasPrice, maxPriorityFeePerGas, maxFeePerGas) From 3fa5eb1ae4fa0cd33a055e09420500f4ea7431bf Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 8 Jul 2022 12:04:29 +0900 Subject: [PATCH 19/42] Rollback to original test code --- test/getTransactionReceipt.js | 4 +- test/transactionType/accountUpdate.js | 114 +++++++-------- test/transactionType/cancelTransaction.js | 34 ++--- test/transactionType/contractDeploy.js | 34 ++--- test/transactionType/contractExecution.js | 34 ++--- .../feeDelegatedAccountUpdate.js | 132 +++++++++--------- .../feeDelegatedAccountUpdateWithRatio.js | 132 +++++++++--------- .../feeDelegatedCancelTransaction.js | 34 ++--- .../feeDelegatedCancelTransactionWithRatio.js | 34 ++--- .../feeDelegatedContractDeploy.js | 34 ++--- .../feeDelegatedContractDeployWithRatio.js | 34 ++--- .../feeDelegatedContractExecution.js | 34 ++--- .../feeDelegatedContractExecutionWithRatio.js | 34 ++--- .../feeDelegatedValueTransfer.js | 36 ++--- .../feeDelegatedValueTransferMemo.js | 36 ++--- .../feeDelegatedValueTransferMemoWithRatio.js | 36 ++--- .../feeDelegatedValueTransferWithRatio.js | 36 ++--- test/transactionType/legacyTransaction.js | 32 ++--- test/transactionType/valueTransfer.js | 38 ++--- test/transactionType/valueTransferWithMemo.js | 36 ++--- 20 files changed, 469 insertions(+), 469 deletions(-) diff --git a/test/getTransactionReceipt.js b/test/getTransactionReceipt.js index 7813366a..1d711f0b 100644 --- a/test/getTransactionReceipt.js +++ b/test/getTransactionReceipt.js @@ -63,8 +63,8 @@ describe('get transaction receipt', () => { .catch(() => done()) }).timeout(100000) - it('should throw an error without parameter', async () => { - await expect(caver.klay.getTransactionReceipt()).to.be.rejected + it('should throw an error without parameter', () => { + expect(() => caver.klay.getTransactionReceipt()).to.throw() }).timeout(100000) it('CAVERJS-UNIT-TX-567 : After sending transction, getTransactionReceipt should return transaction infromation', async () => { diff --git a/test/transactionType/accountUpdate.js b/test/transactionType/accountUpdate.js index ab331a07..e056544c 100644 --- a/test/transactionType/accountUpdate.js +++ b/test/transactionType/accountUpdate.js @@ -103,7 +103,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { delete tx.from // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // UnnecessaryTo @@ -123,7 +123,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { publicKey, to: senderAddress, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // UnnecessaryValue @@ -143,7 +143,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { publicKey, value: 1, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // MissingGas @@ -165,7 +165,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { delete tx.gas // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // MissingKey @@ -291,7 +291,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleTransactionKey. @@ -341,7 +341,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleTransactionKey and multisig. @@ -361,7 +361,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleTransactionKey, publicKey and multisig. @@ -381,7 +381,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleAccountUpdateKey. @@ -461,7 +461,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleAccountUpdateKey and multisig. @@ -481,7 +481,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleAccountUpdateKey, publicKey and multisig. @@ -501,7 +501,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleAccountUpdateKey, roleTransactionKey and publicKey. @@ -521,7 +521,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleAccountUpdateKey, roleTransactionKey and multisig. @@ -541,7 +541,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleAccountUpdateKey, roleTransactionKey, publicKey and multisig. @@ -573,7 +573,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey. @@ -717,7 +717,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey and multisig. @@ -737,7 +737,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey, publicKey and multisig. @@ -757,7 +757,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey and publicKey. @@ -777,7 +777,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey and multisig. @@ -797,7 +797,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey, publicKey and multisig. @@ -829,7 +829,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey, roleAccountUpdateKey and publicKey. @@ -849,7 +849,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey, roleAccountUpdateKey and multisig. @@ -869,7 +869,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey, roleAccountUpdateKey, publicKey and multisig. @@ -901,7 +901,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and publicKey. @@ -933,7 +933,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey and multisig. @@ -965,7 +965,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with roleFeePayerKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig. @@ -999,7 +999,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey. @@ -1031,7 +1031,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey and multisig. @@ -1051,7 +1051,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, publicKey and multisig. @@ -1071,7 +1071,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey and roleTransactionKey. @@ -1091,7 +1091,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey and publicKey. @@ -1111,7 +1111,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey and multisig. @@ -1131,7 +1131,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey, publicKey and multisig. @@ -1151,7 +1151,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey and roleAccountUpdateKey. @@ -1171,7 +1171,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleAccountUpdateKey and publicKey. @@ -1191,7 +1191,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleAccountUpdateKey and multisig. @@ -1211,7 +1211,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleAccountUpdateKey, publicKey and multisig. @@ -1231,7 +1231,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey and roleFeePayerKey. @@ -1251,7 +1251,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleFeePayerKey and publicKey. @@ -1271,7 +1271,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleFeePayerKey and multisig. @@ -1291,7 +1291,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleFeePayerKey, publicKey and multisig. @@ -1311,7 +1311,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey and publicKey. @@ -1343,7 +1343,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey and multisig. @@ -1375,7 +1375,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey, publicKey and multisig. @@ -1409,7 +1409,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey, roleFeePayerKey and publicKey. @@ -1441,7 +1441,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey, roleFeePayerKey and multisig. @@ -1473,7 +1473,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey, roleFeePayerKey, publicKey and multisig. @@ -1507,7 +1507,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleAccountUpdateKey, roleFeePayerKey and publicKey. @@ -1539,7 +1539,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleAccountUpdateKey, roleFeePayerKey and multisig. @@ -1571,7 +1571,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig. @@ -1605,7 +1605,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and publicKey. @@ -1639,7 +1639,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey and multisig. @@ -1673,7 +1673,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update with failKey, roleTransactionKey, roleAccountUpdateKey, roleFeePayerKey, publicKey and multisig. @@ -1709,7 +1709,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // UnnecessaryData @@ -1729,7 +1729,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { data: '0x68656c6c6f', publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // UnnecessaryFeePayer @@ -1749,7 +1749,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { feePayer: caver.klay.accounts.create().address, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // UnnecessaryFeeRatio @@ -1769,7 +1769,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { feeRatio: 20, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // UnnecessaryCodeFormat @@ -1789,7 +1789,7 @@ describe('ACCOUNT_UPDATE transaction', async () => { const tx = { codeFormat: 'EVM', publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Update account with legacyKey diff --git a/test/transactionType/cancelTransaction.js b/test/transactionType/cancelTransaction.js index 9fb799c8..9d75969c 100644 --- a/test/transactionType/cancelTransaction.js +++ b/test/transactionType/cancelTransaction.js @@ -67,7 +67,7 @@ describe('CANCEL transaction', async () => { const tx = { ...cancelObject } delete tx.from - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The send transactions "from" field must be defined!') }).timeout(200000) // UnnecessaryTo @@ -83,7 +83,7 @@ describe('CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-512 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: testAccount.address, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"to" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryValue @@ -99,7 +99,7 @@ describe('CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-513 : If transaction object has unnecessary value field, sendTransaction should throw error', async () => { const tx = { value: 1, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"value" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"value" cannot be used with CANCEL transaction') }).timeout(200000) // MissingGas @@ -117,7 +117,7 @@ describe('CANCEL transaction', async () => { const tx = { ...cancelObject } delete tx.gas - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"gas" is missing') }).timeout(200000) // UnnecessaryData @@ -133,7 +133,7 @@ describe('CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-515 : If transaction object has unnecessary data field, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"data" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryFeePayer @@ -149,7 +149,7 @@ describe('CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-516 : If transaction object has unnecessary feePayer field, sendTransaction should throw error', async () => { const tx = { feePayer: testAccount.address, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feePayer" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feePayer" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryFeeRatio @@ -165,7 +165,7 @@ describe('CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-517 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feeRatio" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryPublicKey @@ -189,7 +189,7 @@ describe('CANCEL transaction', async () => { ...cancelObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"publicKey" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"publicKey" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryMultisig @@ -255,7 +255,7 @@ describe('CANCEL transaction', async () => { } const tx = { multisig, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"multisig" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"multisig" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryRoleTransactionKey @@ -279,7 +279,7 @@ describe('CANCEL transaction', async () => { } const tx = { roleTransactionKey, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"roleTransactionKey" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"roleTransactionKey" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryRoleAccountUpdateKey @@ -303,7 +303,7 @@ describe('CANCEL transaction', async () => { } const tx = { roleAccountUpdateKey, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"roleAccountUpdateKey" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"roleAccountUpdateKey" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryRoleFeePayerKey @@ -327,7 +327,7 @@ describe('CANCEL transaction', async () => { } const tx = { roleFeePayerKey, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"roleFeePayerKey" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"roleFeePayerKey" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryFailKey @@ -343,7 +343,7 @@ describe('CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-523 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"failKey" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"failKey" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryCodeFormat @@ -359,7 +359,7 @@ describe('CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-524 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"codeFormat" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"codeFormat" cannot be used with CANCEL transaction') }).timeout(200000) // UnnecessaryLegacyKey @@ -375,7 +375,7 @@ describe('CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-525 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"legacyKey" cannot be used with CANCEL transaction') }).timeout(200000) // Invalid from address @@ -395,7 +395,7 @@ describe('CANCEL transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -413,7 +413,7 @@ describe('CANCEL transaction', async () => { const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) it('CAVERJS-UNIT-TX-712: sendTransaction should throw error when try to use an account in Node with not LEGACY transaction', async () => { diff --git a/test/transactionType/contractDeploy.js b/test/transactionType/contractDeploy.js index 3ebf1ef0..4b5192df 100644 --- a/test/transactionType/contractDeploy.js +++ b/test/transactionType/contractDeploy.js @@ -76,7 +76,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { const tx = { ...deployObject } delete tx.from - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The send transactions "from" field must be defined!') }).timeout(200000) // MissingValue @@ -94,7 +94,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { const tx = { ...deployObject } delete tx.value - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"value" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"value" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -112,7 +112,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { const tx = { ...deployObject } delete tx.gas - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"gas" is missing') }).timeout(200000) // MissingData @@ -130,7 +130,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { const tx = { ...deployObject } delete tx.data - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"data" is missing') }).timeout(200000) // InvalidCodeFormat @@ -146,7 +146,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { it('CAVERJS-UNIT-TX-427 : If transaction object has invalid codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'InvalidCodeFormat', ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The codeFormat(InvalidCodeFormat) is invalid.') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The codeFormat(InvalidCodeFormat) is invalid.') }).timeout(200000) // UnnecessaryFeePayer @@ -163,7 +163,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { const tx = { feePayer: testAccount.address, ...deployObject } // This error return from formatter. Because in formatter discriminate fee delegation through feePayer and senderRawTransaction - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feePayer" cannot be used with SMART_CONTRACT_DEPLOY transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feePayer" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryFeeRatio @@ -179,7 +179,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { it('CAVERJS-UNIT-TX-429 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" cannot be used with SMART_CONTRACT_DEPLOY transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feeRatio" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryPublicKey @@ -203,7 +203,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { ...deployObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"publicKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"publicKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryMultisig @@ -269,7 +269,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { } const tx = { multisig, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"multisig" cannot be used with SMART_CONTRACT_DEPLOY transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"multisig" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryRoleTransactionKey @@ -293,7 +293,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { } const tx = { roleTransactionKey, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleTransactionKey" cannot be used with SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -319,7 +319,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { } const tx = { roleAccountUpdateKey, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleAccountUpdateKey" cannot be used with SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -345,7 +345,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { } const tx = { roleFeePayerKey, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleFeePayerKey" cannot be used with SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -363,7 +363,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { it('CAVERJS-UNIT-TX-435 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"failKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"failKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryLegacyKey @@ -379,7 +379,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { it('CAVERJS-UNIT-TX-436 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"legacyKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryTo @@ -395,7 +395,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { it('CAVERJS-UNIT-TX-569 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: '0x5e008646fde91fb6eda7b1fdabc7d84649125cf5', ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" cannot be used with SMART_CONTRACT_DEPLOY transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"to" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) it('CAVERJS-UNIT-TX-577: If data field of transaction is not 0x-hex prefixed, signTransaction should formatting and sign', async () => { @@ -434,7 +434,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -452,7 +452,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) it('CAVERJS-UNIT-TX-713: sendTransaction should throw error when try to use an account in Node with not LEGACY transaction', async () => { diff --git a/test/transactionType/contractExecution.js b/test/transactionType/contractExecution.js index 49f0ac78..53948078 100644 --- a/test/transactionType/contractExecution.js +++ b/test/transactionType/contractExecution.js @@ -80,7 +80,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { const tx = { ...executionObject } delete tx.from - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The send transactions "from" field must be defined!') }).timeout(200000) // MissingTo @@ -98,7 +98,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { const tx = { ...executionObject } delete tx.to - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"to" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -116,7 +116,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { const tx = { ...executionObject } delete tx.gas - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"gas" is missing') }).timeout(200000) // MissingData @@ -134,7 +134,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { const tx = { ...executionObject } delete tx.data - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"data" is missing') }).timeout(200000) // UnnecessaryFeePayer @@ -151,7 +151,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { const tx = { feePayer: testAccount.address, ...executionObject } // This error return from formatter. Because in formatter discriminate fee delegation through feePayer and senderRawTransaction - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"feePayer" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -169,7 +169,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-472 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"feeRatio" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -195,7 +195,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { ...executionObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"publicKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -263,7 +263,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { } const tx = { multisig, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"multisig" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -289,7 +289,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { } const tx = { roleTransactionKey, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleTransactionKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -315,7 +315,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { } const tx = { roleAccountUpdateKey, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleAccountUpdateKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -341,7 +341,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { } const tx = { roleFeePayerKey, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleFeePayerKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -359,7 +359,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-478 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"failKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -377,7 +377,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-479 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"codeFormat" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -395,7 +395,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-480 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"legacyKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -417,7 +417,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -435,7 +435,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // InvalidTo @@ -457,7 +457,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) it('CAVERJS-UNIT-TX-714: sendTransaction should throw error when try to use an account in Node with not LEGACY transaction', async () => { diff --git a/test/transactionType/feeDelegatedAccountUpdate.js b/test/transactionType/feeDelegatedAccountUpdate.js index 0cdc0683..01323773 100644 --- a/test/transactionType/feeDelegatedAccountUpdate.js +++ b/test/transactionType/feeDelegatedAccountUpdate.js @@ -109,7 +109,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.from - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The send transactions "from" field must be defined!') }).timeout(200000) // UnnecessaryTo @@ -125,7 +125,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-266 : If transaction object has to, sendTransaction should throw error', async () => { const tx = { publicKey, to: senderAddress, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"to" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') }).timeout(200000) // UnnecessaryValue @@ -141,7 +141,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-267 : If transaction object has value, sendTransaction should throw error', async () => { const tx = { publicKey, value: 1, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"value" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' ) }).timeout(200000) @@ -161,7 +161,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.gas - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"gas" is missing') }).timeout(200000) // MissingKey @@ -177,7 +177,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-269 : If transaction object missing key information, sendTransaction should throw error', async () => { const tx = { ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'Missing key information with FEE_DELEGATED_ACCOUNT_UPDATE transaction' ) }).timeout(200000) @@ -281,7 +281,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-275 : If transaction object has multisig and publicKey, sendTransaction should throw error', async () => { const tx = { publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -336,7 +336,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-277 : If transaction object has roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -354,7 +354,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-278 : If transaction object has roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -372,7 +372,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-279 : If transaction object has roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -464,7 +464,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-282 : If transaction object has roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -482,7 +482,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-283 : If transaction object has roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -500,7 +500,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-284 : If transaction object has roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -518,7 +518,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-285 : If transaction object has roleAccountUpdateKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -536,7 +536,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-286 : If transaction object has roleAccountUpdateKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -566,7 +566,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -735,7 +735,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-292 : If transaction object has roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -753,7 +753,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-293 : If transaction object has roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -771,7 +771,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-294 : If transaction object has roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -789,7 +789,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-295 : If transaction object has roleFeePayerKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -807,7 +807,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-296 : If transaction object has roleFeePayerKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -837,7 +837,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -855,7 +855,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-298 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -873,7 +873,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-299 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -903,7 +903,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -933,7 +933,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -963,7 +963,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -995,7 +995,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1030,7 +1030,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-305 : If transaction object has failKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1048,7 +1048,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-306 : If transaction object has failKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1066,7 +1066,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-307 : If transaction object has failKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1084,7 +1084,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-308 : If transaction object has failKey and roleTransactionKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1102,7 +1102,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-309 : If transaction object has failKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1120,7 +1120,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-310 : If transaction object has failKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1138,7 +1138,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-311 : If transaction object has failKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1156,7 +1156,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-312 : If transaction object has failKey and roleAccountUpdateKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1174,7 +1174,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-313 : If transaction object has failKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1192,7 +1192,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-314 : If transaction object has failKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1210,7 +1210,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-315 : If transaction object has failKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1228,7 +1228,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-316 : If transaction object has failKey and roleFeePayerKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1246,7 +1246,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-317 : If transaction object has failKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1264,7 +1264,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-318 : If transaction object has failKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1282,7 +1282,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-319 : If transaction object has failKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1312,7 +1312,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1342,7 +1342,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1374,7 +1374,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1404,7 +1404,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1434,7 +1434,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1466,7 +1466,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1496,7 +1496,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1526,7 +1526,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1558,7 +1558,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1590,7 +1590,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1622,7 +1622,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1656,7 +1656,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1674,7 +1674,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-332 : If transaction object has data, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"data" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' ) }).timeout(200000) @@ -1702,7 +1702,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-335 : If transaction object has feeRatio, sendTransaction should throw error', async () => { const tx = { feeRatio: 20, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"feeRatio" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' ) }).timeout(200000) @@ -1720,7 +1720,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-336 : If transaction object has codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"codeFormat" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' ) }).timeout(200000) @@ -1755,7 +1755,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { const tx = { legacyKey: true, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1774,7 +1774,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { const tx = { legacyKey: true, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1793,7 +1793,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { const tx = { legacyKey: true, failKey: true, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1812,7 +1812,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { const tx = { legacyKey: true, roleTransactionKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1831,7 +1831,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { const tx = { legacyKey: true, roleAccountUpdateKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1850,7 +1850,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { const tx = { legacyKey: true, roleFeePayerKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE is duplicated.' ) }).timeout(200000) @@ -1872,7 +1872,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -1903,7 +1903,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -1936,7 +1936,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedAccountUpdateWithRatio.js b/test/transactionType/feeDelegatedAccountUpdateWithRatio.js index 1b0e1a83..1c58560f 100644 --- a/test/transactionType/feeDelegatedAccountUpdateWithRatio.js +++ b/test/transactionType/feeDelegatedAccountUpdateWithRatio.js @@ -112,7 +112,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.from - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The send transactions "from" field must be defined!') }).timeout(200000) // UnnecessaryTo @@ -128,7 +128,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-345 : If transaction object has to, sendTransaction should throw error', async () => { const tx = { publicKey, to: senderAddress, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"to" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction' ) }).timeout(200000) @@ -146,7 +146,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-346 : If transaction object has value, sendTransaction should throw error', async () => { const tx = { publicKey, value: 1, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"value" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction' ) }).timeout(200000) @@ -166,7 +166,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.gas - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"gas" is missing') }).timeout(200000) // MissingKey @@ -182,7 +182,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-348 : If transaction object missing key information, sendTransaction should throw error', async () => { const tx = { ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'Missing key information with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction' ) }).timeout(200000) @@ -288,7 +288,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-354 : If transaction object has multisig and publicKey, sendTransaction should throw error', async () => { const tx = { publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -346,7 +346,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-356 : If transaction object has roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -366,7 +366,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-357 : If transaction object has roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -386,7 +386,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-358 : If transaction object has roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -482,7 +482,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-361 : If transaction object has roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -502,7 +502,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-362 : If transaction object has roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -522,7 +522,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-363 : If transaction object has roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -542,7 +542,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-364 : If transaction object has roleAccountUpdateKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -562,7 +562,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-365 : If transaction object has roleAccountUpdateKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -594,7 +594,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -768,7 +768,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-371 : If transaction object has roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -788,7 +788,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-372 : If transaction object has roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -808,7 +808,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-373 : If transaction object has roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -828,7 +828,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-374 : If transaction object has roleFeePayerKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -848,7 +848,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-375 : If transaction object has roleFeePayerKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { roleTransactionKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -880,7 +880,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -900,7 +900,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-377 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -920,7 +920,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-378 : If transaction object has roleFeePayerKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { roleAccountUpdateKey: { publicKey }, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -952,7 +952,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -984,7 +984,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1016,7 +1016,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1050,7 +1050,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1087,7 +1087,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-384 : If transaction object has failKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1107,7 +1107,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-385 : If transaction object has failKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1127,7 +1127,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-386 : If transaction object has failKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1147,7 +1147,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-387 : If transaction object has failKey and roleTransactionKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1167,7 +1167,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-388 : If transaction object has failKey, roleTransactionKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1187,7 +1187,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-389 : If transaction object has failKey, roleTransactionKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1207,7 +1207,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-390 : If transaction object has failKey, roleTransactionKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleTransactionKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1227,7 +1227,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-391 : If transaction object has failKey and roleAccountUpdateKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1247,7 +1247,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-392 : If transaction object has failKey, roleAccountUpdateKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1267,7 +1267,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-393 : If transaction object has failKey, roleAccountUpdateKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1287,7 +1287,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-394 : If transaction object has failKey, roleAccountUpdateKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleAccountUpdateKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1307,7 +1307,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-395 : If transaction object has failKey and roleFeePayerKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1327,7 +1327,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-396 : If transaction object has failKey, roleFeePayerKey and publicKey, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1347,7 +1347,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-397 : If transaction object has failKey, roleFeePayerKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1367,7 +1367,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-398 : If transaction object has failKey, roleFeePayerKey, publicKey and multisig, sendTransaction should throw error', async () => { const tx = { failKey: true, roleFeePayerKey: { publicKey }, publicKey, multisig, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1399,7 +1399,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1431,7 +1431,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1465,7 +1465,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1497,7 +1497,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1529,7 +1529,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1563,7 +1563,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1595,7 +1595,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1627,7 +1627,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1661,7 +1661,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1695,7 +1695,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1729,7 +1729,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1765,7 +1765,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { ...accountUpdateObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1783,7 +1783,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-411 : If transaction object has data, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"data" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction' ) }).timeout(200000) @@ -1813,7 +1813,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const tx = { publicKey, ...accountUpdateObject } delete tx.feeRatio - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feeRatio" is missing') }).timeout(200000) // UnnecessaryCodeFormat @@ -1831,7 +1831,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-415 : If transaction object has codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', publicKey, ...accountUpdateObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"codeFormat" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction' ) }).timeout(200000) @@ -1868,7 +1868,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const tx = { legacyKey: true, publicKey, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1889,7 +1889,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const tx = { legacyKey: true, multisig, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1910,7 +1910,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const tx = { legacyKey: true, failKey: true, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1931,7 +1931,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const tx = { legacyKey: true, roleTransactionKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1952,7 +1952,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const tx = { legacyKey: true, roleAccountUpdateKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1973,7 +1973,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const tx = { legacyKey: true, roleFeePayerKey: { publicKey }, ...accountUpdateObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( 'The key parameter to be used for FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO is duplicated.' ) }).timeout(200000) @@ -1995,7 +1995,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -2026,7 +2026,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -2059,7 +2059,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE_WITH_RATIO transaction', async () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedCancelTransaction.js b/test/transactionType/feeDelegatedCancelTransaction.js index 3df06aa8..4c7b7e50 100644 --- a/test/transactionType/feeDelegatedCancelTransaction.js +++ b/test/transactionType/feeDelegatedCancelTransaction.js @@ -71,7 +71,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { const tx = { ...cancelObject } delete tx.from - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The send transactions "from" field must be defined!') }).timeout(200000) // UnnecessaryTo @@ -87,7 +87,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-527 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: testAccount.address, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" cannot be used with FEE_DELEGATED_CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"to" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryValue @@ -103,7 +103,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-528 : If transaction object has unnecessary value field, sendTransaction should throw error', async () => { const tx = { value: 1, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"value" cannot be used with FEE_DELEGATED_CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"value" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // MissingGas @@ -121,7 +121,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { const tx = { ...cancelObject } delete tx.gas - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"gas" is missing') }).timeout(200000) // UnnecessaryData @@ -137,7 +137,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-530 : If transaction object has unnecessary data field, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" cannot be used with FEE_DELEGATED_CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"data" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // MissingFeePayer @@ -165,7 +165,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-533 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" cannot be used with FEE_DELEGATED_CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feeRatio" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryPublicKey @@ -189,7 +189,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { ...cancelObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"publicKey" cannot be used with FEE_DELEGATED_CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"publicKey" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryMultisig @@ -255,7 +255,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { } const tx = { multisig, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"multisig" cannot be used with FEE_DELEGATED_CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"multisig" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryRoleTransactionKey @@ -279,7 +279,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { } const tx = { roleTransactionKey, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleTransactionKey" cannot be used with FEE_DELEGATED_CANCEL transaction' ) }).timeout(200000) @@ -305,7 +305,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { } const tx = { roleAccountUpdateKey, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_CANCEL transaction' ) }).timeout(200000) @@ -331,7 +331,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { } const tx = { roleFeePayerKey, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleFeePayerKey" cannot be used with FEE_DELEGATED_CANCEL transaction' ) }).timeout(200000) @@ -349,7 +349,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-539 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"failKey" cannot be used with FEE_DELEGATED_CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"failKey" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryCodeFormat @@ -365,7 +365,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-540 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"codeFormat" cannot be used with FEE_DELEGATED_CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"codeFormat" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryLegacyKey @@ -381,7 +381,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { it('CAVERJS-UNIT-TX-541 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with FEE_DELEGATED_CANCEL transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"legacyKey" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // Invalid from address @@ -401,7 +401,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -433,7 +433,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -467,7 +467,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedCancelTransactionWithRatio.js b/test/transactionType/feeDelegatedCancelTransactionWithRatio.js index c2d3b6c9..a89e0259 100644 --- a/test/transactionType/feeDelegatedCancelTransactionWithRatio.js +++ b/test/transactionType/feeDelegatedCancelTransactionWithRatio.js @@ -72,7 +72,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { const tx = { ...cancelObject } delete tx.from - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The send transactions "from" field must be defined!') }).timeout(200000) // UnnecessaryTo @@ -88,7 +88,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-543 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: testAccount.address, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"to" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -106,7 +106,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-544 : If transaction object has unnecessary value field, sendTransaction should throw error', async () => { const tx = { value: 1, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"value" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -126,7 +126,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { const tx = { ...cancelObject } delete tx.gas - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"gas" is missing') }).timeout(200000) // UnnecessaryData @@ -142,7 +142,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-546 : If transaction object has unnecessary data field, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"data" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -172,7 +172,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { const tx = { ...cancelObject } delete tx.feeRatio - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feeRatio" is missing') }).timeout(200000) // UnnecessaryPublicKey @@ -196,7 +196,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { ...cancelObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"publicKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -264,7 +264,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { } const tx = { multisig, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"multisig" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -292,7 +292,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { } const tx = { roleTransactionKey, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleTransactionKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -320,7 +320,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { } const tx = { roleAccountUpdateKey, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -348,7 +348,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { } const tx = { roleFeePayerKey, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleFeePayerKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -366,7 +366,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-555 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"failKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -384,7 +384,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-556 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"codeFormat" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -402,7 +402,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-557 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...cancelObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"legacyKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' ) }).timeout(200000) @@ -424,7 +424,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -455,7 +455,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -488,7 +488,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedContractDeploy.js b/test/transactionType/feeDelegatedContractDeploy.js index 54e1851f..c43606f4 100644 --- a/test/transactionType/feeDelegatedContractDeploy.js +++ b/test/transactionType/feeDelegatedContractDeploy.js @@ -83,7 +83,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { const tx = { ...deployObject } delete tx.from - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The send transactions "from" field must be defined!') }).timeout(200000) // MissingValue @@ -101,7 +101,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { const tx = { ...deployObject } delete tx.value - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"value" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"value" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -119,7 +119,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { const tx = { ...deployObject } delete tx.gas - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"gas" is missing') }).timeout(200000) // MissingData @@ -137,7 +137,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { const tx = { ...deployObject } delete tx.data - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"data" is missing') }).timeout(200000) // InvalidCodeFormat @@ -153,7 +153,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { it('CAVERJS-UNIT-TX-441 : If transaction object has invalid codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'InvalidCodeFormat', ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The codeFormat(InvalidCodeFormat) is invalid.') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The codeFormat(InvalidCodeFormat) is invalid.') }).timeout(200000) // MissingFeePayer @@ -180,7 +180,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { it('CAVERJS-UNIT-TX-444 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"feeRatio" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -206,7 +206,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { ...deployObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"publicKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -274,7 +274,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { } const tx = { multisig, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"multisig" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -302,7 +302,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { } const tx = { roleTransactionKey, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleTransactionKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -330,7 +330,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { } const tx = { roleAccountUpdateKey, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -358,7 +358,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { } const tx = { roleFeePayerKey, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleFeePayerKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -376,7 +376,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { it('CAVERJS-UNIT-TX-450 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"failKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -394,7 +394,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { it('CAVERJS-UNIT-TX-451 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"legacyKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -412,7 +412,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { it('CAVERJS-UNIT-TX-570 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: '0x5e008646fde91fb6eda7b1fdabc7d84649125cf5', ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"to" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' ) }).timeout(200000) @@ -448,7 +448,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -479,7 +479,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -512,7 +512,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedContractDeployWithRatio.js b/test/transactionType/feeDelegatedContractDeployWithRatio.js index 12c06d4a..90cae1be 100644 --- a/test/transactionType/feeDelegatedContractDeployWithRatio.js +++ b/test/transactionType/feeDelegatedContractDeployWithRatio.js @@ -84,7 +84,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () const tx = { ...deployObject } delete tx.from - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The send transactions "from" field must be defined!') }).timeout(200000) // MissingValue @@ -102,7 +102,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () const tx = { ...deployObject } delete tx.value - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"value" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"value" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -120,7 +120,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () const tx = { ...deployObject } delete tx.gas - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"gas" is missing') }).timeout(200000) // MissingData @@ -138,7 +138,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () const tx = { ...deployObject } delete tx.data - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"data" is missing') }).timeout(200000) // InvalidCodeFormat @@ -154,7 +154,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () it('CAVERJS-UNIT-TX-456 : If transaction object has invalid codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'InvalidCodeFormat', ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The codeFormat(InvalidCodeFormat) is invalid.') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The codeFormat(InvalidCodeFormat) is invalid.') }).timeout(200000) // MissingFeePayer @@ -183,7 +183,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () const tx = Object.assign(deployObject) delete tx.feeRatio - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feeRatio" is missing') }).timeout(200000) // UnnecessaryPublicKey @@ -209,7 +209,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () ...deployObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"publicKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -279,7 +279,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () } const tx = { multisig, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"multisig" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -309,7 +309,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () } const tx = { roleTransactionKey, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleTransactionKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -339,7 +339,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () } const tx = { roleAccountUpdateKey, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -369,7 +369,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () } const tx = { roleFeePayerKey, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleFeePayerKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -389,7 +389,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () it('CAVERJS-UNIT-TX-465 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"failKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -409,7 +409,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () it('CAVERJS-UNIT-TX-466 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"legacyKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -429,7 +429,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () it('CAVERJS-UNIT-TX-571 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: '0x5e008646fde91fb6eda7b1fdabc7d84649125cf5', ...deployObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"to" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction' ) }).timeout(200000) @@ -465,7 +465,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -496,7 +496,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -529,7 +529,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY_WITH_RATIO transaction', async () const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedContractExecution.js b/test/transactionType/feeDelegatedContractExecution.js index 98796e5d..c6e57413 100644 --- a/test/transactionType/feeDelegatedContractExecution.js +++ b/test/transactionType/feeDelegatedContractExecution.js @@ -88,7 +88,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { const tx = { ...executionObject } delete tx.from - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The send transactions "from" field must be defined!') }).timeout(200000) // MissingTo @@ -106,7 +106,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { const tx = { ...executionObject } delete tx.to - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"to" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -124,7 +124,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { const tx = { ...executionObject } delete tx.gas - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"gas" is missing') }).timeout(200000) // MissingData @@ -142,7 +142,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { const tx = { ...executionObject } delete tx.data - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"data" is missing') }).timeout(200000) // MissingFeePayer @@ -170,7 +170,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-487 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"feeRatio" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -198,7 +198,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { ...executionObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"publicKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -268,7 +268,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { } const tx = { multisig, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"multisig" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -296,7 +296,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { } const tx = { roleTransactionKey, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleTransactionKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -326,7 +326,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { } const tx = { roleAccountUpdateKey, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -354,7 +354,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { } const tx = { roleFeePayerKey, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleFeePayerKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -372,7 +372,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-493 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"failKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -392,7 +392,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-494 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"codeFormat" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -412,7 +412,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-495 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"legacyKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction' ) }).timeout(200000) @@ -434,7 +434,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -465,7 +465,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -498,7 +498,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // InvalidTo @@ -520,7 +520,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION transaction', async () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedContractExecutionWithRatio.js b/test/transactionType/feeDelegatedContractExecutionWithRatio.js index a79151bf..d90ee793 100644 --- a/test/transactionType/feeDelegatedContractExecutionWithRatio.js +++ b/test/transactionType/feeDelegatedContractExecutionWithRatio.js @@ -89,7 +89,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async const tx = { ...executionObject } delete tx.from - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('The send transactions "from" field must be defined!') + expect(() => caver.klay.sendTransaction(tx)).to.throw('The send transactions "from" field must be defined!') }).timeout(200000) // MissingTo @@ -107,7 +107,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async const tx = { ...executionObject } delete tx.to - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"to" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"to" is missing') }).timeout(200000) // Missing gas and gasLimit @@ -125,7 +125,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async const tx = { ...executionObject } delete tx.gas - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"gas" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"gas" is missing') }).timeout(200000) // MissingData @@ -143,7 +143,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async const tx = { ...executionObject } delete tx.data - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"data" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"data" is missing') }).timeout(200000) // MissingFeePayer @@ -171,7 +171,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async const tx = { ...executionObject } delete tx.feeRatio - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"feeRatio" is missing') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feeRatio" is missing') }).timeout(200000) // UnnecessaryPublicKey @@ -199,7 +199,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async ...executionObject, } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"publicKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -271,7 +271,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async } const tx = { multisig, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"multisig" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -301,7 +301,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async } const tx = { roleTransactionKey, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleTransactionKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -331,7 +331,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async } const tx = { roleAccountUpdateKey, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -361,7 +361,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async } const tx = { roleFeePayerKey, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"roleFeePayerKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -381,7 +381,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async it('CAVERJS-UNIT-TX-508 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"failKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -403,7 +403,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async it('CAVERJS-UNIT-TX-509 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"codeFormat" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -425,7 +425,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async it('CAVERJS-UNIT-TX-510 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...executionObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"legacyKey" cannot be used with FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction' ) }).timeout(200000) @@ -447,7 +447,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -478,7 +478,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -511,7 +511,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // InvalidTo @@ -533,7 +533,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_EXECUTION_WITH_RATIO transaction', async const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedValueTransfer.js b/test/transactionType/feeDelegatedValueTransfer.js index c66f50d5..2e4c672c 100644 --- a/test/transactionType/feeDelegatedValueTransfer.js +++ b/test/transactionType/feeDelegatedValueTransfer.js @@ -102,7 +102,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { delete tx.from // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error to missing @@ -123,7 +123,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { delete tx.to // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error value missing @@ -144,7 +144,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { delete tx.value // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error gas and gasLimit missing @@ -165,7 +165,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { delete tx.gas // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error feePayer missing (A check on the feePayer is performed when the feePayer attempts to sign the rawTransaction after sender signed.) @@ -202,7 +202,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const tx = { feeRatio: 20, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary publicKey @@ -229,7 +229,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary multisig @@ -298,7 +298,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const tx = { multisig, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -325,7 +325,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const tx = { roleTransactionKey, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -352,7 +352,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const tx = { roleAccountUpdateKey, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -379,7 +379,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const tx = { roleFeePayerKey, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary failKey @@ -398,7 +398,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const tx = { failKey: true, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary codeFormat @@ -417,7 +417,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const tx = { codeFormat: 'EVM', ...feeDelegatedValueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary data @@ -440,7 +440,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const tx = { data, ...feeDelegatedValueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // UnnecessaryLegacyKey @@ -456,7 +456,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { it('CAVERJS-UNIT-TX-560 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...feeDelegatedValueTransferObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER transaction' ) }).timeout(200000) @@ -478,7 +478,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -509,7 +509,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -542,7 +542,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // InvalidTo @@ -564,7 +564,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedValueTransferMemo.js b/test/transactionType/feeDelegatedValueTransferMemo.js index 41371e5c..ca85459e 100644 --- a/test/transactionType/feeDelegatedValueTransferMemo.js +++ b/test/transactionType/feeDelegatedValueTransferMemo.js @@ -103,7 +103,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { delete tx.from // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error to missing @@ -125,7 +125,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { delete tx.to // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error value missing @@ -147,7 +147,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { delete tx.value // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error gas and gasLimit missing @@ -169,7 +169,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { delete tx.gas // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error data missing @@ -191,7 +191,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { delete tx.data // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error feePayer missing (A check on the feePayer is performed when the feePayer attempts to sign the rawTransaction after sender signed.) @@ -229,7 +229,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { const tx = { feeRatio: 20, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary publicKey @@ -257,7 +257,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary multisig @@ -327,7 +327,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { const tx = { multisig, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -355,7 +355,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { const tx = { roleTransactionKey, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -383,7 +383,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { const tx = { roleAccountUpdateKey, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -411,7 +411,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { const tx = { roleFeePayerKey, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary failKey @@ -431,7 +431,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { const tx = { failKey: true, ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary codeFormat @@ -451,7 +451,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { const tx = { codeFormat: 'EVM', ...feeDelegatedValueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // UnnecessaryLegacyKey @@ -467,7 +467,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { it('CAVERJS-UNIT-TX-563 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...feeDelegatedValueTransferMemoObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction' ) }).timeout(200000) @@ -489,7 +489,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -521,7 +521,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -554,7 +554,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // InvalidTo @@ -576,7 +576,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO transaction', async () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedValueTransferMemoWithRatio.js b/test/transactionType/feeDelegatedValueTransferMemoWithRatio.js index 2b502546..77d67e36 100644 --- a/test/transactionType/feeDelegatedValueTransferMemoWithRatio.js +++ b/test/transactionType/feeDelegatedValueTransferMemoWithRatio.js @@ -104,7 +104,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => delete tx.from // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error to missing @@ -126,7 +126,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => delete tx.to // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error value missing @@ -148,7 +148,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => delete tx.value // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error gas and gasLimit missing @@ -170,7 +170,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => delete tx.gas // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error data missing @@ -192,7 +192,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => delete tx.data // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error feePayer missing (A check on the feePayer is performed when the feePayer attempts to sign the rawTransaction after sender signed.) @@ -232,7 +232,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => delete tx.feeRatio // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary publicKey @@ -260,7 +260,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary multisig @@ -330,7 +330,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => const tx = { multisig, ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -358,7 +358,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => const tx = { roleTransactionKey, ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -386,7 +386,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => const tx = { roleAccountUpdateKey, ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -414,7 +414,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => const tx = { roleFeePayerKey, ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary failKey @@ -434,7 +434,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => const tx = { failKey: true, ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary codeFormat @@ -454,7 +454,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => const tx = { codeFormat: 'EVM', ...feeDelegatedValueTransferMemoWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // UnnecessaryLegacyKey @@ -472,7 +472,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => it('CAVERJS-UNIT-TX-564 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...feeDelegatedValueTransferMemoWithRatioObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction' ) }).timeout(200000) @@ -494,7 +494,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -526,7 +526,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -559,7 +559,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // InvalidTo @@ -581,7 +581,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_MEMO_WITH_RATIO transaction', async () => const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/feeDelegatedValueTransferWithRatio.js b/test/transactionType/feeDelegatedValueTransferWithRatio.js index 8b2f8a00..8ed3903c 100644 --- a/test/transactionType/feeDelegatedValueTransferWithRatio.js +++ b/test/transactionType/feeDelegatedValueTransferWithRatio.js @@ -103,7 +103,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { delete tx.from // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error to missing @@ -125,7 +125,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { delete tx.to // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error value missing @@ -147,7 +147,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { delete tx.value // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error gas and gasLimit missing @@ -169,7 +169,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { delete tx.gas // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error feePayer missing (A check on the feePayer is performed when the feePayer attempts to sign the rawTransaction after sender signed.) @@ -209,7 +209,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { delete tx.feeRatio // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary publicKey @@ -237,7 +237,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary multisig @@ -307,7 +307,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { const tx = { multisig, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -335,7 +335,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { const tx = { roleTransactionKey, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -363,7 +363,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { const tx = { roleAccountUpdateKey, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -391,7 +391,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { const tx = { roleFeePayerKey, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary failKey @@ -411,7 +411,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { const tx = { failKey: true, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary codeFormat @@ -431,7 +431,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { const tx = { codeFormat: 'EVM', ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary data @@ -455,7 +455,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { const tx = { data, ...feeDelegatedValueTransferWithRatioObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // UnnecessaryLegacyKey @@ -473,7 +473,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-561 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...feeDelegatedValueTransferWithRatioObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith( + expect(() => caver.klay.sendTransaction(tx)).to.throw( '"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction' ) }).timeout(200000) @@ -495,7 +495,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error feePayer missing when feePayerSignatures is defined in transaction object @@ -527,7 +527,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.' // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error with invalid feePayer missing when feePayerSignatures is defined in transaction object @@ -560,7 +560,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { const expectedError = `Invalid address of fee payer: ${invalidFeePayer}` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // InvalidTo @@ -582,7 +582,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER_WITH_RATIO transaction', async () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // Error when feePayer is not defined with fee payer transaction format diff --git a/test/transactionType/legacyTransaction.js b/test/transactionType/legacyTransaction.js index b4126b19..1fca3b9b 100644 --- a/test/transactionType/legacyTransaction.js +++ b/test/transactionType/legacyTransaction.js @@ -98,7 +98,7 @@ describe('LEGACY transaction', async () => { delete tx.from // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error gas and gasLimit missing @@ -119,7 +119,7 @@ describe('LEGACY transaction', async () => { delete tx.gas // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error to and data missing @@ -142,7 +142,7 @@ describe('LEGACY transaction', async () => { delete tx.data // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary feePayer @@ -161,7 +161,7 @@ describe('LEGACY transaction', async () => { const tx = { feePayer: testAccount.address, ...legacyObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary feeRatio @@ -180,7 +180,7 @@ describe('LEGACY transaction', async () => { const tx = { feeRatio: 20, ...legacyObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary publicKey @@ -207,7 +207,7 @@ describe('LEGACY transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary multisig @@ -276,7 +276,7 @@ describe('LEGACY transaction', async () => { const tx = { multisig, ...legacyObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -303,7 +303,7 @@ describe('LEGACY transaction', async () => { const tx = { roleTransactionKey, ...legacyObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -330,7 +330,7 @@ describe('LEGACY transaction', async () => { const tx = { roleAccountUpdateKey, ...legacyObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -357,7 +357,7 @@ describe('LEGACY transaction', async () => { const tx = { roleFeePayerKey, ...legacyObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary failKey @@ -376,7 +376,7 @@ describe('LEGACY transaction', async () => { const tx = { failKey: true, ...legacyObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary codeFormat @@ -395,7 +395,7 @@ describe('LEGACY transaction', async () => { const tx = { codeFormat: 'EVM', ...legacyObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // UnnecessaryLegacyKey @@ -412,7 +412,7 @@ describe('LEGACY transaction', async () => { const tx = { legacyKey: true, ...legacyObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with LEGACY transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"legacyKey" cannot be used with LEGACY transaction') }).timeout(200000) // Invalid from address @@ -432,7 +432,7 @@ describe('LEGACY transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -450,7 +450,7 @@ describe('LEGACY transaction', async () => { const expectedError = '"feePayerSignatures" cannot be used with LEGACY transaction' // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // InvalidTo @@ -472,6 +472,6 @@ describe('LEGACY transaction', async () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) }) diff --git a/test/transactionType/valueTransfer.js b/test/transactionType/valueTransfer.js index d391f3a3..169ecf64 100644 --- a/test/transactionType/valueTransfer.js +++ b/test/transactionType/valueTransfer.js @@ -84,7 +84,7 @@ describe('VALUE_TRANSFER transaction', () => { delete tx.from // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error to missing @@ -105,7 +105,7 @@ describe('VALUE_TRANSFER transaction', () => { delete tx.to // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error value missing @@ -126,7 +126,7 @@ describe('VALUE_TRANSFER transaction', () => { delete tx.value // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error gas and gasLimit missing @@ -147,7 +147,7 @@ describe('VALUE_TRANSFER transaction', () => { delete tx.gas // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error unnecessary feePayer @@ -166,7 +166,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { feePayer: testAccount.address, ...valueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error unnecessary feeRatio @@ -185,7 +185,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { feeRatio: 20, ...valueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error unnecessary publicKey @@ -212,7 +212,7 @@ describe('VALUE_TRANSFER transaction', () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error unnecessary multisig @@ -281,7 +281,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { multisig, ...valueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error unnecessary roleTransactionKey @@ -308,7 +308,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { roleTransactionKey, ...valueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -335,7 +335,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { roleAccountUpdateKey, ...valueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -362,7 +362,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { roleFeePayerKey, ...valueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error unnecessary failKey @@ -381,7 +381,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { failKey: true, ...valueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error unnecessary codeFormat @@ -400,7 +400,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { codeFormat: 'EVM', ...valueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // Error unnecessary data @@ -423,7 +423,7 @@ describe('VALUE_TRANSFER transaction', () => { const tx = { data, ...valueTransferObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejected + expect(() => caver.klay.sendTransaction(tx)).to.throw }).timeout(200000) // UnnecessaryLegacyKey @@ -439,7 +439,7 @@ describe('VALUE_TRANSFER transaction', () => { it('CAVERJS-UNIT-TX-559 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...valueTransferObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with VALUE_TRANSFER transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"legacyKey" cannot be used with VALUE_TRANSFER transaction') }).timeout(200000) // Invalid from address @@ -459,7 +459,7 @@ describe('VALUE_TRANSFER transaction', () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -468,7 +468,7 @@ describe('VALUE_TRANSFER transaction', () => { const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) it('CAVERJS-UNIT-TX-667: If transaction object has unnecessary feePayerSignatures, sendTransaction should throw error', async () => { @@ -477,7 +477,7 @@ describe('VALUE_TRANSFER transaction', () => { const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // InvalidTo @@ -499,7 +499,7 @@ describe('VALUE_TRANSFER transaction', () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) it('CAVERJS-UNIT-TX-727: sendTransaction should throw error when try to use an account in Node with not LEGACY transaction', async () => { diff --git a/test/transactionType/valueTransferWithMemo.js b/test/transactionType/valueTransferWithMemo.js index de5aeb7c..9c15b92d 100644 --- a/test/transactionType/valueTransferWithMemo.js +++ b/test/transactionType/valueTransferWithMemo.js @@ -84,7 +84,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { delete tx.from // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error to missing @@ -105,7 +105,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { delete tx.to // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error value missing @@ -126,7 +126,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { delete tx.value // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error gas and gasLimit missing @@ -147,7 +147,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { delete tx.gas // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error data missing @@ -168,7 +168,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { delete tx.data // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary feePayer @@ -187,7 +187,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { const tx = { feePayer: testAccount.address, ...valueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary feeRatio @@ -206,7 +206,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { const tx = { feeRatio: 20, ...valueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary publicKey @@ -233,7 +233,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary multisig @@ -302,7 +302,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { const tx = { multisig, ...valueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleTransactionKey @@ -329,7 +329,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { const tx = { roleTransactionKey, ...valueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleAccountUpdateKey @@ -356,7 +356,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { const tx = { roleAccountUpdateKey, ...valueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary roleFeePayerKey @@ -383,7 +383,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { const tx = { roleFeePayerKey, ...valueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary failKey @@ -402,7 +402,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { const tx = { failKey: true, ...valueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // Error unnecessary codeFormat @@ -421,7 +421,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { const tx = { codeFormat: 'EVM', ...valueTransferMemoObject } // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith() + expect(() => caver.klay.sendTransaction(tx)).to.throw() }).timeout(200000) // UnnecessaryLegacyKey @@ -437,7 +437,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { it('CAVERJS-UNIT-TX-562 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...valueTransferMemoObject } - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith('"legacyKey" cannot be used with VALUE_TRANSFER_MEMO transaction') + expect(() => caver.klay.sendTransaction(tx)).to.throw('"legacyKey" cannot be used with VALUE_TRANSFER_MEMO transaction') }).timeout(200000) // Invalid from address @@ -457,7 +457,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { const expectedError = `Provided address "${tx.from}" is invalid, the capitalization checksum test failed` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // UnnecessaryFeePayerSignatures @@ -475,7 +475,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { const expectedError = `"feePayerSignatures" cannot be used with ${tx.type} transaction` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) // InvalidTo @@ -497,7 +497,7 @@ describe('VALUE_TRANSFER_MEMO transaction', async () => { const expectedError = `Provided address "${tx.to}" is invalid, the capitalization checksum test failed.` // Throw error from formatter validation - await expect(caver.klay.sendTransaction(tx)).to.be.rejectedWith(expectedError) + expect(() => caver.klay.sendTransaction(tx)).to.throw(expectedError) }).timeout(200000) it('CAVERJS-UNIT-TX-728: sendTransaction should throw error when try to use an account in Node with not LEGACY transaction', async () => { From 8abe34ad2782bd9f677e0a62336972dbfe9affde Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 8 Jul 2022 12:42:41 +0900 Subject: [PATCH 20/42] Fixed lint error --- packages/caver-core-method/src/index.js | 4 +-- test/transactionType/contractDeploy.js | 8 ++--- test/transactionType/contractExecution.js | 32 +++++-------------- .../feeDelegatedAccountUpdate.js | 20 +++--------- .../feeDelegatedCancelTransaction.js | 12 ++----- .../feeDelegatedCancelTransactionWithRatio.js | 28 ++++------------ .../feeDelegatedContractDeploy.js | 4 +-- .../feeDelegatedValueTransfer.js | 4 +-- 8 files changed, 29 insertions(+), 83 deletions(-) diff --git a/packages/caver-core-method/src/index.js b/packages/caver-core-method/src/index.js index 81240eda..175ec39c 100644 --- a/packages/caver-core-method/src/index.js +++ b/packages/caver-core-method/src/index.js @@ -509,7 +509,7 @@ const buildSendFunc = (method, isSendTx) => (...args) => { payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || baseFee * 2 // If maxPriorityFeePerGas is undefined, call `klay_maxPriorityFeePerGas`. if (payload.params[0].maxPriorityFeePerGas === undefined) { - return getMaxPriorityFeePerGas((err, maxPriorityFeePerGas) => { + return getMaxPriorityFeePerGas((e, maxPriorityFeePerGas) => { payload.params[0].maxPriorityFeePerGas = maxPriorityFeePerGas // Format gas price parameters(gasPrice, maxPriorityFeePerGas, maxFeePerGas) formatGasParametersToHex(payload.params[0]) @@ -519,7 +519,7 @@ const buildSendFunc = (method, isSendTx) => (...args) => { } } else { // If baseFeePerGas is not defined or 0, we need to use unit price for the `gasPrice` field. - return getGasPrice((err, gp) => { + return getGasPrice((e, gp) => { // The TxTypeEthereumDynamicFee transaction does not use the gasPrice field, // so the gas price default is not set for TxTypeEthereumDynamicFee. if (!isDynamicFeeTx) { diff --git a/test/transactionType/contractDeploy.js b/test/transactionType/contractDeploy.js index 4b5192df..472fa5d2 100644 --- a/test/transactionType/contractDeploy.js +++ b/test/transactionType/contractDeploy.js @@ -293,9 +293,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { } const tx = { roleTransactionKey, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"roleTransactionKey" cannot be used with SMART_CONTRACT_DEPLOY transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"roleTransactionKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryRoleAccountUpdateKey @@ -345,9 +343,7 @@ describe('SMART_CONTRACT_DEPLOY transaction', async () => { } const tx = { roleFeePayerKey, ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"roleFeePayerKey" cannot be used with SMART_CONTRACT_DEPLOY transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"roleFeePayerKey" cannot be used with SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) // UnnecessaryFailKey diff --git a/test/transactionType/contractExecution.js b/test/transactionType/contractExecution.js index 53948078..b18fe36f 100644 --- a/test/transactionType/contractExecution.js +++ b/test/transactionType/contractExecution.js @@ -151,9 +151,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { const tx = { feePayer: testAccount.address, ...executionObject } // This error return from formatter. Because in formatter discriminate fee delegation through feePayer and senderRawTransaction - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"feePayer" cannot be used with SMART_CONTRACT_EXECUTION transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feePayer" cannot be used with SMART_CONTRACT_EXECUTION transaction') }).timeout(200000) // UnnecessaryFeeRatio @@ -169,9 +167,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-472 : If transaction object has unnecessary feeRatio field, sendTransaction should throw error', async () => { const tx = { feeRatio: 10, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"feeRatio" cannot be used with SMART_CONTRACT_EXECUTION transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feeRatio" cannot be used with SMART_CONTRACT_EXECUTION transaction') }).timeout(200000) // UnnecessaryPublicKey @@ -195,9 +191,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { ...executionObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"publicKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"publicKey" cannot be used with SMART_CONTRACT_EXECUTION transaction') }).timeout(200000) // UnnecessaryMultisig @@ -263,9 +257,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { } const tx = { multisig, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"multisig" cannot be used with SMART_CONTRACT_EXECUTION transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"multisig" cannot be used with SMART_CONTRACT_EXECUTION transaction') }).timeout(200000) // UnnecessaryRoleTransactionKey @@ -341,9 +333,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { } const tx = { roleFeePayerKey, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"roleFeePayerKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"roleFeePayerKey" cannot be used with SMART_CONTRACT_EXECUTION transaction') }).timeout(200000) // UnnecessaryFailKey @@ -359,9 +349,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-478 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"failKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"failKey" cannot be used with SMART_CONTRACT_EXECUTION transaction') }).timeout(200000) // UnnecessaryCodeFormat @@ -377,9 +365,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-479 : If transaction object has unnecessary codeFormat field, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"codeFormat" cannot be used with SMART_CONTRACT_EXECUTION transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"codeFormat" cannot be used with SMART_CONTRACT_EXECUTION transaction') }).timeout(200000) // UnnecessaryLegacyKey @@ -395,9 +381,7 @@ describe('SMART_CONTRACT_EXECUTION transaction', async () => { it('CAVERJS-UNIT-TX-480 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...executionObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"legacyKey" cannot be used with SMART_CONTRACT_EXECUTION transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"legacyKey" cannot be used with SMART_CONTRACT_EXECUTION transaction') }).timeout(200000) // Invalid from address diff --git a/test/transactionType/feeDelegatedAccountUpdate.js b/test/transactionType/feeDelegatedAccountUpdate.js index 01323773..533275b6 100644 --- a/test/transactionType/feeDelegatedAccountUpdate.js +++ b/test/transactionType/feeDelegatedAccountUpdate.js @@ -141,9 +141,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-267 : If transaction object has value, sendTransaction should throw error', async () => { const tx = { publicKey, value: 1, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"value" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"value" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') }).timeout(200000) // MissingGas @@ -177,9 +175,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-269 : If transaction object missing key information, sendTransaction should throw error', async () => { const tx = { ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - 'Missing key information with FEE_DELEGATED_ACCOUNT_UPDATE transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('Missing key information with FEE_DELEGATED_ACCOUNT_UPDATE transaction') }).timeout(200000) // PublicKey @@ -1674,9 +1670,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-332 : If transaction object has data, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"data" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"data" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') }).timeout(200000) // Error feePayer missing (A check on the feePayer is performed when the feePayer attempts to sign the rawTransaction after sender signed.) @@ -1702,9 +1696,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-335 : If transaction object has feeRatio, sendTransaction should throw error', async () => { const tx = { feeRatio: 20, publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"feeRatio" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"feeRatio" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') }).timeout(200000) // UnnecessaryCodeFormat @@ -1720,9 +1712,7 @@ describe('FEE_DELEGATED_ACCOUNT_UPDATE transaction', async () => { it('CAVERJS-UNIT-TX-336 : If transaction object has codeFormat, sendTransaction should throw error', async () => { const tx = { codeFormat: 'EVM', publicKey, ...accountUpdateObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"codeFormat" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"codeFormat" cannot be used with FEE_DELEGATED_ACCOUNT_UPDATE transaction') }).timeout(200000) // Update account with legacyKey diff --git a/test/transactionType/feeDelegatedCancelTransaction.js b/test/transactionType/feeDelegatedCancelTransaction.js index 4c7b7e50..e4aa086a 100644 --- a/test/transactionType/feeDelegatedCancelTransaction.js +++ b/test/transactionType/feeDelegatedCancelTransaction.js @@ -279,9 +279,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { } const tx = { roleTransactionKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"roleTransactionKey" cannot be used with FEE_DELEGATED_CANCEL transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"roleTransactionKey" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryRoleAccountUpdateKey @@ -305,9 +303,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { } const tx = { roleAccountUpdateKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_CANCEL transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"roleAccountUpdateKey" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryRoleFeePayerKey @@ -331,9 +327,7 @@ describe('FEE_DELEGATED_CANCEL transaction', async () => { } const tx = { roleFeePayerKey, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"roleFeePayerKey" cannot be used with FEE_DELEGATED_CANCEL transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"roleFeePayerKey" cannot be used with FEE_DELEGATED_CANCEL transaction') }).timeout(200000) // UnnecessaryFailKey diff --git a/test/transactionType/feeDelegatedCancelTransactionWithRatio.js b/test/transactionType/feeDelegatedCancelTransactionWithRatio.js index a89e0259..f3a313f6 100644 --- a/test/transactionType/feeDelegatedCancelTransactionWithRatio.js +++ b/test/transactionType/feeDelegatedCancelTransactionWithRatio.js @@ -88,9 +88,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-543 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: testAccount.address, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"to" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"to" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') }).timeout(200000) // UnnecessaryValue @@ -106,9 +104,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-544 : If transaction object has unnecessary value field, sendTransaction should throw error', async () => { const tx = { value: 1, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"value" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"value" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') }).timeout(200000) // MissingGas @@ -142,9 +138,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-546 : If transaction object has unnecessary data field, sendTransaction should throw error', async () => { const tx = { data: '0x68656c6c6f', ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"data" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"data" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') }).timeout(200000) // MissingFeePayer @@ -196,9 +190,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { ...cancelObject, } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"publicKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"publicKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') }).timeout(200000) // UnnecessaryMultisig @@ -264,9 +256,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { } const tx = { multisig, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"multisig" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"multisig" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') }).timeout(200000) // UnnecessaryRoleTransactionKey @@ -366,9 +356,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-555 : If transaction object has unnecessary failKey field, sendTransaction should throw error', async () => { const tx = { failKey: true, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"failKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"failKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') }).timeout(200000) // UnnecessaryCodeFormat @@ -402,9 +390,7 @@ describe('FEE_DELEGATED_CANCEL_WITH_RATIO transaction', async () => { it('CAVERJS-UNIT-TX-557 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...cancelObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"legacyKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"legacyKey" cannot be used with FEE_DELEGATED_CANCEL_WITH_RATIO transaction') }).timeout(200000) // Invalid from address diff --git a/test/transactionType/feeDelegatedContractDeploy.js b/test/transactionType/feeDelegatedContractDeploy.js index c43606f4..7a18247b 100644 --- a/test/transactionType/feeDelegatedContractDeploy.js +++ b/test/transactionType/feeDelegatedContractDeploy.js @@ -412,9 +412,7 @@ describe('FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction', async () => { it('CAVERJS-UNIT-TX-570 : If transaction object has unnecessary to field, sendTransaction should throw error', async () => { const tx = { to: '0x5e008646fde91fb6eda7b1fdabc7d84649125cf5', ...deployObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"to" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"to" cannot be used with FEE_DELEGATED_SMART_CONTRACT_DEPLOY transaction') }).timeout(200000) it('CAVERJS-UNIT-TX-579: If data field of transaction is not 0x-hex prefixed, signTransaction should formatting and sign', async () => { diff --git a/test/transactionType/feeDelegatedValueTransfer.js b/test/transactionType/feeDelegatedValueTransfer.js index 2e4c672c..c05868b6 100644 --- a/test/transactionType/feeDelegatedValueTransfer.js +++ b/test/transactionType/feeDelegatedValueTransfer.js @@ -456,9 +456,7 @@ describe('FEE_DELEGATED_VALUE_TRANSFER transaction', async () => { it('CAVERJS-UNIT-TX-560 : If transaction object has unnecessary legacyKey field, sendTransaction should throw error', async () => { const tx = { legacyKey: true, ...feeDelegatedValueTransferObject } - expect(() => caver.klay.sendTransaction(tx)).to.throw( - '"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER transaction' - ) + expect(() => caver.klay.sendTransaction(tx)).to.throw('"legacyKey" cannot be used with FEE_DELEGATED_VALUE_TRANSFER transaction') }).timeout(200000) // Invalid from address From 4361cf84e9b0f0a435e338d7aa625a2ae9d62a36 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Jul 2022 03:56:56 +0000 Subject: [PATCH 21/42] Bump moment from 2.29.2 to 2.29.4 in /test/test-web Bumps [moment](https://github.com/moment/moment) from 2.29.2 to 2.29.4. - [Release notes](https://github.com/moment/moment/releases) - [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) - [Commits](https://github.com/moment/moment/compare/2.29.2...2.29.4) --- updated-dependencies: - dependency-name: moment dependency-type: indirect ... Signed-off-by: dependabot[bot] --- test/test-web/package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test-web/package-lock.json b/test/test-web/package-lock.json index 1aa62892..5219d919 100644 --- a/test/test-web/package-lock.json +++ b/test/test-web/package-lock.json @@ -11354,9 +11354,9 @@ "dev": true }, "node_modules/moment": { - "version": "2.29.2", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz", - "integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==", + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", "dev": true, "engines": { "node": "*" @@ -25420,9 +25420,9 @@ "dev": true }, "moment": { - "version": "2.29.2", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz", - "integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==", + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==", "dev": true }, "moment-timezone": { From 63d0ea9a7b5ba32b5fc8d05999da97b5e3feb8aa Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 8 Jul 2022 12:57:08 +0900 Subject: [PATCH 22/42] Upgraded version to v1.9.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 74f1744c..604a92fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "caver-js", - "version": "1.8.2", + "version": "1.9.0", "description": "caver-js is a JavaScript API library that allows developers to interact with a Klaytn node", "main": "index.js", "types": "types/index.d.ts", From dda0482f42660fb98d25b2f25f53016da0325019 Mon Sep 17 00:00:00 2001 From: Ayanami Date: Fri, 8 Jul 2022 17:27:58 +0900 Subject: [PATCH 23/42] Backport HttpProvider changes from web3.js web3-providers-http: Migrate from xhr2-cookies to cross-fetch (#5179) * web3-providers-http: Migrate from xhr2-cookies to cross-fetch (#5085) * Update CHANGELOG.md * Migrate from xhr2-cookies to cross-fetch * Address comments for web3-providers-http * web3-providers-http: Prevent global leakage of this.connected * Return server side error without creating additional error object * Fixed type of http.Agent https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export * Removed unused variable * Remove unnecessary catch block * Remove unnecessary internal _prepareRequest function from web3-providers-http * :arrow_up: Update package-lock.json * Update packages/web3-providers-http/src/index.js Co-authored-by: Junaid <86780488+jdevcs@users.noreply.github.com> * :coffin: Remove dead code * :art: Improve the with credentials check --- package-lock.json | 68 +++++---- package.json | 6 +- .../caver-providers-http/src/index.js | 142 ++++++++++++------ test/invalidResponse.js | 10 +- .../caver-providers-http/src/index.d.ts | 13 +- 5 files changed, 147 insertions(+), 92 deletions(-) diff --git a/package-lock.json b/package-lock.json index 56e1a0d4..b93dfdb1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,12 +11,15 @@ "dependencies": { "@babel/runtime": "7.3.1", "@ethersproject/abi": "5.0.7", + "abortcontroller-polyfill": "^1.7.3", "any-promise": "1.3.0", "bignumber.js": "8.0.2", "bn.js": "4.11.6", "constants-browserify": "^1.0.0", + "cross-fetch": "^3.1.5", "crypto-browserify": "^3.12.0", "elliptic": "6.5.4", + "es6-promise": "^4.2.8", "eth-lib": "0.2.8", "ethers": "5.4.1", "ethjs-unit": "0.1.6", @@ -34,8 +37,7 @@ "stream-http": "^3.2.0", "utf8": "2.1.1", "uuid": "8.3.2", - "websocket": "1.0.31", - "xhr2-cookies": "1.1.0" + "websocket": "1.0.31" }, "devDependencies": { "@babel/core": "^7.11.0", @@ -2812,6 +2814,11 @@ "node": ">=6.5" } }, + "node_modules/abortcontroller-polyfill": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.3.tgz", + "integrity": "sha512-zetDJxd89y3X99Kvo4qFx8GKlt6GsvN3UcRZHwU6iFA/0KiOmhkTVhe8oRoTBiTVPZu09x3vCra47+w8Yz1+2Q==" + }, "node_modules/acorn": { "version": "8.7.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", @@ -4509,11 +4516,6 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, - "node_modules/cookiejar": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", - "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" - }, "node_modules/core-js": { "version": "2.6.12", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", @@ -4573,6 +4575,14 @@ "sha.js": "^2.4.8" } }, + "node_modules/cross-fetch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", + "integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==", + "dependencies": { + "node-fetch": "2.6.7" + } + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -5552,6 +5562,11 @@ "es6-symbol": "^3.1.1" } }, + "node_modules/es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + }, "node_modules/es6-symbol": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", @@ -13373,14 +13388,6 @@ "xhr-request": "^1.1.0" } }, - "node_modules/xhr2-cookies": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/xhr2-cookies/-/xhr2-cookies-1.1.0.tgz", - "integrity": "sha1-fXdEnQmZGX8VXLc7I99yUF7YnUg=", - "dependencies": { - "cookiejar": "^2.1.1" - } - }, "node_modules/xmlcreate": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz", @@ -15476,6 +15483,11 @@ "event-target-shim": "^5.0.0" } }, + "abortcontroller-polyfill": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.3.tgz", + "integrity": "sha512-zetDJxd89y3X99Kvo4qFx8GKlt6GsvN3UcRZHwU6iFA/0KiOmhkTVhe8oRoTBiTVPZu09x3vCra47+w8Yz1+2Q==" + }, "acorn": { "version": "8.7.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.0.tgz", @@ -16899,11 +16911,6 @@ } } }, - "cookiejar": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", - "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" - }, "core-js": { "version": "2.6.12", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", @@ -16956,6 +16963,14 @@ "sha.js": "^2.4.8" } }, + "cross-fetch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", + "integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==", + "requires": { + "node-fetch": "2.6.7" + } + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -17754,6 +17769,11 @@ "es6-symbol": "^3.1.1" } }, + "es6-promise": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", + "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" + }, "es6-symbol": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz", @@ -23841,14 +23861,6 @@ "xhr-request": "^1.1.0" } }, - "xhr2-cookies": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/xhr2-cookies/-/xhr2-cookies-1.1.0.tgz", - "integrity": "sha1-fXdEnQmZGX8VXLc7I99yUF7YnUg=", - "requires": { - "cookiejar": "^2.1.1" - } - }, "xmlcreate": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz", diff --git a/package.json b/package.json index 74292be4..462c1f9c 100644 --- a/package.json +++ b/package.json @@ -67,12 +67,15 @@ "dependencies": { "@babel/runtime": "7.3.1", "@ethersproject/abi": "5.0.7", + "abortcontroller-polyfill": "^1.7.3", "any-promise": "1.3.0", "bignumber.js": "8.0.2", "bn.js": "4.11.6", "constants-browserify": "^1.0.0", + "cross-fetch": "^3.1.5", "crypto-browserify": "^3.12.0", "elliptic": "6.5.4", + "es6-promise": "^4.2.8", "eth-lib": "0.2.8", "ethers": "5.4.1", "ethjs-unit": "0.1.6", @@ -90,8 +93,7 @@ "stream-http": "^3.2.0", "utf8": "2.1.1", "uuid": "8.3.2", - "websocket": "1.0.31", - "xhr2-cookies": "1.1.0" + "websocket": "1.0.31" }, "devDependencies": { "@babel/core": "^7.11.0", diff --git a/packages/caver-core-requestmanager/caver-providers-http/src/index.js b/packages/caver-core-requestmanager/caver-providers-http/src/index.js index e798f8ba..99cd04cb 100644 --- a/packages/caver-core-requestmanager/caver-providers-http/src/index.js +++ b/packages/caver-core-requestmanager/caver-providers-http/src/index.js @@ -23,13 +23,18 @@ * Marek Kotewicz * Marian Oancea * Fabian Vogelsteller + * AyanamiTech * @date 2015 */ -const XHR2 = require('xhr2-cookies').XMLHttpRequest +const fetch = require('cross-fetch') const http = require('http') const https = require('https') +// Apply missing polyfill for IE +require('es6-promise').polyfill() +require('abortcontroller-polyfill/dist/polyfill-patch-fetch') + const errors = require('../../../caver-core-helpers').errors /** @@ -43,8 +48,11 @@ const errors = require('../../../caver-core-helpers').errors const HttpProvider = function HttpProvider(host, options) { options = options || {} this.host = host || 'http://localhost:8545' + + this.withCredentials = options.withCredentials this.timeout = options.timeout || 0 this.headers = options.headers + this.agent = options.agent this.connected = false // keepAlive is true unless explicitly set to false @@ -60,80 +68,118 @@ const HttpProvider = function HttpProvider(host, options) { } /** - * _prepareRequest create request instance + * Should be used to make async request + * + * @method send + * @param {Object} payload + * @param {Function} callback triggered on end with (err, result) */ -HttpProvider.prototype._prepareRequest = function() { - let request +HttpProvider.prototype.send = function(payload, callback) { + const options = { + method: 'POST', + body: JSON.stringify(payload), + } + const headers = {} + let controller - // the current runtime is a browser - if (typeof XMLHttpRequest !== 'undefined') { + if (typeof AbortController !== 'undefined') { + controller = new AbortController() + // eslint-disable-next-line no-undef + } else if (typeof AbortController === 'undefined' && typeof window !== 'undefined' && typeof window.AbortController !== 'undefined') { + // Some chrome version doesn't recognize new AbortController(); so we are using it from window instead + // https://stackoverflow.com/questions/55718778/why-abortcontroller-is-not-defined // eslint-disable-next-line no-undef - request = new XMLHttpRequest() + controller = new window.AbortController() } else { - request = new XHR2() - const agents = { httpsAgent: this.httpsAgent, httpAgent: this.httpAgent, baseUrl: this.baseUrl } + // Disable user defined timeout + this.timeout = 0 + } + + // the current runtime is node + if (typeof XMLHttpRequest === 'undefined') { + // https://github.com/node-fetch/node-fetch#custom-agent + const agents = { httpsAgent: this.httpsAgent, httpAgent: this.httpAgent } if (this.agent) { agents.httpsAgent = this.agent.https agents.httpAgent = this.agent.http - agents.baseUrl = this.agent.baseUrl } - request.nodejsSet(agents) + if (this.host.substring(0, 5) === 'https') { + options.agent = agents.httpsAgent + } else { + options.agent = agents.httpAgent + } } - request.open('POST', this.host, true) - request.setRequestHeader('Content-Type', 'application/json') - request.timeout = this.timeout - request.withCredentials = this.withCredentials - if (this.headers) { this.headers.forEach(function(header) { - request.setRequestHeader(header.name, header.value) + headers[header.name] = header.value }) } - return request -} + // Default headers + if (!headers['Content-Type']) { + headers['Content-Type'] = 'application/json' + } -/** - * Should be used to make async request - * - * @method send - * @param {Object} payload - * @param {Function} callback triggered on end with (err, result) - */ -HttpProvider.prototype.send = function(payload, callback) { - const _this = this - const request = this._prepareRequest() + // As the Fetch API supports the credentials as following options 'include', 'omit', 'same-origin' + // https://developer.mozilla.org/en-US/docs/Web/API/fetch#credentials + // To avoid breaking change in 1.x we override this value based on boolean option. + if (this.withCredentials) { + options.credentials = 'include' + } else { + options.credentials = 'omit' + } + + options.headers = headers - request.onreadystatechange = function() { - if (request.readyState === 4 && request.timeout !== 1) { - let result = request.responseText - let error = null + if (this.timeout > 0) { + this.timeoutId = setTimeout(function() { + controller.abort() + }, this.timeout) + } - try { - result = JSON.parse(result) - } catch (e) { - error = errors.InvalidResponse(request.responseText) - } + // Prevent global leak of connected + const _this = this - _this.connected = true - callback(error, result) + const success = function(response) { + if (this.timeoutId !== undefined) { + clearTimeout(this.timeoutId) + } + let result = response + const error = null + + try { + // Response is a stream data so should be awaited for json response + result.json().then(function(data) { + result = data + _this.connected = true + callback(error, result) + }) + } catch (e) { + _this.connected = false + callback(errors.InvalidResponse(result)) } } - request.ontimeout = function() { - _this.connected = false - callback(errors.ConnectionTimeout(this.timeout)) - } + const failed = function(error) { + if (this.timeoutId !== undefined) { + clearTimeout(this.timeoutId) + } + + if (error.name === 'AbortError') { + _this.connected = false + callback(errors.ConnectionTimeout(this.timeout)) + } - try { - request.send(JSON.stringify(payload)) - } catch (error) { - this.connected = false + _this.connected = false callback(errors.InvalidConnection(this.host)) } + + fetch(this.host, options) + .then(success.bind(this)) + .catch(failed.bind(this)) } HttpProvider.prototype.disconnect = function() { diff --git a/test/invalidResponse.js b/test/invalidResponse.js index 01e1c1da..1209f0d6 100644 --- a/test/invalidResponse.js +++ b/test/invalidResponse.js @@ -31,26 +31,24 @@ describe('Connection error test', () => { expect(err.message).to.equals("CONNECTION ERROR: Couldn't connect to node invalid:1234.") } }).timeout(10000) -}) -describe('Invalid response test', () => { - it('CAVERJS-UNIT-ETC-052: without timeout return Invalid response: null error.', async () => { + it('CAVERJS-UNIT-ETC-052: without timeout return connection error.', async () => { caver = new Caver('http://localhost:1234/') try { await caver.klay.getNodeInfo() assert(false) } catch (err) { - expect(err.message).to.equals('Invalid JSON RPC response: ""') + expect(err.message).to.equals("CONNECTION ERROR: Couldn't connect to node http://localhost:1234/.") } }) - it('CAVERJS-UNIT-ETC-053: with timeout return Invalid response: null error.', async () => { + it('CAVERJS-UNIT-ETC-053: with timeout return connection error.', async () => { caver = new Caver(new Caver.providers.HttpProvider('http://localhost:1234/', { timeout: 5000 })) try { await caver.klay.getNodeInfo() assert(false) } catch (err) { - expect(err.message).to.equals('Invalid JSON RPC response: ""') + expect(err.message).to.equals("CONNECTION ERROR: Couldn't connect to node http://localhost:1234/.") } }) }) diff --git a/types/packages/caver-core-requestmanager/caver-providers-http/src/index.d.ts b/types/packages/caver-core-requestmanager/caver-providers-http/src/index.d.ts index 54d49fc5..d8493eb7 100644 --- a/types/packages/caver-core-requestmanager/caver-providers-http/src/index.d.ts +++ b/types/packages/caver-core-requestmanager/caver-providers-http/src/index.d.ts @@ -16,9 +16,8 @@ along with the caver-js. If not, see . */ -import { XMLHttpRequest } from 'xhr2-cookies' -import * as http from 'http' -import * as https from 'https' +import type { Agent as HTTPAgent } from 'http' +import type { Agent as HTTPSAgent } from 'https' import { JsonRpcResponse } from '../../../caver-core-helpers/src' export interface HttpHeader { @@ -27,9 +26,8 @@ export interface HttpHeader { } export interface HttpProviderAgent { - baseUrl?: string - http?: http.Agent - https?: https.Agent + http?: HTTPAgent + https?: HTTPSAgent } export interface HttpProviderOptions { @@ -45,12 +43,11 @@ export class HttpProvider { host: string connected: boolean - withCredentials: boolean + withCredentials?: boolean timeout: number headers?: HttpHeader[] agent?: HttpProviderAgent - _prepareRequest?(): any send(payload: object, callback?: (error: Error | null, result: JsonRpcResponse | undefined) => void): void supportsSubscriptions(): boolean disconnect(): boolean From 7ed9a2af3d26bfa0eb6eb0253b1cc24a7de7fa3b Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 8 Jul 2022 19:50:26 +0900 Subject: [PATCH 24/42] Added dependency --- package-lock.json | 190 ++++++++++++++++++++++++++++++---------------- 1 file changed, 124 insertions(+), 66 deletions(-) diff --git a/package-lock.json b/package-lock.json index b93dfdb1..e6e00136 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "caver-js", - "version": "1.8.2", + "version": "1.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "caver-js", - "version": "1.8.2", + "version": "1.9.0", "license": "LGPL-3.0", "dependencies": { "@babel/runtime": "7.3.1", @@ -1380,21 +1380,27 @@ "dev": true }, "node_modules/@definitelytyped/utils": { - "version": "0.0.111", - "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.0.111.tgz", - "integrity": "sha512-zt9SP5K1FDhISNaXAJdlVVW8Z3YfHV90fP4ieywWcpG1Q1yVfKGBqN5kRgmzh7v1qukrSfOpPYgX3GWMf/E/dA==", + "version": "0.0.121", + "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.0.121.tgz", + "integrity": "sha512-H2g09ZJcmCk0BAy86M/UcMP4pq0UGaKBGpjPjPe5btKgZDB6A1Tn1/TKd46cQ6grhFdsxJFE5cb8XWGTKkpA8w==", "dev": true, "dependencies": { - "@definitelytyped/typescript-versions": "^0.0.111", + "@definitelytyped/typescript-versions": "^0.0.121", "@qiwi/npm-registry-client": "^8.9.1", "@types/node": "^14.14.35", "charm": "^1.0.2", "fs-extra": "^8.1.0", "fstream": "^1.0.12", - "tar": "^2.2.2", + "tar": "^6.1.11", "tar-stream": "^2.1.4" } }, + "node_modules/@definitelytyped/utils/node_modules/@definitelytyped/typescript-versions": { + "version": "0.0.121", + "resolved": "https://registry.npmjs.org/@definitelytyped/typescript-versions/-/typescript-versions-0.0.121.tgz", + "integrity": "sha512-mTfkR7MrGo08lzOPZx3ZgIER9PoalRZok3hmrsLDxTUhS5lrgdgXBOpAyDMtnJUAO6AxrIx126XGlkN+1rvKcA==", + "dev": true + }, "node_modules/@definitelytyped/utils/node_modules/@types/node": { "version": "14.18.12", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.12.tgz", @@ -3512,18 +3518,6 @@ "browser-readablestream-to-it": "^1.0.3" } }, - "node_modules/block-stream": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", - "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", - "dev": true, - "dependencies": { - "inherits": "~2.0.0" - }, - "engines": { - "node": "0.4 || >=0.5.8" - } - }, "node_modules/bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -4179,6 +4173,15 @@ "fsevents": "~2.3.1" } }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/chrome-trace-event": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", @@ -7008,6 +7011,18 @@ "universalify": "^0.1.0" } }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -7044,12 +7059,12 @@ } }, "node_modules/fstream/node_modules/mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "dependencies": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" }, "bin": { "mkdirp": "bin/cmd.js" @@ -9405,9 +9420,9 @@ } }, "node_modules/minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" }, "node_modules/minipass": { "version": "3.1.6", @@ -9421,6 +9436,19 @@ "node": ">=8" } }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dev": true, + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -9434,9 +9462,9 @@ } }, "node_modules/mocha": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.3.2.tgz", - "integrity": "sha512-UdmISwr/5w+uXLPKspgoV7/RXZwKRTiTjJ2/AC5ZiEztIoOYdfKb19+9jNmEInzx5pBsCyJQzarAxqIGBNYJhg==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.4.0.tgz", + "integrity": "sha512-hJaO0mwDXmZS4ghXsvPVriOhsxQ7ofcpQdm8dE+jISUOKopitvnXFQmpRR7jd2K6VBG6E26gU3IAbXXGIbu4sQ==", "dev": true, "dependencies": { "@ungap/promise-all-settled": "1.1.2", @@ -12211,15 +12239,20 @@ } }, "node_modules/tar": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz", - "integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==", - "deprecated": "This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.", + "version": "6.1.11", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz", + "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==", "dev": true, "dependencies": { - "block-stream": "*", - "fstream": "^1.0.12", - "inherits": "2" + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^3.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 10" } }, "node_modules/tar-stream": { @@ -14419,21 +14452,27 @@ "dev": true }, "@definitelytyped/utils": { - "version": "0.0.111", - "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.0.111.tgz", - "integrity": "sha512-zt9SP5K1FDhISNaXAJdlVVW8Z3YfHV90fP4ieywWcpG1Q1yVfKGBqN5kRgmzh7v1qukrSfOpPYgX3GWMf/E/dA==", + "version": "0.0.121", + "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.0.121.tgz", + "integrity": "sha512-H2g09ZJcmCk0BAy86M/UcMP4pq0UGaKBGpjPjPe5btKgZDB6A1Tn1/TKd46cQ6grhFdsxJFE5cb8XWGTKkpA8w==", "dev": true, "requires": { - "@definitelytyped/typescript-versions": "^0.0.111", + "@definitelytyped/typescript-versions": "^0.0.121", "@qiwi/npm-registry-client": "^8.9.1", "@types/node": "^14.14.35", "charm": "^1.0.2", "fs-extra": "^8.1.0", "fstream": "^1.0.12", - "tar": "^2.2.2", + "tar": "^6.1.11", "tar-stream": "^2.1.4" }, "dependencies": { + "@definitelytyped/typescript-versions": { + "version": "0.0.121", + "resolved": "https://registry.npmjs.org/@definitelytyped/typescript-versions/-/typescript-versions-0.0.121.tgz", + "integrity": "sha512-mTfkR7MrGo08lzOPZx3ZgIER9PoalRZok3hmrsLDxTUhS5lrgdgXBOpAyDMtnJUAO6AxrIx126XGlkN+1rvKcA==", + "dev": true + }, "@types/node": { "version": "14.18.12", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.12.tgz", @@ -16049,15 +16088,6 @@ "browser-readablestream-to-it": "^1.0.3" } }, - "block-stream": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", - "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", - "dev": true, - "requires": { - "inherits": "~2.0.0" - } - }, "bluebird": { "version": "3.7.2", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", @@ -16602,6 +16632,12 @@ "readdirp": "~3.5.0" } }, + "chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "dev": true + }, "chrome-trace-event": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", @@ -18795,6 +18831,15 @@ "universalify": "^0.1.0" } }, + "fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dev": true, + "requires": { + "minipass": "^3.0.0" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -18821,12 +18866,12 @@ }, "dependencies": { "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "requires": { - "minimist": "^1.2.5" + "minimist": "^1.2.6" } } } @@ -20669,9 +20714,9 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" }, "minipass": { "version": "3.1.6", @@ -20682,6 +20727,16 @@ "yallist": "^4.0.0" } }, + "minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dev": true, + "requires": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + } + }, "mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -20689,9 +20744,9 @@ "dev": true }, "mocha": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.3.2.tgz", - "integrity": "sha512-UdmISwr/5w+uXLPKspgoV7/RXZwKRTiTjJ2/AC5ZiEztIoOYdfKb19+9jNmEInzx5pBsCyJQzarAxqIGBNYJhg==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-8.4.0.tgz", + "integrity": "sha512-hJaO0mwDXmZS4ghXsvPVriOhsxQ7ofcpQdm8dE+jISUOKopitvnXFQmpRR7jd2K6VBG6E26gU3IAbXXGIbu4sQ==", "dev": true, "requires": { "@ungap/promise-all-settled": "1.1.2", @@ -22922,14 +22977,17 @@ "dev": true }, "tar": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz", - "integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==", + "version": "6.1.11", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz", + "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==", "dev": true, "requires": { - "block-stream": "*", - "fstream": "^1.0.12", - "inherits": "2" + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^3.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" } }, "tar-stream": { From 0b97ff76b2d349d032ef37277a3abedd0f97abb1 Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 8 Jul 2022 19:52:20 +0900 Subject: [PATCH 25/42] Updated code owner --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 73bfd9b4..acb777eb 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -6,7 +6,7 @@ # @global-owner1 and @global-owner2 will be requested for # review when someone opens a pull request. #* @global-owner1 @global-owner2 -* @jimni1222 @aeharvlee +* @jimni1222 @kjhman21 # Order is important; the last matching pattern takes the most # precedence. When someone opens a pull request that only From 2961af7e8b0094b0ead5f14a0bfeac7e2f50011a Mon Sep 17 00:00:00 2001 From: Jamie Date: Mon, 11 Jul 2022 15:51:43 +0900 Subject: [PATCH 26/42] Added governance KIP-71 fields --- test/packages/caver.rpc.js | 11 ++++++++++ types/packages/caver-rpc/src/governance.d.ts | 23 +++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/test/packages/caver.rpc.js b/test/packages/caver.rpc.js index 007868fa..0e6ef4bc 100644 --- a/test/packages/caver.rpc.js +++ b/test/packages/caver.rpc.js @@ -849,6 +849,10 @@ describe('caver.rpc.governance', () => { expect(payload.params.length).to.equal(caver.rpc.governance.getChainConfig.method.params) const ret = { chainId: 1001, + istanbulCompatibleBlock: 0, + londonCompatibleBlock: 0, + ethTxTypeCompatibleBlock: 0, + kip71CompatibleBlock: 1, deriveShaImpl: 2, governance: { governanceMode: 'ballot', @@ -862,6 +866,13 @@ describe('caver.rpc.governance', () => { stakingUpdateInterval: 20, useGiniCoeff: false, }, + kip71: { + lowerboundbasefee: 25000000000, + upperboundbasefee: 750000000000, + gastarget: 30000000, + maxblockgasusedforbasefee: 60000000, + basefeedenominator: 20 + }, }, istanbul: { epoch: 20, policy: 2, sub: 1 }, unitPrice: 25000000000, diff --git a/types/packages/caver-rpc/src/governance.d.ts b/types/packages/caver-rpc/src/governance.d.ts index be82c9f8..269839f1 100644 --- a/types/packages/caver-rpc/src/governance.d.ts +++ b/types/packages/caver-rpc/src/governance.d.ts @@ -41,6 +41,10 @@ export interface Vote { export interface ChainConfig { chainId: number + istanbulCompatibleBlock?: number + londonCompatibleBlock?: number + ethTxTypeCompatibleBlock?: number + kip71CompatibleBlock?: number deriveShaImpl: number governance: { governanceMode: string @@ -54,6 +58,13 @@ export interface ChainConfig { stakingUpdateInterval: number useGiniCoeff: boolean } + kip71?: { + lowerboundbasefee: number + upperboundbasefee: number + gastarget: number + maxblockgasusedforbasefee: number + basefeedenominator: number + } } istanbul: { epoch: number @@ -77,6 +88,11 @@ export interface GovernanceItems { 'reward.ratio': string 'reward.stakingupdateinterval': number 'reward.useginicoeff': boolean + 'kip71.lowerboundbasefee': number + 'kip71.upperboundbasefee': number + 'kip71.gastarget': number + 'kip71.maxblockgasusedforbasefee': number + 'kip71.basefeedenominator': number } export interface VoteItems { @@ -95,6 +111,11 @@ export interface VoteItems { 'reward.minimumstake'?: string 'reward.proposerupdateinterval'?: number 'reward.stakingupdateinterval'?: number + 'kip71.lowerboundbasefee'?: number + 'kip71.upperboundbasefee'?: number + 'kip71.gastarget'?: number + 'kip71.maxblockgasusedforbasefee'?: number + 'kip71.basefeedenominator'?: number } export interface StakingInformation { @@ -105,7 +126,7 @@ export interface StakingInformation { CouncilStakingAmounts: number[] Gini: number KIRAddr: string - PoCAddr: string + PoCAddr: string // PoC is the previous name of KGF. UseGini: boolean } From c6169106e4b88acdbd6ec70f876e28077fdf82c2 Mon Sep 17 00:00:00 2001 From: Jamie Date: Mon, 11 Jul 2022 15:53:50 +0900 Subject: [PATCH 27/42] Added optional for optional fields --- types/packages/caver-rpc/src/governance.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/packages/caver-rpc/src/governance.d.ts b/types/packages/caver-rpc/src/governance.d.ts index 269839f1..70de1111 100644 --- a/types/packages/caver-rpc/src/governance.d.ts +++ b/types/packages/caver-rpc/src/governance.d.ts @@ -88,11 +88,11 @@ export interface GovernanceItems { 'reward.ratio': string 'reward.stakingupdateinterval': number 'reward.useginicoeff': boolean - 'kip71.lowerboundbasefee': number - 'kip71.upperboundbasefee': number - 'kip71.gastarget': number - 'kip71.maxblockgasusedforbasefee': number - 'kip71.basefeedenominator': number + 'kip71.lowerboundbasefee'?: number + 'kip71.upperboundbasefee'?: number + 'kip71.gastarget'?: number + 'kip71.maxblockgasusedforbasefee'?: number + 'kip71.basefeedenominator'?: number } export interface VoteItems { From a5391189a59a33fb93923e9bda77c267d0537d74 Mon Sep 17 00:00:00 2001 From: Jamie Date: Mon, 11 Jul 2022 17:35:12 +0900 Subject: [PATCH 28/42] Fixed lint error --- test/packages/caver.rpc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/packages/caver.rpc.js b/test/packages/caver.rpc.js index 0e6ef4bc..28e86ee2 100644 --- a/test/packages/caver.rpc.js +++ b/test/packages/caver.rpc.js @@ -871,7 +871,7 @@ describe('caver.rpc.governance', () => { upperboundbasefee: 750000000000, gastarget: 30000000, maxblockgasusedforbasefee: 60000000, - basefeedenominator: 20 + basefeedenominator: 20, }, }, istanbul: { epoch: 20, policy: 2, sub: 1 }, From e6e16957f989cb3736f13e16cd9b5adf50de15bd Mon Sep 17 00:00:00 2001 From: Namhoon Lee Date: Mon, 11 Jul 2022 18:29:00 +0900 Subject: [PATCH 29/42] Update index.d.ts --- types/packages/caver-abi/src/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/packages/caver-abi/src/index.d.ts b/types/packages/caver-abi/src/index.d.ts index cc8b943d..8a856475 100644 --- a/types/packages/caver-abi/src/index.d.ts +++ b/types/packages/caver-abi/src/index.d.ts @@ -25,7 +25,7 @@ export class ABI { decodeLog(inputs: AbiInput[], data: string, topics: string[]): Result decodeParameter(type: string | object, bytes: string): string decodeParameters(outputs: Array, bytes: string): Result - encodeContractDeploy(jsonInterface: AbiItem[], bytecode: string, args: any[]): string + encodeContractDeploy(jsonInterface: AbiItem[], bytecode: string, ...args: any[]): string encodeEventSignature(functionName: AbiItem | string): string encodeFunctionCall(jsonInterface: AbiItem, params: any): string encodeFunctionSignature(functionName: AbiItem | string): string From 900dbc7937459d9dff22cc7231bcf40041daa858 Mon Sep 17 00:00:00 2001 From: Namhoon Lee Date: Tue, 12 Jul 2022 11:02:22 +0900 Subject: [PATCH 30/42] empty commit for circle ci From 0318f4acbb77589d793ff6d6e21c7c5fb881292f Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 12 Jul 2022 16:57:45 +0900 Subject: [PATCH 31/42] Removed unused console --- test/personal.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/personal.js b/test/personal.js index 1d988638..a319ca94 100644 --- a/test/personal.js +++ b/test/personal.js @@ -153,7 +153,6 @@ describe('Personal RPC test', () => { }, password ) - console.log(receipt) expect(receipt).not.to.be.null expect(receipt.type).to.equals('TxTypeAccountUpdate') }).timeout(50000) From 422c593c6ed9f6d38ff38ba101fff0025a8c8314 Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 12 Jul 2022 09:14:14 +0900 Subject: [PATCH 32/42] Rename hardfork to Magma --- .../transactionTypes/abstractTransaction.js | 4 ++-- test/packages/caver.rpc.js | 4 ++-- types/packages/caver-rpc/src/governance.d.ts | 24 +++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js index d16d613f..9cc38414 100644 --- a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js +++ b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js @@ -183,11 +183,11 @@ class AbstractTransaction { let suggestedGasPrice if (baseFee > 0) { - // After hard KIP-71 fork, set gasPrice (or maxFeePerGas) with baseFee * 2 + // After hard Magma fork, set gasPrice (or maxFeePerGas) with baseFee * 2 suggestedGasPrice = baseFee * 2 suggestedGasPrice = utils.toHex(suggestedGasPrice) } else { - // Before hard KIP-71 fork, set gasPrice (or maxFeePerGas) with gas unit price + // Before hard Magma fork, set gasPrice (or maxFeePerGas) with gas unit price suggestedGasPrice = await this.klaytnCall.getGasPrice() } return suggestedGasPrice diff --git a/test/packages/caver.rpc.js b/test/packages/caver.rpc.js index 28e86ee2..d6ecef29 100644 --- a/test/packages/caver.rpc.js +++ b/test/packages/caver.rpc.js @@ -852,7 +852,7 @@ describe('caver.rpc.governance', () => { istanbulCompatibleBlock: 0, londonCompatibleBlock: 0, ethTxTypeCompatibleBlock: 0, - kip71CompatibleBlock: 1, + magmaCompatibleBlock: 1, deriveShaImpl: 2, governance: { governanceMode: 'ballot', @@ -866,7 +866,7 @@ describe('caver.rpc.governance', () => { stakingUpdateInterval: 20, useGiniCoeff: false, }, - kip71: { + magma: { lowerboundbasefee: 25000000000, upperboundbasefee: 750000000000, gastarget: 30000000, diff --git a/types/packages/caver-rpc/src/governance.d.ts b/types/packages/caver-rpc/src/governance.d.ts index 70de1111..1da65cb3 100644 --- a/types/packages/caver-rpc/src/governance.d.ts +++ b/types/packages/caver-rpc/src/governance.d.ts @@ -44,7 +44,7 @@ export interface ChainConfig { istanbulCompatibleBlock?: number londonCompatibleBlock?: number ethTxTypeCompatibleBlock?: number - kip71CompatibleBlock?: number + magmaCompatibleBlock?: number deriveShaImpl: number governance: { governanceMode: string @@ -58,7 +58,7 @@ export interface ChainConfig { stakingUpdateInterval: number useGiniCoeff: boolean } - kip71?: { + magma?: { lowerboundbasefee: number upperboundbasefee: number gastarget: number @@ -88,11 +88,11 @@ export interface GovernanceItems { 'reward.ratio': string 'reward.stakingupdateinterval': number 'reward.useginicoeff': boolean - 'kip71.lowerboundbasefee'?: number - 'kip71.upperboundbasefee'?: number - 'kip71.gastarget'?: number - 'kip71.maxblockgasusedforbasefee'?: number - 'kip71.basefeedenominator'?: number + 'magma.lowerboundbasefee'?: number + 'magma.upperboundbasefee'?: number + 'magma.gastarget'?: number + 'magma.maxblockgasusedforbasefee'?: number + 'magma.basefeedenominator'?: number } export interface VoteItems { @@ -111,11 +111,11 @@ export interface VoteItems { 'reward.minimumstake'?: string 'reward.proposerupdateinterval'?: number 'reward.stakingupdateinterval'?: number - 'kip71.lowerboundbasefee'?: number - 'kip71.upperboundbasefee'?: number - 'kip71.gastarget'?: number - 'kip71.maxblockgasusedforbasefee'?: number - 'kip71.basefeedenominator'?: number + 'magma.lowerboundbasefee'?: number + 'magma.upperboundbasefee'?: number + 'magma.gastarget'?: number + 'magma.maxblockgasusedforbasefee'?: number + 'magma.basefeedenominator'?: number } export interface StakingInformation { From 1b39c0a2ea543da3733029563e5be16b66ffec6e Mon Sep 17 00:00:00 2001 From: Jamie Date: Wed, 13 Jul 2022 14:18:37 +0900 Subject: [PATCH 33/42] Rename magma to kip71 --- .../transactionTypes/abstractTransaction.js | 4 ++-- test/packages/caver.rpc.js | 2 +- types/packages/caver-rpc/src/governance.d.ts | 22 +++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js index 9cc38414..c3449b99 100644 --- a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js +++ b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js @@ -183,11 +183,11 @@ class AbstractTransaction { let suggestedGasPrice if (baseFee > 0) { - // After hard Magma fork, set gasPrice (or maxFeePerGas) with baseFee * 2 + // After Magma hard fork, set gasPrice (or maxFeePerGas) with baseFee * 2 suggestedGasPrice = baseFee * 2 suggestedGasPrice = utils.toHex(suggestedGasPrice) } else { - // Before hard Magma fork, set gasPrice (or maxFeePerGas) with gas unit price + // Before Magma hard fork, set gasPrice (or maxFeePerGas) with gas unit price suggestedGasPrice = await this.klaytnCall.getGasPrice() } return suggestedGasPrice diff --git a/test/packages/caver.rpc.js b/test/packages/caver.rpc.js index d6ecef29..134b68e6 100644 --- a/test/packages/caver.rpc.js +++ b/test/packages/caver.rpc.js @@ -866,7 +866,7 @@ describe('caver.rpc.governance', () => { stakingUpdateInterval: 20, useGiniCoeff: false, }, - magma: { + kip71: { lowerboundbasefee: 25000000000, upperboundbasefee: 750000000000, gastarget: 30000000, diff --git a/types/packages/caver-rpc/src/governance.d.ts b/types/packages/caver-rpc/src/governance.d.ts index 1da65cb3..eef840c7 100644 --- a/types/packages/caver-rpc/src/governance.d.ts +++ b/types/packages/caver-rpc/src/governance.d.ts @@ -58,7 +58,7 @@ export interface ChainConfig { stakingUpdateInterval: number useGiniCoeff: boolean } - magma?: { + kip71?: { lowerboundbasefee: number upperboundbasefee: number gastarget: number @@ -88,11 +88,11 @@ export interface GovernanceItems { 'reward.ratio': string 'reward.stakingupdateinterval': number 'reward.useginicoeff': boolean - 'magma.lowerboundbasefee'?: number - 'magma.upperboundbasefee'?: number - 'magma.gastarget'?: number - 'magma.maxblockgasusedforbasefee'?: number - 'magma.basefeedenominator'?: number + 'kip71.lowerboundbasefee'?: number + 'kip71.upperboundbasefee'?: number + 'kip71.gastarget'?: number + 'kip71.maxblockgasusedforbasefee'?: number + 'kip71.basefeedenominator'?: number } export interface VoteItems { @@ -111,11 +111,11 @@ export interface VoteItems { 'reward.minimumstake'?: string 'reward.proposerupdateinterval'?: number 'reward.stakingupdateinterval'?: number - 'magma.lowerboundbasefee'?: number - 'magma.upperboundbasefee'?: number - 'magma.gastarget'?: number - 'magma.maxblockgasusedforbasefee'?: number - 'magma.basefeedenominator'?: number + 'kip71.lowerboundbasefee'?: number + 'kip71.upperboundbasefee'?: number + 'kip71.gastarget'?: number + 'kip71.maxblockgasusedforbasefee'?: number + 'kip71.basefeedenominator'?: number } export interface StakingInformation { From 13967dfa59d4403affb7dcc7dbd1cb9be4715106 Mon Sep 17 00:00:00 2001 From: Ayanami Date: Wed, 13 Jul 2022 16:18:11 +0900 Subject: [PATCH 34/42] Fixed bug that timeout option doesn't work properly Backport https://github.com/ChainSafe/web3.js/pull/5228 to fix bug --- package.json | 1 + .../caver-providers-http/src/index.js | 43 +++++++--------- test/invalidResponse.js | 51 ++++++++----------- 3 files changed, 42 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index 2fc57890..60febc6d 100644 --- a/package.json +++ b/package.json @@ -121,6 +121,7 @@ "eslint-plugin-prettier": "3.1.1", "eslint-plugin-react": "^7.28.0", "exorcist": "2.0.0", + "fetch-mock": "^9.11.0", "jsdoc": "^3.6.7", "jsdoc-typeof-plugin": "^1.0.0", "jshint": "^2.13.4", diff --git a/packages/caver-core-requestmanager/caver-providers-http/src/index.js b/packages/caver-core-requestmanager/caver-providers-http/src/index.js index 99cd04cb..8fd2c1bc 100644 --- a/packages/caver-core-requestmanager/caver-providers-http/src/index.js +++ b/packages/caver-core-requestmanager/caver-providers-http/src/index.js @@ -27,11 +27,11 @@ * @date 2015 */ -const fetch = require('cross-fetch') const http = require('http') const https = require('https') // Apply missing polyfill for IE +require('cross-fetch/polyfill') require('es6-promise').polyfill() require('abortcontroller-polyfill/dist/polyfill-patch-fetch') @@ -85,14 +85,15 @@ HttpProvider.prototype.send = function(payload, callback) { if (typeof AbortController !== 'undefined') { controller = new AbortController() // eslint-disable-next-line no-undef - } else if (typeof AbortController === 'undefined' && typeof window !== 'undefined' && typeof window.AbortController !== 'undefined') { + } else if (typeof window !== 'undefined' && typeof window.AbortController !== 'undefined') { // Some chrome version doesn't recognize new AbortController(); so we are using it from window instead // https://stackoverflow.com/questions/55718778/why-abortcontroller-is-not-defined // eslint-disable-next-line no-undef controller = new window.AbortController() - } else { - // Disable user defined timeout - this.timeout = 0 + } + + if (typeof controller !== 'undefined') { + options.signal = controller.signal } // the current runtime is node @@ -134,33 +135,26 @@ HttpProvider.prototype.send = function(payload, callback) { options.headers = headers - if (this.timeout > 0) { + if (this.timeout > 0 && typeof controller !== 'undefined') { this.timeoutId = setTimeout(function() { controller.abort() }, this.timeout) } - // Prevent global leak of connected - const _this = this - const success = function(response) { if (this.timeoutId !== undefined) { clearTimeout(this.timeoutId) } - let result = response - const error = null - - try { - // Response is a stream data so should be awaited for json response - result.json().then(function(data) { - result = data - _this.connected = true - callback(error, result) + + // Response is a stream data so should be awaited for json response + response + .json() + .then(function(data) { + callback(null, data) + }) + .catch(function() { + callback(errors.InvalidResponse(response)) }) - } catch (e) { - _this.connected = false - callback(errors.InvalidResponse(result)) - } } const failed = function(error) { @@ -169,14 +163,15 @@ HttpProvider.prototype.send = function(payload, callback) { } if (error.name === 'AbortError') { - _this.connected = false callback(errors.ConnectionTimeout(this.timeout)) } - _this.connected = false callback(errors.InvalidConnection(this.host)) } + // Disable eslint warning since fetch API is available through polyfill + // https://github.com/lquixada/cross-fetch#install + // eslint-disable-next-line no-undef fetch(this.host, options) .then(success.bind(this)) .catch(failed.bind(this)) diff --git a/test/invalidResponse.js b/test/invalidResponse.js index 1209f0d6..49b51ea8 100644 --- a/test/invalidResponse.js +++ b/test/invalidResponse.js @@ -16,39 +16,32 @@ along with the caver-js. If not, see . */ -const { expect, assert } = require('./extendedChai') +const fetchMock = require('fetch-mock') +const { expect } = require('./extendedChai') const Caver = require('../index') -let caver - describe('Connection error test', () => { - it('CAVERJS-UNIT-ETC-051: host url is invalid, return connection error.', async () => { - caver = new Caver(new Caver.providers.HttpProvider('invalid:1234', { timeout: 5000 })) - try { - await caver.klay.getNodeInfo() - assert(false) - } catch (err) { - expect(err.message).to.equals("CONNECTION ERROR: Couldn't connect to node invalid:1234.") - } - }).timeout(10000) - - it('CAVERJS-UNIT-ETC-052: without timeout return connection error.', async () => { - caver = new Caver('http://localhost:1234/') - try { - await caver.klay.getNodeInfo() - assert(false) - } catch (err) { - expect(err.message).to.equals("CONNECTION ERROR: Couldn't connect to node http://localhost:1234/.") - } + it('CAVERJS-UNIT-ETC-051: return connection error.', async () => { + const caver = new Caver(new Caver.providers.HttpProvider('invalid:1234')) + + await expect(caver.klay.getNodeInfo()).to.be.rejectedWith(Error, "CONNECTION ERROR: Couldn't connect to node invalid:1234.") + }) + + it('CAVERJS-UNIT-ETC-052: return invalid response error for non-json response.', async () => { + const caver = new Caver(new Caver.providers.HttpProvider('/fetchMock')) + + fetchMock.mock('/fetchMock', 'Testing non-json format response') + + await expect(caver.klay.getChainId()).to.be.rejectedWith(Error, /Invalid JSON RPC response/) + fetchMock.restore() }) - it('CAVERJS-UNIT-ETC-053: with timeout return connection error.', async () => { - caver = new Caver(new Caver.providers.HttpProvider('http://localhost:1234/', { timeout: 5000 })) - try { - await caver.klay.getNodeInfo() - assert(false) - } catch (err) { - expect(err.message).to.equals("CONNECTION ERROR: Couldn't connect to node http://localhost:1234/.") - } + it('CAVERJS-UNIT-ETC-053: return timeout error.', async () => { + const caver = new Caver(new Caver.providers.HttpProvider('/fetchMock', { timeout: 500 })) + + fetchMock.mock('/fetchMock', 'Testing non-json format response', { delay: 1000 }) + + await expect(caver.klay.getChainId()).to.be.rejectedWith(Error, 'CONNECTION TIMEOUT: timeout of 500ms achived') + fetchMock.restore() }) }) From 7a94d9ad752b9555443c2e1eade3d3f117f70383 Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 15 Jul 2022 13:29:24 +0900 Subject: [PATCH 35/42] Added newly added klay APIs for upper/lower bound gas price --- packages/caver-rpc/src/klay.js | 36 ++++++++++++++++++++++++++ test/packages/caver.rpc.js | 36 ++++++++++++++++++++++++++ types/packages/caver-rpc/src/klay.d.ts | 6 +++++ types/test/rpc-test.ts | 13 ++++++++++ 4 files changed, 91 insertions(+) diff --git a/packages/caver-rpc/src/klay.js b/packages/caver-rpc/src/klay.js index 81782363..44d368d4 100644 --- a/packages/caver-rpc/src/klay.js +++ b/packages/caver-rpc/src/klay.js @@ -2006,6 +2006,42 @@ class Klay { call: 'klay_maxPriorityFeePerGas', params: 0, }), + /** + * Returns an upper bound gas price. + * + * @memberof Klay + * @method getUpperBoundGasPrice + * @instance + * + * @example + * const result = await caver.rpc.klay.getUpperBoundGasPrice() + * + * @param {function} [callback] Optional callback, returns an error object as the first parameter and the result as the second. + * @return {Promise} An upper bound gas price + */ + new Method({ + name: 'getUpperBoundGasPrice', + call: 'klay_upperBoundGasPrice', + params: 0, + }), + /** + * Returns a lower bound gas price. + * + * @memberof Klay + * @method getLowerBoundGasPrice + * @instance + * + * @example + * const result = await caver.rpc.klay.getLowerBoundGasPrice() + * + * @param {function} [callback] Optional callback, returns an error object as the first parameter and the result as the second. + * @return {Promise} A lower bound gas price + */ + new Method({ + name: 'getLowerBoundGasPrice', + call: 'klay_lowerBoundGasPrice', + params: 0, + }), /** * An object defines an access list result that includes accessList and gasUsed. * diff --git a/test/packages/caver.rpc.js b/test/packages/caver.rpc.js index 134b68e6..0ebec71a 100644 --- a/test/packages/caver.rpc.js +++ b/test/packages/caver.rpc.js @@ -576,6 +576,42 @@ describe('caver.rpc.klay', () => { }).timeout(100000) }) + context('caver.rpc.klay.getUpperBoundGasPrice', () => { + it('CAVERJS-UNIT-RPC-035: should call klay_upperBoundGasPrice', async () => { + sandbox.stub(caver.rpc.klay._requestManager, 'send').callsFake((data, callback) => { + expect(data.method).to.equal('klay_upperBoundGasPrice') + callback(undefined, {}) + }) + + await caver.rpc.klay.getUpperBoundGasPrice() + }).timeout(100000) + + it('CAVERJS-UNIT-RPC-036: should return an upper bound gas price', async () => { + const ret = await caver.rpc.klay.getUpperBoundGasPrice() + const gasPrice = await caver.rpc.klay.getGasPrice() + expect(_.isString(ret)).to.be.true + expect(ret).to.equal(gasPrice) + }).timeout(100000) + }) + + context('caver.rpc.klay.getLowerBoundGasPrice', () => { + it('CAVERJS-UNIT-RPC-037: should call klay_lowerBoundGasPrice', async () => { + sandbox.stub(caver.rpc.klay._requestManager, 'send').callsFake((data, callback) => { + expect(data.method).to.equal('klay_lowerBoundGasPrice') + callback(undefined, {}) + }) + + await caver.rpc.klay.getLowerBoundGasPrice() + }).timeout(100000) + + it('CAVERJS-UNIT-RPC-038: should return an lower bound gas price', async () => { + const ret = await caver.rpc.klay.getLowerBoundGasPrice() + const gasPrice = await caver.rpc.klay.getGasPrice() + expect(_.isString(ret)).to.be.true + expect(ret).to.equal(gasPrice) + }).timeout(100000) + }) + context('caver.rpc.klay.createAccessList', () => { const txArgs = { from: '0x3bc5885c2941c5cda454bdb4a8c88aa7f248e312', diff --git a/types/packages/caver-rpc/src/klay.d.ts b/types/packages/caver-rpc/src/klay.d.ts index 41cb1b04..bd31f5b9 100644 --- a/types/packages/caver-rpc/src/klay.d.ts +++ b/types/packages/caver-rpc/src/klay.d.ts @@ -251,6 +251,12 @@ export class Klay { getMaxPriorityFeePerGas( callback?: (error: Error, result: string) => void ): Promise + getUpperBoundGasPrice( + callback?: (error: Error, result: string) => void + ): Promise + getLowerBoundGasPrice( + callback?: (error: Error, result: string) => void + ): Promise createAccessList( callObject: CallObject, blockNumber: BlockNumber, diff --git a/types/test/rpc-test.ts b/types/test/rpc-test.ts index 585e7fe9..0beb131e 100644 --- a/types/test/rpc-test.ts +++ b/types/test/rpc-test.ts @@ -1133,6 +1133,19 @@ rpc.klay.getGasPrice() // $ExpectType Promise rpc.klay.getGasPrice((err: Error, ret: string) => {}) +// $ExpectType Promise +rpc.klay.getMaxPriorityFeePerGas() +// $ExpectType Promise +rpc.klay.getMaxPriorityFeePerGas((err: Error, ret: string) => {}) +// $ExpectType Promise +rpc.klay.getUpperBoundGasPrice() +// $ExpectType Promise +rpc.klay.getUpperBoundGasPrice((err: Error, ret: string) => {}) +// $ExpectType Promise +rpc.klay.getLowerBoundGasPrice() +// $ExpectType Promise +rpc.klay.getLowerBoundGasPrice((err: Error, ret: string) => {}) + // $ExpectType Promise rpc.klay.getGasPriceAt(0) // $ExpectType Promise From abf7d6855910bec78530b6e9c82f49e9903d2b5b Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 15 Jul 2022 13:34:00 +0900 Subject: [PATCH 36/42] Fixed test code --- test/packages/caver.rpc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/packages/caver.rpc.js b/test/packages/caver.rpc.js index 0ebec71a..fbe3358b 100644 --- a/test/packages/caver.rpc.js +++ b/test/packages/caver.rpc.js @@ -590,7 +590,7 @@ describe('caver.rpc.klay', () => { const ret = await caver.rpc.klay.getUpperBoundGasPrice() const gasPrice = await caver.rpc.klay.getGasPrice() expect(_.isString(ret)).to.be.true - expect(ret).to.equal(gasPrice) + expect(caver.utils.hexToNumber(ret) >= caver.utils.hexToNumber(gasPrice)).to.be.true }).timeout(100000) }) @@ -608,7 +608,7 @@ describe('caver.rpc.klay', () => { const ret = await caver.rpc.klay.getLowerBoundGasPrice() const gasPrice = await caver.rpc.klay.getGasPrice() expect(_.isString(ret)).to.be.true - expect(ret).to.equal(gasPrice) + expect(caver.utils.hexToNumber(ret) <= caver.utils.hexToNumber(gasPrice)).to.be.true }).timeout(100000) }) From 8d053e27fd87fc0ab76a01d8b556a5cd9e09b3fa Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 15 Jul 2022 13:37:41 +0900 Subject: [PATCH 37/42] Added dependency --- package-lock.json | 171 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) diff --git a/package-lock.json b/package-lock.json index e6e00136..bc4d290a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -65,6 +65,7 @@ "eslint-plugin-prettier": "3.1.1", "eslint-plugin-react": "^7.28.0", "exorcist": "2.0.0", + "fetch-mock": "^9.11.0", "jsdoc": "^3.6.7", "jsdoc-typeof-plugin": "^1.0.0", "jshint": "^2.13.4", @@ -6829,6 +6830,82 @@ "integrity": "sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow==", "dev": true }, + "node_modules/fetch-mock": { + "version": "9.11.0", + "resolved": "https://registry.npmjs.org/fetch-mock/-/fetch-mock-9.11.0.tgz", + "integrity": "sha512-PG1XUv+x7iag5p/iNHD4/jdpxL9FtVSqRMUQhPab4hVDt80T1MH5ehzVrL2IdXO9Q2iBggArFvPqjUbHFuI58Q==", + "dev": true, + "dependencies": { + "@babel/core": "^7.0.0", + "@babel/runtime": "^7.0.0", + "core-js": "^3.0.0", + "debug": "^4.1.1", + "glob-to-regexp": "^0.4.0", + "is-subset": "^0.1.1", + "lodash.isequal": "^4.5.0", + "path-to-regexp": "^2.2.1", + "querystring": "^0.2.0", + "whatwg-url": "^6.5.0" + }, + "engines": { + "node": ">=4.0.0" + }, + "funding": { + "type": "charity", + "url": "https://www.justgiving.com/refugee-support-europe" + }, + "peerDependencies": { + "node-fetch": "*" + }, + "peerDependenciesMeta": { + "node-fetch": { + "optional": true + } + } + }, + "node_modules/fetch-mock/node_modules/core-js": { + "version": "3.23.4", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.23.4.tgz", + "integrity": "sha512-vjsKqRc1RyAJC3Ye2kYqgfdThb3zYnx9CrqoCcjMOENMtQPC7ZViBvlDxwYU/2z2NI/IPuiXw5mT4hWhddqjzQ==", + "dev": true, + "hasInstallScript": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, + "node_modules/fetch-mock/node_modules/path-to-regexp": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.4.0.tgz", + "integrity": "sha512-G6zHoVqC6GGTQkZwF4lkuEyMbVOjoBKAEybQUypI1WTkqinCOrq2x6U2+phkJ1XsEMTy4LjtwPI7HW+NVrRR2w==", + "dev": true + }, + "node_modules/fetch-mock/node_modules/tr46": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", + "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/fetch-mock/node_modules/webidl-conversions": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", + "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", + "dev": true + }, + "node_modules/fetch-mock/node_modules/whatwg-url": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.5.0.tgz", + "integrity": "sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ==", + "dev": true, + "dependencies": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + }, "node_modules/file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -8377,6 +8454,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-subset": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", + "integrity": "sha512-6Ybun0IkarhmEqxXCNw/C0bna6Zb/TkfUX9UbwJtK6ObwAVCxmAP308WWTHviM/zAqXk05cdhYsUsZeGQh99iw==", + "dev": true + }, "node_modules/is-symbol": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", @@ -9203,6 +9286,12 @@ "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", "dev": true }, + "node_modules/lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", + "dev": true + }, "node_modules/lodash.memoize": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", @@ -9215,6 +9304,12 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "node_modules/lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", + "dev": true + }, "node_modules/log-symbols": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", @@ -18700,6 +18795,64 @@ "integrity": "sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow==", "dev": true }, + "fetch-mock": { + "version": "9.11.0", + "resolved": "https://registry.npmjs.org/fetch-mock/-/fetch-mock-9.11.0.tgz", + "integrity": "sha512-PG1XUv+x7iag5p/iNHD4/jdpxL9FtVSqRMUQhPab4hVDt80T1MH5ehzVrL2IdXO9Q2iBggArFvPqjUbHFuI58Q==", + "dev": true, + "requires": { + "@babel/core": "^7.0.0", + "@babel/runtime": "^7.0.0", + "core-js": "^3.0.0", + "debug": "^4.1.1", + "glob-to-regexp": "^0.4.0", + "is-subset": "^0.1.1", + "lodash.isequal": "^4.5.0", + "path-to-regexp": "^2.2.1", + "querystring": "^0.2.0", + "whatwg-url": "^6.5.0" + }, + "dependencies": { + "core-js": { + "version": "3.23.4", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.23.4.tgz", + "integrity": "sha512-vjsKqRc1RyAJC3Ye2kYqgfdThb3zYnx9CrqoCcjMOENMtQPC7ZViBvlDxwYU/2z2NI/IPuiXw5mT4hWhddqjzQ==", + "dev": true + }, + "path-to-regexp": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-2.4.0.tgz", + "integrity": "sha512-G6zHoVqC6GGTQkZwF4lkuEyMbVOjoBKAEybQUypI1WTkqinCOrq2x6U2+phkJ1XsEMTy4LjtwPI7HW+NVrRR2w==", + "dev": true + }, + "tr46": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", + "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "webidl-conversions": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", + "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", + "dev": true + }, + "whatwg-url": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.5.0.tgz", + "integrity": "sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ==", + "dev": true, + "requires": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + } + } + }, "file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -19882,6 +20035,12 @@ "has-tostringtag": "^1.0.0" } }, + "is-subset": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", + "integrity": "sha512-6Ybun0IkarhmEqxXCNw/C0bna6Zb/TkfUX9UbwJtK6ObwAVCxmAP308WWTHviM/zAqXk05cdhYsUsZeGQh99iw==", + "dev": true + }, "is-symbol": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", @@ -20545,6 +20704,12 @@ "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", "dev": true }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", + "dev": true + }, "lodash.memoize": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", @@ -20557,6 +20722,12 @@ "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true }, + "lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", + "dev": true + }, "log-symbols": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", From 9c5b3c14010f523c74159a0c1217e3094e201bff Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 19 Jul 2022 09:31:05 +0900 Subject: [PATCH 38/42] Rename function to suggestGasPrice --- packages/caver-klay/caver-klay-accounts/src/index.js | 8 ++++---- .../src/transactionTypes/abstractTransaction.js | 8 ++++---- .../src/transactionTypes/accountUpdate/accountUpdate.js | 2 +- .../accountUpdate/feeDelegatedAccountUpdate.js | 2 +- .../accountUpdate/feeDelegatedAccountUpdateWithRatio.js | 2 +- .../src/transactionTypes/cancel/cancel.js | 2 +- .../src/transactionTypes/cancel/feeDelegatedCancel.js | 2 +- .../cancel/feeDelegatedCancelWithRatio.js | 2 +- .../chainDataAnchoring/chainDataAnchoring.js | 2 +- .../chainDataAnchoring/feeDelegatedChainDataAnchoring.js | 2 +- .../feeDelegatedChainDataAnchoringWithRatio.js | 2 +- .../ethereumTypedTransaction/ethereumAccessList.js | 2 +- .../ethereumTypedTransaction/ethereumDynamicFee.js | 2 +- .../legacyTransaction/legacyTransaction.js | 2 +- .../feeDelegatedSmartContractDeploy.js | 2 +- .../feeDelegatedSmartContractDeployWithRatio.js | 2 +- .../smartContractDeploy/smartContractDeploy.js | 2 +- .../feeDelegatedSmartContractExecution.js | 2 +- .../feeDelegatedSmartContractExecutionWithRatio.js | 2 +- .../smartContractExecution/smartContractExecution.js | 2 +- .../valueTransfer/feeDelegatedValueTransfer.js | 2 +- .../valueTransfer/feeDelegatedValueTransferWithRatio.js | 2 +- .../src/transactionTypes/valueTransfer/valueTransfer.js | 2 +- .../valueTransferMemo/feeDelegatedValueTransferMemo.js | 2 +- .../feeDelegatedValueTransferMemoWithRatio.js | 2 +- .../valueTransferMemo/valueTransferMemo.js | 2 +- 26 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/caver-klay/caver-klay-accounts/src/index.js b/packages/caver-klay/caver-klay-accounts/src/index.js index 9871b84e..8a17a7dc 100644 --- a/packages/caver-klay/caver-klay-accounts/src/index.js +++ b/packages/caver-klay/caver-klay-accounts/src/index.js @@ -394,14 +394,14 @@ Accounts.prototype._getRoleKey = function _getRoleKey(tx, account) { } /** - * _suggestedGasPrice returns suggested gas price. + * _suggestGasPrice suggests a gas price. * This function will be used to set gasPrice field if that is omitted. * Before common architecture does not support newly added transaction types. * - * @method _suggestedGasPrice + * @method _suggestGasPrice * @return {string} */ -Accounts.prototype._suggestedGasPrice = async function _suggestedGasPrice() { +Accounts.prototype._suggestGasPrice = async function _suggestGasPrice() { const header = await this._klaytnCall.getHeader('latest') const bf = utils.hexToNumber(header.baseFeePerGas || '0x0') @@ -909,7 +909,7 @@ Accounts.prototype.signTransaction = function signTransaction() { // Otherwise, get the missing info from the Klaytn Node return Promise.all([ isNot(tx.chainId) ? _this._klaytnCall.getChainId() : tx.chainId, - isNot(tx.gasPrice) ? _this._suggestedGasPrice() : tx.gasPrice, + isNot(tx.gasPrice) ? _this._suggestGasPrice() : tx.gasPrice, isNot(tx.nonce) ? _this._klaytnCall.getTransactionCount(tx.from, 'pending') : tx.nonce, ]).then(function(args) { if (isNot(args[0]) || isNot(args[1]) || isNot(args[2])) { diff --git a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js index c3449b99..3fdfd630 100644 --- a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js +++ b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js @@ -167,17 +167,17 @@ class AbstractTransaction { } /** - * Returns a suggested gas price to use in the transaction. + * Suggests a gas price to use in the transaction. * If `baseFee` is bigger than `0` in the header, * then returns `baseFee * 2`. * If not, calls `klay_gasPrice` to return unit price of the gas. * * @example - * const result = await tx.suggestedGasPrice() + * const result = await tx.suggestGasPrice() * * @return {string} gas price */ - async suggestedGasPrice() { + async suggestGasPrice() { const bfStr = await this.getBaseFee() const baseFee = utils.hexToNumber(bfStr) @@ -196,7 +196,7 @@ class AbstractTransaction { /** * Calls `klay_gasPrice` klay rpc call. * Note that when Klaytn network use dynamic gas fee, - * you need to use `tx.suggestedGasPrice` function in the gasPrice field. + * you need to use `tx.suggestGasPrice` function in the gasPrice field. * * @example * const result = await tx.getGasPrice() diff --git a/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js b/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js index 2594767f..c80c3a5c 100644 --- a/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js +++ b/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.js @@ -180,7 +180,7 @@ class AccountUpdate extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js index 2da42c59..4eb75101 100644 --- a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js +++ b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.js @@ -186,7 +186,7 @@ class FeeDelegatedAccountUpdate extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js index 6497df56..998627b1 100644 --- a/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.js @@ -190,7 +190,7 @@ class FeeDelegatedAccountUpdateWithRatio extends AbstractFeeDelegatedWithRatioTr async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/cancel/cancel.js b/packages/caver-transaction/src/transactionTypes/cancel/cancel.js index e7a235fb..bd69ca36 100644 --- a/packages/caver-transaction/src/transactionTypes/cancel/cancel.js +++ b/packages/caver-transaction/src/transactionTypes/cancel/cancel.js @@ -154,7 +154,7 @@ class Cancel extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js index 52eebe35..d4469838 100644 --- a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js +++ b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.js @@ -159,7 +159,7 @@ class FeeDelegatedCancel extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js index e8d668f1..195e5bcf 100644 --- a/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.js @@ -164,7 +164,7 @@ class FeeDelegatedCancelWithRatio extends AbstractFeeDelegatedWithRatioTransacti async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js index ba6d9885..cb85a152 100644 --- a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js +++ b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.js @@ -174,7 +174,7 @@ class ChainDataAnchoring extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js index 6abc7058..89cc3d72 100644 --- a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js +++ b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.js @@ -181,7 +181,7 @@ class FeeDelegatedChainDataAnchoring extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js index be43dfe6..056ce7df 100644 --- a/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.js @@ -184,7 +184,7 @@ class FeeDelegatedChainDataAnchoringWithRatio extends AbstractFeeDelegatedWithRa async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js index 123cbbec..bcfd5e26 100644 --- a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js +++ b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumAccessList.js @@ -373,7 +373,7 @@ class EthereumAccessList extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js index 820279c2..8ec4ce0b 100644 --- a/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js +++ b/packages/caver-transaction/src/transactionTypes/ethereumTypedTransaction/ethereumDynamicFee.js @@ -394,7 +394,7 @@ class EthereumDynamicFee extends AbstractTransaction { isNot(this.chainId) ? this.getChainId() : this.chainId, isNotMaxPriorityFeePerGas ? this.getMaxPriorityFeePerGas() : this.maxPriorityFeePerGas, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, - isNotMaxFeePerGas ? this.suggestedGasPrice() : this.maxFeePerGas, + isNotMaxFeePerGas ? this.suggestGasPrice() : this.maxFeePerGas, ]) this.chainId = chainId diff --git a/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js b/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js index 62a65327..aa2a066e 100644 --- a/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js +++ b/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.js @@ -268,7 +268,7 @@ class LegacyTransaction extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js index 4f3572dd..a525fa8a 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeploy.js @@ -260,7 +260,7 @@ class FeeDelegatedSmartContractDeploy extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js index 002fa8d9..0b76405c 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/feeDelegatedSmartContractDeployWithRatio.js @@ -275,7 +275,7 @@ class FeeDelegatedSmartContractDeployWithRatio extends AbstractFeeDelegatedWithR async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js index 22c3bc23..2cf4b05b 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.js @@ -254,7 +254,7 @@ class SmartContractDeploy extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js index 1bf52e76..f1b96d1e 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.js @@ -226,7 +226,7 @@ class FeeDelegatedSmartContractExecution extends AbstractFeeDelegatedTransaction async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js index 76cb2432..1360dd89 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.js @@ -229,7 +229,7 @@ class FeeDelegatedSmartContractExecutionWithRatio extends AbstractFeeDelegatedWi async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js b/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js index 1e72cafa..8cf4e44d 100644 --- a/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js +++ b/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.js @@ -219,7 +219,7 @@ class SmartContractExecution extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js index 162d0f40..566a0b21 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.js @@ -193,7 +193,7 @@ class FeeDelegatedValueTransfer extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js index ae041cf3..cc0c6849 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.js @@ -196,7 +196,7 @@ class FeeDelegatedValueTransferWithRatio extends AbstractFeeDelegatedWithRatioTr async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js b/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js index c351f345..c77fe661 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.js @@ -187,7 +187,7 @@ class ValueTransfer extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js index bebef412..484da55d 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.js @@ -224,7 +224,7 @@ class FeeDelegatedValueTransferMemo extends AbstractFeeDelegatedTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js index a5b2a091..85d2b1a2 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.js @@ -227,7 +227,7 @@ class FeeDelegatedValueTransferMemoWithRatio extends AbstractFeeDelegatedWithRat async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) diff --git a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js index cdfba575..4516a98a 100644 --- a/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js +++ b/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.js @@ -217,7 +217,7 @@ class ValueTransferMemo extends AbstractTransaction { async fillTransaction() { const [chainId, gasPrice, nonce] = await Promise.all([ isNot(this.chainId) ? this.getChainId() : this.chainId, - isNot(this.gasPrice) ? this.suggestedGasPrice() : this.gasPrice, + isNot(this.gasPrice) ? this.suggestGasPrice() : this.gasPrice, isNot(this.nonce) ? this.getNonce(this.from) : this.nonce, ]) From 1bfb8391a30d0c196b5a43da803e14a7cf5c03e8 Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 19 Jul 2022 12:07:25 +0900 Subject: [PATCH 39/42] Use klay_gasPrice to suggest gas price --- .../transactionTypes/abstractTransaction.js | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js index 3fdfd630..4fc4d22f 100644 --- a/packages/caver-transaction/src/transactionTypes/abstractTransaction.js +++ b/packages/caver-transaction/src/transactionTypes/abstractTransaction.js @@ -168,9 +168,7 @@ class AbstractTransaction { /** * Suggests a gas price to use in the transaction. - * If `baseFee` is bigger than `0` in the header, - * then returns `baseFee * 2`. - * If not, calls `klay_gasPrice` to return unit price of the gas. + * Calls `klay_gasPrice` to return unit price of the gas. * * @example * const result = await tx.suggestGasPrice() @@ -178,19 +176,8 @@ class AbstractTransaction { * @return {string} gas price */ async suggestGasPrice() { - const bfStr = await this.getBaseFee() - const baseFee = utils.hexToNumber(bfStr) - - let suggestedGasPrice - if (baseFee > 0) { - // After Magma hard fork, set gasPrice (or maxFeePerGas) with baseFee * 2 - suggestedGasPrice = baseFee * 2 - suggestedGasPrice = utils.toHex(suggestedGasPrice) - } else { - // Before Magma hard fork, set gasPrice (or maxFeePerGas) with gas unit price - suggestedGasPrice = await this.klaytnCall.getGasPrice() - } - return suggestedGasPrice + const suggestion = await this.klaytnCall.getGasPrice() + return suggestion } /** From 87b51a70098171d77643de792f67cffe1ea55bdf Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 19 Jul 2022 12:19:42 +0900 Subject: [PATCH 40/42] Fixed test code errors --- test/packages/caver.transaction/accountUpdate.js | 3 +-- test/packages/caver.transaction/cancel.js | 4 ++-- test/packages/caver.transaction/chainDataAnchoring.js | 4 ++-- test/packages/caver.transaction/ethereumAccessList.js | 4 ++-- test/packages/caver.transaction/ethereumDynamicFee.js | 10 ++++++---- .../caver.transaction/feeDelegatedAccountUpdate.js | 4 ++-- .../feeDelegatedAccountUpdateWithRatio.js | 3 +-- test/packages/caver.transaction/feeDelegatedCancel.js | 4 ++-- .../caver.transaction/feeDelegatedCancelWIthRatio.js | 4 ++-- .../feeDelegatedChainDataAnchoring.js | 4 ++-- .../feeDelegatedChainDataAnchoringWithRatio.js | 4 ++-- .../feeDelegatedSmartContractDeploy.js | 4 ++-- .../feeDelegatedSmartContractDeployWithRatio.js | 4 ++-- .../feeDelegatedSmartContractExecution.js | 4 ++-- .../feeDelegatedSmartContractExecutionWithRatio.js | 4 ++-- .../caver.transaction/feeDelegatedValueTransfer.js | 4 ++-- .../caver.transaction/feeDelegatedValueTransferMemo.js | 4 ++-- .../feeDelegatedValueTransferMemoWithRatio.js | 4 ++-- .../feeDelegatedValueTransferWithRatio.js | 4 ++-- test/packages/caver.transaction/legacyTransaction.js | 4 ++-- test/packages/caver.transaction/smartContractDeploy.js | 4 ++-- .../caver.transaction/smartContractExecution.js | 4 ++-- test/packages/caver.transaction/valueTransfer.js | 4 ++-- test/packages/caver.transaction/valueTransferMemo.js | 4 ++-- 24 files changed, 50 insertions(+), 50 deletions(-) diff --git a/test/packages/caver.transaction/accountUpdate.js b/test/packages/caver.transaction/accountUpdate.js index 53835ab7..3a9238cc 100644 --- a/test/packages/caver.transaction/accountUpdate.js +++ b/test/packages/caver.transaction/accountUpdate.js @@ -1008,9 +1008,8 @@ describe('TxTypeAccountUpdate', () => { await tx.fillTransaction() expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce - expect(getGasPriceSpy).not.to.have.been.calledOnce } - expect(getHeaderSpy).to.have.been.callCount(Object.values(expectedValues).length) + expect(getGasPriceSpy).to.have.been.callCount(Object.values(expectedValues).length) }).timeout(200000) it('CAVERJS-UNIT-TRANSACTION-196: fillTransaction should call klay_getTransactionCount to fill nonce when nonce is undefined', async () => { diff --git a/test/packages/caver.transaction/cancel.js b/test/packages/caver.transaction/cancel.js index ce868229..53f9368a 100644 --- a/test/packages/caver.transaction/cancel.js +++ b/test/packages/caver.transaction/cancel.js @@ -702,8 +702,8 @@ describe('TxTypeCancel', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/chainDataAnchoring.js b/test/packages/caver.transaction/chainDataAnchoring.js index 90ec1d6b..add76de9 100644 --- a/test/packages/caver.transaction/chainDataAnchoring.js +++ b/test/packages/caver.transaction/chainDataAnchoring.js @@ -724,8 +724,8 @@ describe('TxTypeChainDataAnchoring', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/ethereumAccessList.js b/test/packages/caver.transaction/ethereumAccessList.js index a158b230..49217979 100644 --- a/test/packages/caver.transaction/ethereumAccessList.js +++ b/test/packages/caver.transaction/ethereumAccessList.js @@ -870,8 +870,8 @@ describe('TxTypeEthereumAccessList', () => { const tx = caver.transaction.ethereumAccessList.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/ethereumDynamicFee.js b/test/packages/caver.transaction/ethereumDynamicFee.js index cdc6e5fe..6abb88f8 100644 --- a/test/packages/caver.transaction/ethereumDynamicFee.js +++ b/test/packages/caver.transaction/ethereumDynamicFee.js @@ -78,6 +78,7 @@ describe('TxTypeEthereumDynamicFee', () => { let getNonceSpy let getChainIdSpy + let getGasPriceSpy let getHeaderByNumberSpy let getMaxPriorityFeePerGasSpy @@ -127,6 +128,8 @@ describe('TxTypeEthereumDynamicFee', () => { getNonceSpy.returns('0x3a') getChainIdSpy = sandbox.stub(caver.transaction.klaytnCall, 'getChainId') getChainIdSpy.returns('0x7e3') + getGasPriceSpy = sandbox.stub(caver.transaction.klaytnCall, 'getGasPrice') + getGasPriceSpy.returns('0xba43b7400') baseFee = '0x5d21dba00' getHeaderByNumberSpy = sandbox.stub(caver.transaction.klaytnCall, 'getHeaderByNumber') getHeaderByNumberSpy.returns({ baseFeePerGas: baseFee }) @@ -907,6 +910,7 @@ describe('TxTypeEthereumDynamicFee', () => { await tx.fillTransaction() expect(getMaxPriorityFeePerGasSpy).to.have.been.calledOnce expect(getHeaderByNumberSpy).not.to.have.been.calledOnce // getHeader only when maxFeePerGas is empty to get baseFee. + expect(getGasPriceSpy).not.to.have.been.called expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) @@ -916,15 +920,13 @@ describe('TxTypeEthereumDynamicFee', () => { delete transactionObj.maxFeePerGas const tx = caver.transaction.ethereumDynamicFee.create(transactionObj) - const expectedMaxFeePerGas = caver.utils.toHex(caver.utils.hexToNumber(baseFee) * 2) - await tx.fillTransaction() expect(getMaxPriorityFeePerGasSpy).not.to.have.been.called - expect(getHeaderByNumberSpy).to.have.been.calledOnce + expect(getHeaderByNumberSpy).not.to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.called expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce - expect(tx.maxFeePerGas).to.equal(expectedMaxFeePerGas) }).timeout(200000) it('CAVERJS-UNIT-TRANSACTION-549: fillTransaction should call klay_getTransactionCount to fill nonce when nonce is undefined', async () => { diff --git a/test/packages/caver.transaction/feeDelegatedAccountUpdate.js b/test/packages/caver.transaction/feeDelegatedAccountUpdate.js index 5a61f27b..3f3f0e8d 100644 --- a/test/packages/caver.transaction/feeDelegatedAccountUpdate.js +++ b/test/packages/caver.transaction/feeDelegatedAccountUpdate.js @@ -1605,9 +1605,9 @@ describe('TxTypeFeeDelegatedAccountUpdate', () => { await tx.fillTransaction() expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce - expect(getGasPriceSpy).not.to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce } - expect(getHeaderSpy).to.have.been.callCount(Object.values(expectedValues).length) + expect(getGasPriceSpy).to.have.been.callCount(Object.values(expectedValues).length) }).timeout(200000) it('CAVERJS-UNIT-TRANSACTIONFD-220: fillTransaction should call klay_getTransactionCount to fill nonce when nonce is undefined', async () => { diff --git a/test/packages/caver.transaction/feeDelegatedAccountUpdateWithRatio.js b/test/packages/caver.transaction/feeDelegatedAccountUpdateWithRatio.js index df72e912..ea75e61c 100644 --- a/test/packages/caver.transaction/feeDelegatedAccountUpdateWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedAccountUpdateWithRatio.js @@ -1643,9 +1643,8 @@ describe('TxTypeFeeDelegatedAccountUpdateWithRatio', () => { await tx.fillTransaction() expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce - expect(getGasPriceSpy).not.to.have.been.calledOnce } - expect(getHeaderSpy).to.have.been.callCount(Object.values(expectedValues).length) + expect(getGasPriceSpy).to.have.been.callCount(Object.values(expectedValues).length) }).timeout(200000) it('CAVERJS-UNIT-TRANSACTIONFDR-223: fillTransaction should call klay_getTransactionCount to fill nonce when nonce is undefined', async () => { diff --git a/test/packages/caver.transaction/feeDelegatedCancel.js b/test/packages/caver.transaction/feeDelegatedCancel.js index f6800681..9e021f3e 100644 --- a/test/packages/caver.transaction/feeDelegatedCancel.js +++ b/test/packages/caver.transaction/feeDelegatedCancel.js @@ -1178,8 +1178,8 @@ describe('TxTypeFeeDelegatedCancel', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedCancelWIthRatio.js b/test/packages/caver.transaction/feeDelegatedCancelWIthRatio.js index e3ce7ce8..86e5ba79 100644 --- a/test/packages/caver.transaction/feeDelegatedCancelWIthRatio.js +++ b/test/packages/caver.transaction/feeDelegatedCancelWIthRatio.js @@ -1211,8 +1211,8 @@ describe('TxTypeFeeDelegatedCancelWithRatio', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedChainDataAnchoring.js b/test/packages/caver.transaction/feeDelegatedChainDataAnchoring.js index aea5c351..1712b1fd 100644 --- a/test/packages/caver.transaction/feeDelegatedChainDataAnchoring.js +++ b/test/packages/caver.transaction/feeDelegatedChainDataAnchoring.js @@ -1190,8 +1190,8 @@ describe('TxTypeFeeDelegatedChainDataAnchoring', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedChainDataAnchoringWithRatio.js b/test/packages/caver.transaction/feeDelegatedChainDataAnchoringWithRatio.js index 4945306d..eba57895 100644 --- a/test/packages/caver.transaction/feeDelegatedChainDataAnchoringWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedChainDataAnchoringWithRatio.js @@ -1224,8 +1224,8 @@ describe('TxTypeFeeDelegatedChainDataAnchoringWithRatio', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedSmartContractDeploy.js b/test/packages/caver.transaction/feeDelegatedSmartContractDeploy.js index 6ad04563..773b3f95 100644 --- a/test/packages/caver.transaction/feeDelegatedSmartContractDeploy.js +++ b/test/packages/caver.transaction/feeDelegatedSmartContractDeploy.js @@ -1218,8 +1218,8 @@ describe('TxTypeFeeDelegatedSmartContractDeploy', () => { const tx = caver.transaction.feeDelegatedSmartContractDeploy.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedSmartContractDeployWithRatio.js b/test/packages/caver.transaction/feeDelegatedSmartContractDeployWithRatio.js index 5351cfb8..52ab7f86 100644 --- a/test/packages/caver.transaction/feeDelegatedSmartContractDeployWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedSmartContractDeployWithRatio.js @@ -1252,8 +1252,8 @@ describe('TxTypeFeeDelegatedSmartContractDeployWithRatio', () => { const tx = caver.transaction.feeDelegatedSmartContractDeployWithRatio.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedSmartContractExecution.js b/test/packages/caver.transaction/feeDelegatedSmartContractExecution.js index 15c2297b..378adcd2 100644 --- a/test/packages/caver.transaction/feeDelegatedSmartContractExecution.js +++ b/test/packages/caver.transaction/feeDelegatedSmartContractExecution.js @@ -1216,8 +1216,8 @@ describe('TxTypeFeeDelegatedSmartContractExecution', () => { const tx = caver.transaction.feeDelegatedSmartContractExecution.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedSmartContractExecutionWithRatio.js b/test/packages/caver.transaction/feeDelegatedSmartContractExecutionWithRatio.js index 103c02d2..cb548333 100644 --- a/test/packages/caver.transaction/feeDelegatedSmartContractExecutionWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedSmartContractExecutionWithRatio.js @@ -1250,8 +1250,8 @@ describe('TxTypeFeeDelegatedSmartContractExecutionWithRatio', () => { const tx = caver.transaction.feeDelegatedSmartContractExecutionWithRatio.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedValueTransfer.js b/test/packages/caver.transaction/feeDelegatedValueTransfer.js index 91c53c83..241be73e 100644 --- a/test/packages/caver.transaction/feeDelegatedValueTransfer.js +++ b/test/packages/caver.transaction/feeDelegatedValueTransfer.js @@ -1216,8 +1216,8 @@ describe('TxTypeFeeDelegatedValueTransfer', () => { const tx = caver.transaction.feeDelegatedValueTransfer.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedValueTransferMemo.js b/test/packages/caver.transaction/feeDelegatedValueTransferMemo.js index 04841c21..98c81201 100644 --- a/test/packages/caver.transaction/feeDelegatedValueTransferMemo.js +++ b/test/packages/caver.transaction/feeDelegatedValueTransferMemo.js @@ -1224,8 +1224,8 @@ describe('TxTypeFeeDelegatedValueTransferMemo', () => { const tx = caver.transaction.feeDelegatedValueTransferMemo.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedValueTransferMemoWithRatio.js b/test/packages/caver.transaction/feeDelegatedValueTransferMemoWithRatio.js index b634c7d1..5bdf42c8 100644 --- a/test/packages/caver.transaction/feeDelegatedValueTransferMemoWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedValueTransferMemoWithRatio.js @@ -1258,8 +1258,8 @@ describe('TxTypeFeeDelegatedValueTransferMemoWithRatio', () => { const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/feeDelegatedValueTransferWithRatio.js b/test/packages/caver.transaction/feeDelegatedValueTransferWithRatio.js index 5ba4ab6e..b539cb58 100644 --- a/test/packages/caver.transaction/feeDelegatedValueTransferWithRatio.js +++ b/test/packages/caver.transaction/feeDelegatedValueTransferWithRatio.js @@ -1250,8 +1250,8 @@ describe('TxTypeFeeDelegatedValueTransferWithRatio', () => { const tx = caver.transaction.feeDelegatedValueTransferWithRatio.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/legacyTransaction.js b/test/packages/caver.transaction/legacyTransaction.js index c3b927fa..b1074cf8 100644 --- a/test/packages/caver.transaction/legacyTransaction.js +++ b/test/packages/caver.transaction/legacyTransaction.js @@ -777,8 +777,8 @@ describe('TxTypeLegacyTransaction', () => { const tx = caver.transaction.legacyTransaction.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/smartContractDeploy.js b/test/packages/caver.transaction/smartContractDeploy.js index ddff73e1..96233495 100644 --- a/test/packages/caver.transaction/smartContractDeploy.js +++ b/test/packages/caver.transaction/smartContractDeploy.js @@ -740,8 +740,8 @@ describe('TxTypeSmartContractDeploy', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/smartContractExecution.js b/test/packages/caver.transaction/smartContractExecution.js index 0a99cb8e..57287758 100644 --- a/test/packages/caver.transaction/smartContractExecution.js +++ b/test/packages/caver.transaction/smartContractExecution.js @@ -743,8 +743,8 @@ describe('TxTypeSmartContractExecution', () => { delete tx._gasPrice await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/valueTransfer.js b/test/packages/caver.transaction/valueTransfer.js index fa25b8b8..e97736e4 100644 --- a/test/packages/caver.transaction/valueTransfer.js +++ b/test/packages/caver.transaction/valueTransfer.js @@ -743,8 +743,8 @@ describe('TxTypeValueTransfer', () => { const tx = caver.transaction.valueTransfer.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) diff --git a/test/packages/caver.transaction/valueTransferMemo.js b/test/packages/caver.transaction/valueTransferMemo.js index 5044bdaa..23d5aeac 100644 --- a/test/packages/caver.transaction/valueTransferMemo.js +++ b/test/packages/caver.transaction/valueTransferMemo.js @@ -753,8 +753,8 @@ describe('TxTypeValueTransferMemo', () => { const tx = caver.transaction.valueTransferMemo.create(transactionObj) await tx.fillTransaction() - expect(getGasPriceSpy).not.to.have.been.calledOnce - expect(getHeaderSpy).to.have.been.calledOnce + expect(getGasPriceSpy).to.have.been.calledOnce + expect(getHeaderSpy).not.to.have.been.calledOnce expect(getNonceSpy).not.to.have.been.calledOnce expect(getChainIdSpy).not.to.have.been.calledOnce }).timeout(200000) From 3830c51ed23a8518f25875b6a705adfd8c231576 Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 19 Jul 2022 13:39:51 +0900 Subject: [PATCH 41/42] Use klay_gasPrice in method and accounts packages --- packages/caver-core-method/src/index.js | 58 ++++++------------- .../caver-klay-accounts/src/index.js | 8 --- 2 files changed, 17 insertions(+), 49 deletions(-) diff --git a/packages/caver-core-method/src/index.js b/packages/caver-core-method/src/index.js index 175ec39c..60b129eb 100644 --- a/packages/caver-core-method/src/index.js +++ b/packages/caver-core-method/src/index.js @@ -478,12 +478,6 @@ const buildSendFunc = (method, isSendTx) => (...args) => { } // gasPrice is missing, have to fill gasPrice field before sending tx - const getHeader = new Method({ - name: 'getHeader', - call: 'klay_getHeaderByNumber', - params: 1, - }).createFunction(method.requestManager) - const getGasPrice = new Method({ name: 'getGasPrice', call: 'klay_gasPrice', @@ -496,42 +490,24 @@ const buildSendFunc = (method, isSendTx) => (...args) => { params: 0, }).createFunction(method.requestManager) - getHeader('latest', (err, header) => { - // Get baseFee(`baseFeePerGas`) from block header - const baseFee = utils.hexToNumber(header.baseFeePerGas || '0x0') - - // The baseFeePerGas is bigger than 0 means that Klaytn uses dynamic gas price. - if (baseFee > 0) { - if (!isDynamicFeeTx) { - payload.params[0].gasPrice = baseFee * 2 - } else { - // If maxFeePerGas is undefined, set maxFeePerGas with `baseFee * 2`. - payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || baseFee * 2 - // If maxPriorityFeePerGas is undefined, call `klay_maxPriorityFeePerGas`. - if (payload.params[0].maxPriorityFeePerGas === undefined) { - return getMaxPriorityFeePerGas((e, maxPriorityFeePerGas) => { - payload.params[0].maxPriorityFeePerGas = maxPriorityFeePerGas - // Format gas price parameters(gasPrice, maxPriorityFeePerGas, maxFeePerGas) - formatGasParametersToHex(payload.params[0]) - sendRequest(payload, method) - }) - } - } + // `klay_gasPrice` returns a suggestion of gas price. + // So using this value in gasPrice field (or maxFeePerGas). + getGasPrice((e, gp) => { + // The TxTypeEthereumDynamicFee transaction does not use the gasPrice field, + // so the gas price default is not set for TxTypeEthereumDynamicFee. + if (!isDynamicFeeTx) { + payload.params[0].gasPrice = payload.params[0].gasPrice || gp } else { - // If baseFeePerGas is not defined or 0, we need to use unit price for the `gasPrice` field. - return getGasPrice((e, gp) => { - // The TxTypeEthereumDynamicFee transaction does not use the gasPrice field, - // so the gas price default is not set for TxTypeEthereumDynamicFee. - if (!isDynamicFeeTx) { - payload.params[0].gasPrice = payload.params[0].gasPrice || gp - } else { - payload.params[0].maxPriorityFeePerGas = payload.params[0].maxPriorityFeePerGas || gp - payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || gp - } - // Format gas price parameters(gasPrice, maxPriorityFeePerGas, maxFeePerGas) - formatGasParametersToHex(payload.params[0]) - sendRequest(payload, method) - }) + payload.params[0].maxFeePerGas = payload.params[0].maxFeePerGas || gp + // If maxPriorityFeePerGas is undefined, call `klay_maxPriorityFeePerGas`. + if (payload.params[0].maxPriorityFeePerGas === undefined) { + return getMaxPriorityFeePerGas((e, maxPriorityFeePerGas) => { + payload.params[0].maxPriorityFeePerGas = maxPriorityFeePerGas + // Format gas price parameters(gasPrice, maxPriorityFeePerGas, maxFeePerGas) + formatGasParametersToHex(payload.params[0]) + sendRequest(payload, method) + }) + } } // Format gas price parameters(gasPrice, maxPriorityFeePerGas, maxFeePerGas) formatGasParametersToHex(payload.params[0]) diff --git a/packages/caver-klay/caver-klay-accounts/src/index.js b/packages/caver-klay/caver-klay-accounts/src/index.js index 8a17a7dc..75ff1cfa 100644 --- a/packages/caver-klay/caver-klay-accounts/src/index.js +++ b/packages/caver-klay/caver-klay-accounts/src/index.js @@ -402,14 +402,6 @@ Accounts.prototype._getRoleKey = function _getRoleKey(tx, account) { * @return {string} */ Accounts.prototype._suggestGasPrice = async function _suggestGasPrice() { - const header = await this._klaytnCall.getHeader('latest') - const bf = utils.hexToNumber(header.baseFeePerGas || '0x0') - - // In before common architecture, ethereum typed transactions are not supported. - // So just depends on baseFeePerGas field in the header, - // return `baseFee * 2` or `gasPrice`. - if (bf > 0) return bf * 2 - const gasPrice = await this._klaytnCall.getGasPrice() return gasPrice } From b0138175b0514fa4b00dac7d005ffc4d2b5d56b1 Mon Sep 17 00:00:00 2001 From: Jamie Date: Tue, 19 Jul 2022 13:45:14 +0900 Subject: [PATCH 42/42] Fixed lint error --- packages/caver-core-method/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/caver-core-method/src/index.js b/packages/caver-core-method/src/index.js index 60b129eb..f9521900 100644 --- a/packages/caver-core-method/src/index.js +++ b/packages/caver-core-method/src/index.js @@ -492,7 +492,7 @@ const buildSendFunc = (method, isSendTx) => (...args) => { // `klay_gasPrice` returns a suggestion of gas price. // So using this value in gasPrice field (or maxFeePerGas). - getGasPrice((e, gp) => { + getGasPrice((err, gp) => { // The TxTypeEthereumDynamicFee transaction does not use the gasPrice field, // so the gas price default is not set for TxTypeEthereumDynamicFee. if (!isDynamicFeeTx) {