caver-js
Version:
caver-js is a JavaScript API library that allows developers to interact with a Kaia node
1,020 lines (825 loc) • 63.9 kB
JavaScript
/*
Copyright 2020 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 <http://www.gnu.org/licenses/>.
*/
const chai = require('chai')
const sinon = require('sinon')
const sinonChai = require('sinon-chai')
const chaiAsPromised = require('chai-as-promised')
const RLP = require('eth-lib/lib/rlp')
chai.use(chaiAsPromised)
chai.use(sinonChai)
const expect = chai.expect
const { propertiesForUnnecessary } = require('../utils')
const testRPCURL = require('../../testrpc')
const Caver = require('../../../index')
const Keyring = require('../../../packages/caver-wallet/src/keyring/keyringFactory')
const SingleKeyring = require('../../../packages/caver-wallet/src/keyring/singleKeyring')
const TransactionHasher = require('../../../packages/caver-transaction/src/transactionHasher/transactionHasher')
const { generateRoleBasedKeyring, checkSignature, checkFeePayerSignature } = require('../utils')
let caver
let sender
let roleBasedKeyring
const txWithExpectedValues = {}
const sandbox = sinon.createSandbox()
before(() => {
caver = new Caver(testRPCURL)
sender = caver.wallet.add(caver.wallet.keyring.generate())
roleBasedKeyring = generateRoleBasedKeyring([3, 3, 3])
txWithExpectedValues.tx = {
from: '0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B',
gas: '0xf4240',
gasPrice: '0x19',
chainId: '0x1',
nonce: 1234,
signatures: [
[
'0x26',
'0x8409f5441d4725f90905ad87f03793857d124de7a43169bc67320cd2f020efa9',
'0x60af63e87bdc565d7f7de906916b2334336ee7b24d9a71c9521a67df02e7ec92',
],
],
feePayer: '0x5A0043070275d9f6054307Ee7348bD660849D90f',
feePayerSignatures: [
[
'0x26',
'0x44d5b25e8c649a1fdaa409dc3817be390ad90a17c25bc17c89b6d5d248495e0',
'0x73938e690d27b5267c73108352cf12d01de7fd0077b388e94721aa1fa32f85ec',
],
],
}
txWithExpectedValues.rlpEncodingForSigning = '0xe39fde398204d219830f424094a94f5374fce5edbc8e2a8697c15331677e6ebf0b018080'
txWithExpectedValues.rlpEncodingForFeePayerSigning =
'0xf8389fde398204d219830f424094a94f5374fce5edbc8e2a8697c15331677e6ebf0b945a0043070275d9f6054307ee7348bd660849d90f018080'
txWithExpectedValues.senderTxHash = '0xcc6c2673398903b3d906a3023b41636fc08bd1bddd5aa1602116091638f48447'
txWithExpectedValues.transactionHash = '0x96b39d3ab849127d31a5f7b5c882ca9ba408cd9d875052640d51a64f8c4acbb2'
txWithExpectedValues.rlpEncoding =
'0x39f8c08204d219830f424094a94f5374fce5edbc8e2a8697c15331677e6ebf0bf845f84326a08409f5441d4725f90905ad87f03793857d124de7a43169bc67320cd2f020efa9a060af63e87bdc565d7f7de906916b2334336ee7b24d9a71c9521a67df02e7ec92945a0043070275d9f6054307ee7348bd660849d90ff845f84326a0044d5b25e8c649a1fdaa409dc3817be390ad90a17c25bc17c89b6d5d248495e0a073938e690d27b5267c73108352cf12d01de7fd0077b388e94721aa1fa32f85ec'
})
describe('TxTypeFeeDelegatedCancel', () => {
let transactionObj
let getGasPriceSpy
let getHeaderSpy
let getNonceSpy
let getChainIdSpy
beforeEach(() => {
transactionObj = {
from: sender.address,
gas: '0x15f90',
nonce: '0x6',
}
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')
getChainIdSpy.returns('0x7e3')
})
afterEach(() => {
sandbox.restore()
})
context('create feeDelegatedCancel instance', () => {
it('CAVERJS-UNIT-TRANSACTIONFD-371: If feeDelegatedCancel not define from, return error', () => {
delete transactionObj.from
const expectedError = '"from" is missing'
expect(() => caver.transaction.feeDelegatedCancel.create(transactionObj)).to.throw(expectedError)
})
it('CAVERJS-UNIT-TRANSACTIONFD-372: If feeDelegatedCancel not define gas, return error', () => {
delete transactionObj.gas
const expectedError = '"gas" is missing'
expect(() => caver.transaction.feeDelegatedCancel.create(transactionObj)).to.throw(expectedError)
})
it('CAVERJS-UNIT-TRANSACTIONFD-373: If feeDelegatedCancel define from property with invalid address, return error', () => {
transactionObj.from = 'invalid'
const expectedError = `Invalid address of from: ${transactionObj.from}`
expect(() => caver.transaction.feeDelegatedCancel.create(transactionObj)).to.throw(expectedError)
})
it('CAVERJS-UNIT-TRANSACTIONFD-374: If feeDelegatedCancel define feePayer property with invalid address, return error', () => {
transactionObj.feePayer = 'invalid'
const expectedError = `Invalid address of fee payer: ${transactionObj.feePayer}`
expect(() => caver.transaction.feeDelegatedCancel.create(transactionObj)).to.throw(expectedError)
})
it('CAVERJS-UNIT-TRANSACTIONFD-375: If feeDelegatedCancel define feePayerSignatures property without feePayer, return error', () => {
transactionObj.feePayerSignatures = [
[
'0x26',
'0xf45cf8d7f88c08e6b6ec0b3b562f34ca94283e4689021987abb6b0772ddfd80a',
'0x298fe2c5aeabb6a518f4cbb5ff39631a5d88be505d3923374f65fdcf63c2955b',
],
]
const expectedError = '"feePayer" is missing: feePayer must be defined with feePayerSignatures.'
expect(() => caver.transaction.feeDelegatedCancel.create(transactionObj)).to.throw(expectedError)
})
it('CAVERJS-UNIT-TRANSACTIONFD-376: If feeDelegatedCancel define unnecessary property, return error', () => {
const unnecessaries = [
propertiesForUnnecessary.to,
propertiesForUnnecessary.value,
propertiesForUnnecessary.input,
propertiesForUnnecessary.codeFormat,
propertiesForUnnecessary.humanReadable,
propertiesForUnnecessary.failKey,
propertiesForUnnecessary.feeRatio,
propertiesForUnnecessary.account,
propertiesForUnnecessary.key,
propertiesForUnnecessary.legacyKey,
propertiesForUnnecessary.publicKey,
propertiesForUnnecessary.failKey,
propertiesForUnnecessary.multisig,
propertiesForUnnecessary.roleTransactionKey,
propertiesForUnnecessary.roleAccountUpdateKey,
propertiesForUnnecessary.roleFeePayerKey,
propertiesForUnnecessary.accessList,
propertiesForUnnecessary.maxPriorityFeePerGas,
propertiesForUnnecessary.maxFeePerGas,
]
for (let i = 0; i < unnecessaries.length; i++) {
if (i > 0) delete transactionObj[unnecessaries[i - 1].name]
transactionObj[unnecessaries[i].name] = unnecessaries[i].value
const expectedError = `"${unnecessaries[i].name}" cannot be used with ${caver.transaction.type.TxTypeFeeDelegatedCancel} transaction`
expect(() => caver.transaction.feeDelegatedCancel.create(transactionObj)).to.throw(expectedError)
}
})
})
context('feeDelegatedCancel.getRLPEncoding', () => {
it('CAVERJS-UNIT-TRANSACTIONFD-377: Returns RLP-encoded string', () => {
const tx = caver.transaction.feeDelegatedCancel.create(txWithExpectedValues.tx)
expect(tx.getRLPEncoding()).to.equal(txWithExpectedValues.rlpEncoding)
})
it('CAVERJS-UNIT-TRANSACTIONFD-378: getRLPEncoding should throw error when nonce is undefined', () => {
const tx = caver.transaction.feeDelegatedCancel.create(txWithExpectedValues.tx)
delete tx._nonce
const expectedError = `nonce is undefined. Define nonce in transaction or use 'transaction.fillTransaction' to fill values.`
expect(() => tx.getRLPEncoding()).to.throw(expectedError)
})
it('CAVERJS-UNIT-TRANSACTIONFD-379: getRLPEncoding should throw error when gasPrice is undefined', () => {
const tx = caver.transaction.feeDelegatedCancel.create(txWithExpectedValues.tx)
delete tx._gasPrice
const expectedError = `gasPrice is undefined. Define gasPrice in transaction or use 'transaction.fillTransaction' to fill values.`
expect(() => tx.getRLPEncoding()).to.throw(expectedError)
})
})
context('feeDelegatedCancel.sign', () => {
const txHash = '0xe9a11d9ef95fb437f75d07ce768d43e74f158dd54b106e7d3746ce29d545b550'
let fillTransactionSpy
let createFromPrivateKeySpy
let senderSignSpy
let appendSignaturesSpy
let hasherSpy
let tx
beforeEach(() => {
tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
fillTransactionSpy = sandbox.spy(tx, 'fillTransaction')
createFromPrivateKeySpy = sandbox.spy(Keyring, 'createFromPrivateKey')
senderSignSpy = sandbox.spy(sender, 'sign')
appendSignaturesSpy = sandbox.spy(tx, 'appendSignatures')
hasherSpy = sandbox.stub(TransactionHasher, 'getHashForSignature')
hasherSpy.returns(txHash)
})
afterEach(() => {
sandbox.restore()
})
function checkFunctionCall(customHasher = false) {
expect(fillTransactionSpy).to.have.been.calledOnce
expect(appendSignaturesSpy).to.have.been.calledOnce
if (!customHasher) expect(hasherSpy).to.have.been.calledWith(tx)
}
it('CAVERJS-UNIT-TRANSACTIONFD-381: input: keyring. should sign transaction.', async () => {
await tx.sign(sender)
checkFunctionCall()
checkSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(senderSignSpy).to.have.been.calledWith(txHash, '0x7e3', 0, undefined)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-382: input: private key string. should sign transaction.', async () => {
const signProtoSpy = sandbox.spy(SingleKeyring.prototype, 'sign')
await tx.sign(sender.key.privateKey)
checkFunctionCall()
checkSignature(tx)
expect(createFromPrivateKeySpy).to.have.been.calledOnce
expect(signProtoSpy).to.have.been.calledWith(txHash, '0x7e3', 0, undefined)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-383: input: KlaytnWalletKey. should sign transaction.', async () => {
const signProtoSpy = sandbox.spy(SingleKeyring.prototype, 'sign')
await tx.sign(sender.getKlaytnWalletKey())
checkFunctionCall()
checkSignature(tx)
expect(createFromPrivateKeySpy).to.have.been.calledOnce
expect(signProtoSpy).to.have.been.calledWith(txHash, '0x7e3', 0, undefined)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-384: input: keyring, index. should sign transaction with specific index.', async () => {
const roleBasedSignSpy = sandbox.spy(roleBasedKeyring, 'sign')
tx.from = roleBasedKeyring.address
await tx.sign(roleBasedKeyring, 1)
checkFunctionCall()
checkSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(roleBasedSignSpy).to.have.been.calledWith(txHash, '0x7e3', 0, 1)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-385: input: keyring, custom hasher. should use custom hasher.', async () => {
const hashForCustomHasher = '0x9e4b4835f6ea5ce55bd1037fe92040dd070af6154aefc30d32c65364a1123cae'
const customHasher = () => hashForCustomHasher
await tx.sign(sender, customHasher)
checkFunctionCall(true)
checkSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(senderSignSpy).to.have.been.calledWith(hashForCustomHasher, '0x7e3', 0, undefined)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-386: input: keyring, index, custom hasher. should use custom hasher when sign transaction.', async () => {
const hashForCustomHasher = '0x9e4b4835f6ea5ce55bd1037fe92040dd070af6154aefc30d32c65364a1123cae'
const customHasher = () => hashForCustomHasher
const roleBasedSignSpy = sandbox.spy(roleBasedKeyring, 'sign')
tx.from = roleBasedKeyring.address
await tx.sign(roleBasedKeyring, 1, customHasher)
checkFunctionCall(true)
checkSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(roleBasedSignSpy).to.have.been.calledWith(hashForCustomHasher, '0x7e3', 0, 1)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-387: input: keyring. should throw error when from is different.', async () => {
transactionObj.from = roleBasedKeyring.address
tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const expectedError = `The from address of the transaction is different with the address of the keyring to use.`
await expect(tx.sign(sender)).to.be.rejectedWith(expectedError)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-388: input: rolebased keyring, index out of range. should throw error.', async () => {
transactionObj.from = roleBasedKeyring.address
tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const expectedError = `Invalid index(10): index must be less than the length of keys(${roleBasedKeyring.keys[0].length}).`
await expect(tx.sign(roleBasedKeyring, 10)).to.be.rejectedWith(expectedError)
}).timeout(200000)
})
context('feeDelegatedCancel.signAsFeePayer', () => {
const txHash = '0xe9a11d9ef95fb437f75d07ce768d43e74f158dd54b106e7d3746ce29d545b550'
let fillTransactionSpy
let createFromPrivateKeySpy
let senderSignSpy
let appendSignaturesSpy
let hasherSpy
let tx
beforeEach(() => {
tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
tx.feePayer = sender.address
fillTransactionSpy = sandbox.spy(tx, 'fillTransaction')
createFromPrivateKeySpy = sandbox.spy(Keyring, 'createFromPrivateKey')
senderSignSpy = sandbox.spy(sender, 'sign')
appendSignaturesSpy = sandbox.spy(tx, 'appendFeePayerSignatures')
hasherSpy = sandbox.stub(TransactionHasher, 'getHashForFeePayerSignature')
hasherSpy.returns(txHash)
})
afterEach(() => {
sandbox.restore()
})
function checkFunctionCall(customHasher = false) {
expect(fillTransactionSpy).to.have.been.calledOnce
expect(appendSignaturesSpy).to.have.been.calledOnce
if (!customHasher) expect(hasherSpy).to.have.been.calledWith(tx)
}
it('CAVERJS-UNIT-TRANSACTIONFD-389: input: keyring. If feePayer is not defined, should be set with keyring address.', async () => {
tx.feePayer = '0x'
await tx.signAsFeePayer(sender)
expect(tx.feePayer.toLowerCase()).to.equal(sender.address.toLowerCase())
checkFunctionCall()
checkFeePayerSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(senderSignSpy).to.have.been.calledWith(txHash, '0x7e3', 2, undefined)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-390: input: keyring. should sign transaction.', async () => {
await tx.signAsFeePayer(sender)
checkFunctionCall()
checkFeePayerSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(senderSignSpy).to.have.been.calledWith(txHash, '0x7e3', 2, undefined)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-391: input: private key string. should sign transaction.', async () => {
const signProtoSpy = sandbox.spy(SingleKeyring.prototype, 'sign')
await tx.signAsFeePayer(sender.key.privateKey)
checkFunctionCall()
checkFeePayerSignature(tx)
expect(createFromPrivateKeySpy).to.have.been.calledOnce
expect(signProtoSpy).to.have.been.calledWith(txHash, '0x7e3', 2, undefined)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-392: input: KlaytnWalletKey. should sign transaction.', async () => {
const signProtoSpy = sandbox.spy(SingleKeyring.prototype, 'sign')
await tx.signAsFeePayer(sender.getKlaytnWalletKey())
checkFunctionCall()
checkFeePayerSignature(tx)
expect(createFromPrivateKeySpy).to.have.been.calledOnce
expect(signProtoSpy).to.have.been.calledWith(txHash, '0x7e3', 2, undefined)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-393: input: keyring, index. should sign transaction with specific index.', async () => {
const roleBasedSignSpy = sandbox.spy(roleBasedKeyring, 'sign')
tx.feePayer = roleBasedKeyring.address
await tx.signAsFeePayer(roleBasedKeyring, 1)
checkFunctionCall()
checkFeePayerSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(roleBasedSignSpy).to.have.been.calledWith(txHash, '0x7e3', 2, 1)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-394: input: keyring, custom hasher. should use custom hasher.', async () => {
const hashForCustomHasher = '0x9e4b4835f6ea5ce55bd1037fe92040dd070af6154aefc30d32c65364a1123cae'
const customHasher = () => hashForCustomHasher
const roleBasedSignSpy = sandbox.spy(roleBasedKeyring, 'sign')
tx.feePayer = roleBasedKeyring.address
await tx.signAsFeePayer(roleBasedKeyring, customHasher)
checkFunctionCall(true)
checkFeePayerSignature(tx, { expectedLength: roleBasedKeyring.keys[2].length })
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(roleBasedSignSpy).to.have.been.calledWith(hashForCustomHasher, '0x7e3', 2, undefined)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-395: input: keyring, index, custom hasher. should use custom hasher when sign transaction.', async () => {
const hashForCustomHasher = '0x9e4b4835f6ea5ce55bd1037fe92040dd070af6154aefc30d32c65364a1123cae'
const customHasher = () => hashForCustomHasher
const roleBasedSignSpy = sandbox.spy(roleBasedKeyring, 'sign')
tx.feePayer = roleBasedKeyring.address
await tx.signAsFeePayer(roleBasedKeyring, 1, customHasher)
checkFunctionCall(true)
checkFeePayerSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(roleBasedSignSpy).to.have.been.calledWith(hashForCustomHasher, '0x7e3', 2, 1)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-396: input: keyring. should throw error when feePayer is different.', async () => {
tx.feePayer = roleBasedKeyring.address
const expectedError = `The feePayer address of the transaction is different with the address of the keyring to use.`
await expect(tx.signAsFeePayer(sender)).to.be.rejectedWith(expectedError)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-397: input: rolebased keyring, index out of range. should throw error.', async () => {
transactionObj.from = roleBasedKeyring.address
tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const expectedError = `Invalid index(10): index must be less than the length of keys(${roleBasedKeyring.keys[0].length}).`
await expect(tx.signAsFeePayer(roleBasedKeyring, 10)).to.be.rejectedWith(expectedError)
}).timeout(200000)
})
context('feeDelegatedCancel.sign with multiple keys', () => {
const txHash = '0xe9a11d9ef95fb437f75d07ce768d43e74f158dd54b106e7d3746ce29d545b550'
let fillTransactionSpy
let createFromPrivateKeySpy
let senderSignWithKeysSpy
let appendSignaturesSpy
let hasherSpy
let tx
beforeEach(() => {
tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
fillTransactionSpy = sandbox.spy(tx, 'fillTransaction')
createFromPrivateKeySpy = sandbox.spy(Keyring, 'createFromPrivateKey')
senderSignWithKeysSpy = sandbox.spy(sender, 'sign')
appendSignaturesSpy = sandbox.spy(tx, 'appendSignatures')
hasherSpy = sandbox.stub(TransactionHasher, 'getHashForSignature')
hasherSpy.returns(txHash)
})
afterEach(() => {
sandbox.restore()
})
function checkFunctionCall(customHasher = false) {
expect(fillTransactionSpy).to.have.been.calledOnce
expect(appendSignaturesSpy).to.have.been.calledOnce
if (!customHasher) expect(hasherSpy).to.have.been.calledWith(tx)
}
it('CAVERJS-UNIT-TRANSACTIONFD-398: input: keyring. should sign transaction.', async () => {
await tx.sign(sender)
checkFunctionCall()
checkSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(senderSignWithKeysSpy).to.have.been.calledWith(txHash, '0x7e3', 0)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-399: input: private key string. should sign transaction.', async () => {
const signProtoSpy = sandbox.spy(SingleKeyring.prototype, 'sign')
await tx.sign(sender.key.privateKey)
checkFunctionCall()
checkSignature(tx)
expect(createFromPrivateKeySpy).to.have.been.calledOnce
expect(signProtoSpy).to.have.been.calledWith(txHash, '0x7e3', 0)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-400: input: KlaytnWalletKey. should sign transaction.', async () => {
const signProtoSpy = sandbox.spy(SingleKeyring.prototype, 'sign')
await tx.sign(sender.getKlaytnWalletKey())
checkFunctionCall()
checkSignature(tx)
expect(createFromPrivateKeySpy).to.have.been.calledOnce
expect(signProtoSpy).to.have.been.calledWith(txHash, '0x7e3', 0)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-401: input: keyring, custom hasher. should use custom hasher when sign transaction.', async () => {
const hashForCustomHasher = '0x9e4b4835f6ea5ce55bd1037fe92040dd070af6154aefc30d32c65364a1123cae'
const customHasher = () => hashForCustomHasher
await tx.sign(sender, customHasher)
checkFunctionCall(true)
checkSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(senderSignWithKeysSpy).to.have.been.calledWith(hashForCustomHasher, '0x7e3', 0)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-402: input: keyring. should throw error when from is different.', async () => {
transactionObj.from = roleBasedKeyring.address
tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const expectedError = `The from address of the transaction is different with the address of the keyring to use.`
await expect(tx.sign(sender)).to.be.rejectedWith(expectedError)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-403: input: roleBased keyring. should sign with multiple keys and append signatures', async () => {
const roleBasedSignWithKeysSpy = sandbox.spy(roleBasedKeyring, 'sign')
tx.from = roleBasedKeyring.address
await tx.sign(roleBasedKeyring)
checkFunctionCall(true)
checkSignature(tx, { expectedLength: roleBasedKeyring.keys[0].length })
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(roleBasedSignWithKeysSpy).to.have.been.calledWith(txHash, '0x7e3', 0)
}).timeout(200000)
})
context('feeDelegatedCancel.signAsFeePayer with multiple keys', () => {
const txHash = '0xe9a11d9ef95fb437f75d07ce768d43e74f158dd54b106e7d3746ce29d545b550'
let fillTransactionSpy
let createFromPrivateKeySpy
let senderSignWithKeysSpy
let appendSignaturesSpy
let hasherSpy
let tx
beforeEach(() => {
tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
fillTransactionSpy = sandbox.spy(tx, 'fillTransaction')
createFromPrivateKeySpy = sandbox.spy(Keyring, 'createFromPrivateKey')
senderSignWithKeysSpy = sandbox.spy(sender, 'sign')
appendSignaturesSpy = sandbox.spy(tx, 'appendFeePayerSignatures')
hasherSpy = sandbox.stub(TransactionHasher, 'getHashForFeePayerSignature')
hasherSpy.returns(txHash)
})
afterEach(() => {
sandbox.restore()
})
function checkFunctionCall(customHasher = false) {
expect(fillTransactionSpy).to.have.been.calledOnce
expect(appendSignaturesSpy).to.have.been.calledOnce
if (!customHasher) expect(hasherSpy).to.have.been.calledWith(tx)
}
it('CAVERJS-UNIT-TRANSACTIONFD-404: input: keyring. If feePayer is not defined, should be set with keyring address.', async () => {
tx.feePayer = '0x'
await tx.signAsFeePayer(sender)
checkFunctionCall()
checkFeePayerSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(senderSignWithKeysSpy).to.have.been.calledWith(txHash, '0x7e3', 2)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-405: input: keyring. should sign transaction.', async () => {
await tx.signAsFeePayer(sender)
checkFunctionCall()
checkFeePayerSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(senderSignWithKeysSpy).to.have.been.calledWith(txHash, '0x7e3', 2)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-406: input: private key string. should sign transaction.', async () => {
const signProtoSpy = sandbox.spy(SingleKeyring.prototype, 'sign')
await tx.signAsFeePayer(sender.key.privateKey)
checkFunctionCall()
checkFeePayerSignature(tx)
expect(createFromPrivateKeySpy).to.have.been.calledOnce
expect(signProtoSpy).to.have.been.calledWith(txHash, '0x7e3', 2)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-407: input: KlaytnWalletKey. should sign transaction.', async () => {
const signProtoSpy = sandbox.spy(SingleKeyring.prototype, 'sign')
await tx.signAsFeePayer(sender.getKlaytnWalletKey())
checkFunctionCall()
checkFeePayerSignature(tx)
expect(createFromPrivateKeySpy).to.have.been.calledOnce
expect(signProtoSpy).to.have.been.calledWith(txHash, '0x7e3', 2)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-408: input: keyring, custom hasher. should use custom hasher when sign transaction.', async () => {
const hashForCustomHasher = '0x9e4b4835f6ea5ce55bd1037fe92040dd070af6154aefc30d32c65364a1123cae'
const customHasher = () => hashForCustomHasher
await tx.signAsFeePayer(sender, customHasher)
checkFunctionCall(true)
checkFeePayerSignature(tx)
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(senderSignWithKeysSpy).to.have.been.calledWith(hashForCustomHasher, '0x7e3', 2)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-409: input: keyring. should throw error when feePayer is different.', async () => {
tx.feePayer = roleBasedKeyring.address
const expectedError = `The feePayer address of the transaction is different with the address of the keyring to use.`
await expect(tx.signAsFeePayer(sender)).to.be.rejectedWith(expectedError)
}).timeout(200000)
it('CAVERJS-UNIT-TRANSACTIONFD-410: input: roleBased keyring. should sign with multiple keys and append signatures', async () => {
const roleBasedSignWithKeysSpy = sandbox.spy(roleBasedKeyring, 'sign')
tx.feePayer = roleBasedKeyring.address
await tx.signAsFeePayer(roleBasedKeyring)
checkFunctionCall(true)
checkFeePayerSignature(tx, { expectedLength: roleBasedKeyring.keys[2].length })
expect(createFromPrivateKeySpy).not.to.have.been.calledOnce
expect(roleBasedSignWithKeysSpy).to.have.been.calledWith(txHash, '0x7e3', 2)
}).timeout(200000)
})
context('feeDelegatedCancel.appendSignatures', () => {
afterEach(() => {
sandbox.restore()
})
it('CAVERJS-UNIT-TRANSACTIONFD-411: If signatures is empty, appendSignatures append signatures in transaction', () => {
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const sig = [
'0x0fea',
'0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e',
'0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e',
]
tx.appendSignatures(sig)
checkSignature(tx)
})
it('CAVERJS-UNIT-TRANSACTIONFD-412: If signatures is empty, appendSignatures append signatures with two-dimensional signature array', () => {
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const sig = [
[
'0x0fea',
'0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e',
'0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e',
],
]
tx.appendSignatures(sig)
checkSignature(tx)
})
it('CAVERJS-UNIT-TRANSACTIONFD-413: If signatures is not empty, appendSignatures should append signatures', () => {
transactionObj.signatures = [
'0x0fea',
'0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e',
'0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e',
]
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const sig = [
'0x0fea',
'0x7a5011b41cfcb6270af1b5f8aeac8aeabb1edb436f028261b5add564de694700',
'0x23ac51660b8b421bf732ef8148d0d4f19d5e29cb97be6bccb5ae505ebe89eb4a',
]
tx.appendSignatures(sig)
checkSignature(tx, { expectedLength: 2 })
})
it('CAVERJS-UNIT-TRANSACTIONFD-414: appendSignatures should append multiple signatures', () => {
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const sig = [
[
'0x0fea',
'0xbde66cceed35a576010966338b7ded961f2c160c96f928e193b47aaf4480aa07',
'0x546eb193ec138523b7fd34c4f12a1a04d0f74470e8f3bbe91ce0b4ec16e7f0d2',
],
[
'0x0fea',
'0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e',
'0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e',
],
]
tx.appendSignatures(sig)
checkSignature(tx, { expectedLength: 2 })
})
})
context('feeDelegatedCancel.appendFeePayerSignatures', () => {
beforeEach(() => {
transactionObj.feePayer = '0x90b3e9a3770481345a7f17f22f16d020bccfd33e'
})
afterEach(() => {
sandbox.restore()
})
it('CAVERJS-UNIT-TRANSACTIONFD-415: If feePayerSignatures is empty, appendFeePayerSignatures append feePayerSignatures in transaction', () => {
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const sig = [
'0x0fea',
'0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e',
'0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e',
]
tx.appendFeePayerSignatures(sig)
checkFeePayerSignature(tx)
})
it('CAVERJS-UNIT-TRANSACTIONFD-416: If feePayerSignatures is empty, appendFeePayerSignatures append feePayerSignatures with two-dimensional signature array', () => {
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const sig = [
[
'0x0fea',
'0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e',
'0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e',
],
]
tx.appendFeePayerSignatures(sig)
checkFeePayerSignature(tx)
})
it('CAVERJS-UNIT-TRANSACTIONFD-417: If feePayerSignatures is not empty, appendFeePayerSignatures should append feePayerSignatures', () => {
transactionObj.feePayerSignatures = [
'0x0fea',
'0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e',
'0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e',
]
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const sig = [
'0x0fea',
'0x7a5011b41cfcb6270af1b5f8aeac8aeabb1edb436f028261b5add564de694700',
'0x23ac51660b8b421bf732ef8148d0d4f19d5e29cb97be6bccb5ae505ebe89eb4a',
]
tx.appendFeePayerSignatures(sig)
checkFeePayerSignature(tx, { expectedLength: 2 })
})
it('CAVERJS-UNIT-TRANSACTIONFD-418: appendFeePayerSignatures should append multiple feePayerSignatures', () => {
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const sig = [
[
'0x0fea',
'0xbde66cceed35a576010966338b7ded961f2c160c96f928e193b47aaf4480aa07',
'0x546eb193ec138523b7fd34c4f12a1a04d0f74470e8f3bbe91ce0b4ec16e7f0d2',
],
[
'0x0fea',
'0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e',
'0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e',
],
]
tx.appendFeePayerSignatures(sig)
checkFeePayerSignature(tx, { expectedLength: 2 })
})
})
context('feeDelegatedCancel.combineSignedRawTransactions', () => {
beforeEach(() => {
transactionObj = {
from: '0xdcad313f2bf2240dbdb243eaf5eee2f512e0bfd1',
gas: '0xdbba0',
nonce: '0x1',
gasPrice: '0x5d21dba00',
chainId: '0x7e3',
}
})
afterEach(() => {
sandbox.restore()
})
it('CAVERJS-UNIT-TRANSACTIONFD-419: combineSignedRawTransactions combines single signature and sets signatures in transaction', () => {
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const appendSignaturesSpy = sandbox.spy(tx, 'appendSignatures')
const getRLPEncodingSpy = sandbox.spy(tx, 'getRLPEncoding')
const rlpEncoded =
'0x39f883018505d21dba00830dbba094dcad313f2bf2240dbdb243eaf5eee2f512e0bfd1f847f845820fe9a04d9bf7a8bd15a41143eeecd3c39691cdc151b50d641534f0c73055849f7abca1a07123185b4cc046eb6a78e1ee370c059dfe437012098ebe18379685acd907606f940000000000000000000000000000000000000000c4c3018080'
const combined = tx.combineSignedRawTransactions([rlpEncoded])
const expectedSignatures = [
[
'0x0fe9',
'0x4d9bf7a8bd15a41143eeecd3c39691cdc151b50d641534f0c73055849f7abca1',
'0x7123185b4cc046eb6a78e1ee370c059dfe437012098ebe18379685acd907606f',
],
]
expect(appendSignaturesSpy).to.have.been.calledOnce
expect(getRLPEncodingSpy).to.have.been.calledOnce
expect(combined).to.equal(rlpEncoded)
checkSignature(tx, { expectedSignatures })
})
it('CAVERJS-UNIT-TRANSACTIONFD-420: combineSignedRawTransactions combines multiple signatures and sets signatures in transaction', () => {
transactionObj.signatures = [
[
'0x0fe9',
'0x4d9bf7a8bd15a41143eeecd3c39691cdc151b50d641534f0c73055849f7abca1',
'0x7123185b4cc046eb6a78e1ee370c059dfe437012098ebe18379685acd907606f',
],
]
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const rlpEncodedStrings = [
'0x39f86f018505d21dba00830dbba094dcad313f2bf2240dbdb243eaf5eee2f512e0bfd1f847f845820fe9a0205d4f6f758629da5eb25d1d572e82430243e00096ed64097b6d0031847bf792a0280ce8a79438c699fce0417403e8892e46e10da764b16876091ef0965c1ce1df80c4c3018080',
'0x39f86f018505d21dba00830dbba094dcad313f2bf2240dbdb243eaf5eee2f512e0bfd1f847f845820feaa02f3c7b7aebd6c9af7a5b4259f0ea77d96362efbdca397b9f17e3c6924296c53fa00e4197ba6e38cecf99715f523c1805a58559072f944443bad1152dee73bfb16780c4c3018080',
]
const appendSignaturesSpy = sandbox.spy(tx, 'appendSignatures')
const getRLPEncodingSpy = sandbox.spy(tx, 'getRLPEncoding')
const combined = tx.combineSignedRawTransactions(rlpEncodedStrings)
const expectedRLPEncoded =
'0x39f90111018505d21dba00830dbba094dcad313f2bf2240dbdb243eaf5eee2f512e0bfd1f8d5f845820fe9a04d9bf7a8bd15a41143eeecd3c39691cdc151b50d641534f0c73055849f7abca1a07123185b4cc046eb6a78e1ee370c059dfe437012098ebe18379685acd907606ff845820fe9a0205d4f6f758629da5eb25d1d572e82430243e00096ed64097b6d0031847bf792a0280ce8a79438c699fce0417403e8892e46e10da764b16876091ef0965c1ce1dff845820feaa02f3c7b7aebd6c9af7a5b4259f0ea77d96362efbdca397b9f17e3c6924296c53fa00e4197ba6e38cecf99715f523c1805a58559072f944443bad1152dee73bfb167940000000000000000000000000000000000000000c4c3018080'
const expectedSignatures = [
[
'0x0fe9',
'0x4d9bf7a8bd15a41143eeecd3c39691cdc151b50d641534f0c73055849f7abca1',
'0x7123185b4cc046eb6a78e1ee370c059dfe437012098ebe18379685acd907606f',
],
[
'0x0fe9',
'0x205d4f6f758629da5eb25d1d572e82430243e00096ed64097b6d0031847bf792',
'0x280ce8a79438c699fce0417403e8892e46e10da764b16876091ef0965c1ce1df',
],
[
'0x0fea',
'0x2f3c7b7aebd6c9af7a5b4259f0ea77d96362efbdca397b9f17e3c6924296c53f',
'0x0e4197ba6e38cecf99715f523c1805a58559072f944443bad1152dee73bfb167',
],
]
expect(appendSignaturesSpy).to.have.been.callCount(rlpEncodedStrings.length)
expect(getRLPEncodingSpy).to.have.been.calledOnce
expect(combined).to.equal(expectedRLPEncoded)
checkSignature(tx, { expectedSignatures })
})
it('CAVERJS-UNIT-TRANSACTIONFD-421: combineSignedRawTransactions combines single feePayerSignature and sets feePayerSignatures in transaction', () => {
transactionObj.feePayer = '0x6f89ec285c52a3e092cdb017e125a9b197e78dc7'
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const appendSignaturesSpy = sandbox.spy(tx, 'appendFeePayerSignatures')
const getRLPEncodingSpy = sandbox.spy(tx, 'getRLPEncoding')
const rlpEncoded =
'0x39f883018505d21dba00830dbba094dcad313f2bf2240dbdb243eaf5eee2f512e0bfd1c4c3018080946f89ec285c52a3e092cdb017e125a9b197e78dc7f847f845820fe9a0a4ca740e08115db092a79ce902bdac45347a3d34a74ea0fcc371ccf01269ca43a029e095bf3f9e0be7e2130fe6985419114958877412b46b5b4243cc39380c5028'
const combined = tx.combineSignedRawTransactions([rlpEncoded])
const expectedSignatures = [
[
'0x0fe9',
'0xa4ca740e08115db092a79ce902bdac45347a3d34a74ea0fcc371ccf01269ca43',
'0x29e095bf3f9e0be7e2130fe6985419114958877412b46b5b4243cc39380c5028',
],
]
expect(appendSignaturesSpy).to.have.been.calledOnce
expect(getRLPEncodingSpy).to.have.been.calledOnce
expect(combined).to.equal(rlpEncoded)
checkFeePayerSignature(tx, { expectedSignatures })
})
it('CAVERJS-UNIT-TRANSACTIONFD-422: combineSignedRawTransactions combines multiple feePayerSignatures and sets feePayerSignatures in transaction', () => {
transactionObj.feePayer = '0x6f89ec285c52a3e092cdb017e125a9b197e78dc7'
transactionObj.feePayerSignatures = [
[
'0x0fe9',
'0xa4ca740e08115db092a79ce902bdac45347a3d34a74ea0fcc371ccf01269ca43',
'0x29e095bf3f9e0be7e2130fe6985419114958877412b46b5b4243cc39380c5028',
],
]
const tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const rlpEncodedStrings = [
'0x39f883018505d21dba00830dbba094dcad313f2bf2240dbdb243eaf5eee2f512e0bfd1c4c3018080946f89ec285c52a3e092cdb017e125a9b197e78dc7f847f845820feaa09c86edd1b5d75ac1050a5a7494dece5f186b8e9654f75cf4942f7dca57fc2de0a032f306028776389107c40f1765679b2630f093b1c4f4fda9415f0c909c7addef',
'0x39f883018505d21dba00830dbba094dcad313f2bf2240dbdb243eaf5eee2f512e0bfd1c4c3018080946f89ec285c52a3e092cdb017e125a9b197e78dc7f847f845820fe9a0392e7a5d2efbc7da9d114ce79797eebbe2007ece065109f7f93baed1e23bb22ca022e161a9f20c14b5830154e819cdaf59e8d82690b318afb19e2903b52020bb3e',
]
const appendSignaturesSpy = sandbox.spy(tx, 'appendFeePayerSignatures')
const getRLPEncodingSpy = sandbox.spy(tx, 'getRLPEncoding')
const combined = tx.combineSignedRawTransactions(rlpEncodedStrings)
const expectedRLPEncoded =
'0x39f90111018505d21dba00830dbba094dcad313f2bf2240dbdb243eaf5eee2f512e0bfd1c4c3018080946f89ec285c52a3e092cdb017e125a9b197e78dc7f8d5f845820fe9a0a4ca740e08115db092a79ce902bdac45347a3d34a74ea0fcc371ccf01269ca43a029e095bf3f9e0be7e2130fe6985419114958877412b46b5b4243cc39380c5028f845820feaa09c86edd1b5d75ac1050a5a7494dece5f186b8e9654f75cf4942f7dca57fc2de0a032f306028776389107c40f1765679b2630f093b1c4f4fda9415f0c909c7addeff845820fe9a0392e7a5d2efbc7da9d114ce79797eebbe2007ece065109f7f93baed1e23bb22ca022e161a9f20c14b5830154e819cdaf59e8d82690b318afb19e2903b52020bb3e'
const expectedFeePayerSignatures = [
[
'0x0fe9',
'0xa4ca740e08115db092a79ce902bdac45347a3d34a74ea0fcc371ccf01269ca43',
'0x29e095bf3f9e0be7e2130fe6985419114958877412b46b5b4243cc39380c5028',
],
[
'0x0fea',
'0x9c86edd1b5d75ac1050a5a7494dece5f186b8e9654f75cf4942f7dca57fc2de0',
'0x32f306028776389107c40f1765679b2630f093b1c4f4fda9415f0c909c7addef',
],
[
'0x0fe9',
'0x392e7a5d2efbc7da9d114ce79797eebbe2007ece065109f7f93baed1e23bb22c',
'0x22e161a9f20c14b5830154e819cdaf59e8d82690b318afb19e2903b52020bb3e',
],
]
expect(appendSignaturesSpy).to.have.been.callCount(rlpEncodedStrings.length)
expect(getRLPEncodingSpy).to.have.been.calledOnce
expect(combined).to.equal(expectedRLPEncoded)
checkFeePayerSignature(tx, { expectedFeePayerSignatures })
})
it('CAVERJS-UNIT-TRANSACTIONFD-423: combineSignedRawTransactions combines multiple signatures and feePayerSignatures', () => {
let tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
// RLP encoding with only signatures
const rlpEncodedStrings = [
'0x39f8fd018505d21dba00830dbba094dcad313f2bf2240dbdb243eaf5eee2f512e0bfd1f8d5f845820fe9a04d9bf7a8bd15a41143eeecd3c39691cdc151b50d641534f0c73055849f7abca1a07123185b4cc046eb6a78e1ee370c059dfe437012098ebe18379685acd907606ff845820fe9a0205d4f6f758629da5eb25d1d572e82430243e00096ed64097b6d0031847bf792a0280ce8a79438c699fce0417403e8892e46e10da764b16876091ef0965c1ce1dff845820feaa02f3c7b7aebd6c9af7a5b4259f0ea77d96362efbdca397b9f17e3c6924296c53fa00e4197ba6e38cecf99715f523c1805a58559072f944443bad1152dee73bfb16780c4c3018080',
]
const expectedSignatures = [
[
'0x0fe9',
'0x4d9bf7a8bd15a41143eeecd3c39691cdc151b50d641534f0c73055849f7abca1',
'0x7123185b4cc046eb6a78e1ee370c059dfe437012098ebe18379685acd907606f',
],
[
'0x0fe9',
'0x205d4f6f758629da5eb25d1d572e82430243e00096ed64097b6d0031847bf792',
'0x280ce8a79438c699fce0417403e8892e46e10da764b16876091ef0965c1ce1df',
],
[
'0x0fea',
'0x2f3c7b7aebd6c9af7a5b4259f0ea77d96362efbdca397b9f17e3c6924296c53f',
'0x0e4197ba6e38cecf99715f523c1805a58559072f944443bad1152dee73bfb167',
],
]
const appendSignaturesSpy = sandbox.spy(tx, 'appendSignatures')
let combined = tx.combineSignedRawTransactions(rlpEncodedStrings)
expect(appendSignaturesSpy).to.have.been.callCount(rlpEncodedStrings.length)
const rlpEncodedStringsWithFeePayerSignatures = [
'0x39f90111018505d21dba00830dbba094dcad313f2bf2240dbdb243eaf5eee2f512e0bfd1c4c3018080946f89ec285c52a3e092cdb017e125a9b197e78dc7f8d5f845820fe9a0a4ca740e08115db092a79ce902bdac45347a3d34a74ea0fcc371ccf01269ca43a029e095bf3f9e0be7e2130fe6985419114958877412b46b5b4243cc39380c5028f845820feaa09c86edd1b5d75ac1050a5a7494dece5f186b8e9654f75cf4942f7dca57fc2de0a032f306028776389107c40f1765679b2630f093b1c4f4fda9415f0c909c7addeff845820fe9a0392e7a5d2efbc7da9d114ce79797eebbe2007ece065109f7f93baed1e23bb22ca022e161a9f20c14b5830154e819cdaf59e8d82690b318afb19e2903b52020bb3e',
]
const expectedFeePayerSignatures = [
[
'0x0fe9',
'0xa4ca740e08115db092a79ce902bdac45347a3d34a74ea0fcc371ccf01269ca43',
'0x29e095bf3f9e0be7e2130fe6985419114958877412b46b5b4243cc39380c5028',
],
[
'0x0fea',
'0x9c86edd1b5d75ac1050a5a7494dece5f186b8e9654f75cf4942f7dca57fc2de0',
'0x32f306028776389107c40f1765679b2630f093b1c4f4fda9415f0c909c7addef',
],
[
'0x0fe9',
'0x392e7a5d2efbc7da9d114ce79797eebbe2007ece065109f7f93baed1e23bb22c',
'0x22e161a9f20c14b5830154e819cdaf59e8d82690b318afb19e2903b52020bb3e',
],
]
const appendFeePayerSignaturesSpy = sandbox.spy(tx, 'appendFeePayerSignatures')
combined = tx.combineSignedRawTransactions(rlpEncodedStringsWithFeePayerSignatures)
expect(appendFeePayerSignaturesSpy).to.have.been.callCount(rlpEncodedStringsWithFeePayerSignatures.length)
// combine multiple signatures and feePayerSignatures
tx = caver.transaction.feeDelegatedCancel.create(transactionObj)
const combinedWithMultiple = tx.combineSignedRawTransactions([combined])
expect(combined).to.equal(combinedWithMultiple)
checkSignature(tx, { expectedSignatures })
checkFeePayerSignature(tx, { expec