UNPKG

caver-js

Version:

caver-js is a JavaScript API library that allows developers to interact with a Kaia node

1,006 lines (803 loc) 72.2 kB
/* 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 testKeyring let roleBasedKeyring const txWithExpectedValues = {} const sandbox = sinon.createSandbox() before(() => { caver = new Caver(testRPCURL) sender = caver.wallet.add(caver.wallet.keyring.generate()) testKeyring = caver.wallet.add(caver.wallet.keyring.generate()) roleBasedKeyring = generateRoleBasedKeyring([3, 3, 3]) txWithExpectedValues.tx = { from: '0xa94f5374Fce5edBC8E2a8697C15331677e6EbF0B', to: '0x7b65B75d204aBed71587c9E519a89277766EE1d0', value: '0xa', input: '0x68656c6c6f', gas: '0xf4240', gasPrice: '0x19', feeRatio: 30, chainId: '0x1', nonce: 1234, signatures: [ [ '0x26', '0x769f0afdc310289f9b24decb5bb765c8d7a87a6a4ae28edffb8b7085bbd9bc78', '0x6a7b970eea026e60ac29bb52aee10661a4222e6bdcdfb3839a80586e584586b4', ], ], feePayer: '0x5A0043070275d9f6054307Ee7348bD660849D90f', feePayerSignatures: [ [ '0x25', '0xc1c54bdc72ce7c08821329bf50542535fac74f4bba5de5b7881118a461d52834', '0x3a3a64878d784f9af91c2e3ab9c90f17144c47cfd9951e3588c75063c0649ecd', ], ], } txWithExpectedValues.rlpEncodingForSigning = '0xf842b83df83b128204d219830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94a94f5374fce5edbc8e2a8697c15331677e6ebf0b8568656c6c6f1e018080' txWithExpectedValues.rlpEncodingForFeePayerSigning = '0xf857b83df83b128204d219830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94a94f5374fce5edbc8e2a8697c15331677e6ebf0b8568656c6c6f1e945a0043070275d9f6054307ee7348bd660849d90f018080' txWithExpectedValues.senderTxHash = '0x2c4e8cd3c68a4aacae51c695e857cfc1a019037ca71d8cd1e8ca56ec4eaf55b1' txWithExpectedValues.transactionHash = '0xabcb0fd8ebb8f62ac899e5211b9ba47fe948a8efd815229cc4ed9cd781464f15' txWithExpectedValues.rlpEncoding = '0x12f8dd8204d219830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94a94f5374fce5edbc8e2a8697c15331677e6ebf0b8568656c6c6f1ef845f84326a0769f0afdc310289f9b24decb5bb765c8d7a87a6a4ae28edffb8b7085bbd9bc78a06a7b970eea026e60ac29bb52aee10661a4222e6bdcdfb3839a80586e584586b4945a0043070275d9f6054307ee7348bd660849d90ff845f84325a0c1c54bdc72ce7c08821329bf50542535fac74f4bba5de5b7881118a461d52834a03a3a64878d784f9af91c2e3ab9c90f17144c47cfd9951e3588c75063c0649ecd' }) describe('TxTypeFeeDelegatedValueTransferMemoWithRatio', () => { let transactionObj let getGasPriceSpy let getHeaderSpy let getNonceSpy let getChainIdSpy beforeEach(() => { transactionObj = { from: sender.address, to: testKeyring.address, value: 1, input: '0x68656c6c6f', gas: '0x3b9ac9ff', feeRatio: 30, } 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 feeDelegatedValueTransferMemoWithRatio instance', () => { it('CAVERJS-UNIT-TRANSACTIONFDR-076: If feeDelegatedValueTransferMemoWithRatio not define from, return error', () => { delete transactionObj.from const expectedError = '"from" is missing' expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) }) it('CAVERJS-UNIT-TRANSACTIONFDR-077: If feeDelegatedValueTransferMemoWithRatio not define to, return error', () => { delete transactionObj.to const expectedError = '"to" is missing' expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) }) it('CAVERJS-UNIT-TRANSACTIONFDR-078: If feeDelegatedValueTransferMemoWithRatio not define value, return error', () => { delete transactionObj.value const expectedError = '"value" is missing' expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) }) it('CAVERJS-UNIT-TRANSACTIONFDR-079: If feeDelegatedValueTransferMemoWithRatio not define gas, return error', () => { delete transactionObj.gas const expectedError = '"gas" is missing' expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) }) it('CAVERJS-UNIT-TRANSACTIONFDR-080: If feeDelegatedValueTransferMemoWithRatio not define input, return error', () => { delete transactionObj.input const expectedError = '"input" is missing' expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) }) it('CAVERJS-UNIT-TRANSACTIONFDR-081: If feeDelegatedValueTransferMemoWithRatio not define feeRatio, return error', () => { delete transactionObj.feeRatio const expectedError = '"feeRatio" is missing' expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) }) it('CAVERJS-UNIT-TRANSACTIONFDR-082: If feeDelegatedValueTransferMemoWithRatio define from property with invalid address, return error', () => { transactionObj.from = 'invalid' const expectedError = `Invalid address of from: ${transactionObj.from}` expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) }) it('CAVERJS-UNIT-TRANSACTIONFDR-083: If feeDelegatedValueTransferMemoWithRatio define feePayer property with invalid address, return error', () => { transactionObj.feePayer = 'invalid' const expectedError = `Invalid address of fee payer: ${transactionObj.feePayer}` expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) }) it('CAVERJS-UNIT-TRANSACTIONFDR-084: If feeDelegatedValueTransferMemoWithRatio define to property with invalid address, return error', () => { transactionObj.to = 'invalid address' const expectedError = `Invalid address of to: ${transactionObj.to}` expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) }) it('CAVERJS-UNIT-TRANSACTIONFDR-526: If feeDelegatedValueTransferMemoWithRatio define feeRatio property with invalid value, return error', () => { transactionObj.feeRatio = 'nonHexString' let expectedError = `Invalid type fo feeRatio: feeRatio should be number type or hex number string.` expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) transactionObj.feeRatio = {} expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) transactionObj.feeRatio = [] expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) transactionObj.feeRatio = 0 expectedError = `Invalid feeRatio: feeRatio is out of range. [1, 99]` expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) transactionObj.feeRatio = 100 expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) transactionObj.feeRatio = -1 expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) transactionObj.feeRatio = 101 expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) }) it('CAVERJS-UNIT-TRANSACTIONFDR-085: If feeDelegatedValueTransferMemoWithRatio 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.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) }) it('CAVERJS-UNIT-TRANSACTIONFDR-086: If feeDelegatedValueTransferMemoWithRatio define unnecessary property, return error', () => { const unnecessaries = [ propertiesForUnnecessary.codeFormat, propertiesForUnnecessary.failKey, propertiesForUnnecessary.account, propertiesForUnnecessary.key, propertiesForUnnecessary.legacyKey, propertiesForUnnecessary.publicKey, propertiesForUnnecessary.failKey, propertiesForUnnecessary.multisig, propertiesForUnnecessary.roleTransactionKey, propertiesForUnnecessary.roleAccountUpdateKey, propertiesForUnnecessary.roleFeePayerKey, propertiesForUnnecessary.humanReadable, 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.TxTypeFeeDelegatedValueTransferMemoWithRatio} transaction` expect(() => caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj)).to.throw(expectedError) } }) }) context('feeDelegatedValueTransferMemoWithRatio.getRLPEncoding', () => { it('CAVERJS-UNIT-TRANSACTIONFDR-087: Returns RLP-encoded string', () => { const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(txWithExpectedValues.tx) expect(tx.getRLPEncoding()).to.equal(txWithExpectedValues.rlpEncoding) }) it('CAVERJS-UNIT-TRANSACTIONFDR-088: getRLPEncoding should throw error when nonce is undefined', () => { transactionObj.chainId = 2019 transactionObj.gasPrice = '0x5d21dba00' const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) 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-TRANSACTIONFDR-089: getRLPEncoding should throw error when gasPrice is undefined', () => { transactionObj.chainId = 2019 transactionObj.nonce = '0x3a' const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const expectedError = `gasPrice is undefined. Define gasPrice in transaction or use 'transaction.fillTransaction' to fill values.` expect(() => tx.getRLPEncoding()).to.throw(expectedError) }) }) context('feeDelegatedValueTransferMemoWithRatio.sign', () => { const txHash = '0xe9a11d9ef95fb437f75d07ce768d43e74f158dd54b106e7d3746ce29d545b550' let fillTransactionSpy let createFromPrivateKeySpy let senderSignSpy let appendSignaturesSpy let hasherSpy let tx beforeEach(() => { tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.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-TRANSACTIONFDR-091: 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-TRANSACTIONFDR-092: 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-TRANSACTIONFDR-093: 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-TRANSACTIONFDR-094: 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-TRANSACTIONFDR-095: 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-TRANSACTIONFDR-096: 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-TRANSACTIONFDR-097: input: keyring. should throw error when from is different.', async () => { transactionObj.from = roleBasedKeyring.address tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.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-TRANSACTIONFDR-098: input: rolebased keyring, index out of range. should throw error.', async () => { transactionObj.from = roleBasedKeyring.address tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.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('feeDelegatedValueTransferMemoWithRatio.signAsFeePayer', () => { const txHash = '0xe9a11d9ef95fb437f75d07ce768d43e74f158dd54b106e7d3746ce29d545b550' let fillTransactionSpy let createFromPrivateKeySpy let senderSignSpy let appendSignaturesSpy let hasherSpy let tx beforeEach(() => { tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.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-TRANSACTIONFDR-099: 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-TRANSACTIONFDR-100: 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-TRANSACTIONFDR-101: 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-TRANSACTIONFDR-102: 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-TRANSACTIONFDR-103: 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-TRANSACTIONFDR-104: 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-TRANSACTIONFDR-105: 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-TRANSACTIONFDR-106: 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-TRANSACTIONFDR-107: input: rolebased keyring, index out of range. should throw error.', async () => { transactionObj.from = roleBasedKeyring.address tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.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('feeDelegatedValueTransferMemoWithRatio.sign with multiple keys', () => { const txHash = '0xe9a11d9ef95fb437f75d07ce768d43e74f158dd54b106e7d3746ce29d545b550' let fillTransactionSpy let createFromPrivateKeySpy let senderSignWithKeysSpy let appendSignaturesSpy let hasherSpy let tx beforeEach(() => { tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.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-TRANSACTIONFDR-108: 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-TRANSACTIONFDR-109: 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-TRANSACTIONFDR-110: 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-TRANSACTIONFDR-111: 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-TRANSACTIONFDR-112: input: keyring. should throw error when from is different.', async () => { transactionObj.from = roleBasedKeyring.address tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.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-TRANSACTIONFDR-113: 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('feeDelegatedValueTransferMemoWithRatio.signAsFeePayer with multiple keys', () => { const txHash = '0xe9a11d9ef95fb437f75d07ce768d43e74f158dd54b106e7d3746ce29d545b550' let fillTransactionSpy let createFromPrivateKeySpy let senderSignWithKeysSpy let appendSignaturesSpy let hasherSpy let tx beforeEach(() => { tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.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-TRANSACTIONFDR-114: 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-TRANSACTIONFDR-115: 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-TRANSACTIONFDR-116: 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-TRANSACTIONFDR-117: 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-TRANSACTIONFDR-118: 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-TRANSACTIONFDR-119: 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-TRANSACTIONFDR-120: 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('feeDelegatedValueTransferMemoWithRatio.appendSignatures', () => { afterEach(() => { sandbox.restore() }) it('CAVERJS-UNIT-TRANSACTIONFDR-121: If signatures is empty, appendSignatures append signatures in transaction', () => { const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const sig = [ '0x0fea', '0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e', '0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e', ] tx.appendSignatures(sig) checkSignature(tx) }) it('CAVERJS-UNIT-TRANSACTIONFDR-122: If signatures is empty, appendSignatures append signatures with two-dimensional signature array', () => { const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const sig = [ [ '0x0fea', '0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e', '0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e', ], ] tx.appendSignatures(sig) checkSignature(tx) }) it('CAVERJS-UNIT-TRANSACTIONFDR-123: If signatures is not empty, appendSignatures should append signatures', () => { transactionObj.signatures = [ '0x0fea', '0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e', '0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e', ] const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const sig = [ '0x0fea', '0x7a5011b41cfcb6270af1b5f8aeac8aeabb1edb436f028261b5add564de694700', '0x23ac51660b8b421bf732ef8148d0d4f19d5e29cb97be6bccb5ae505ebe89eb4a', ] tx.appendSignatures(sig) checkSignature(tx, { expectedLength: 2 }) }) it('CAVERJS-UNIT-TRANSACTIONFDR-124: appendSignatures should append multiple signatures', () => { const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const sig = [ [ '0x0fea', '0xbde66cceed35a576010966338b7ded961f2c160c96f928e193b47aaf4480aa07', '0x546eb193ec138523b7fd34c4f12a1a04d0f74470e8f3bbe91ce0b4ec16e7f0d2', ], [ '0x0fea', '0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e', '0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e', ], ] tx.appendSignatures(sig) checkSignature(tx, { expectedLength: 2 }) }) }) context('feeDelegatedValueTransferMemoWithRatio.appendFeePayerSignatures', () => { beforeEach(() => { transactionObj.feePayer = '0x90b3e9a3770481345a7f17f22f16d020bccfd33e' }) afterEach(() => { sandbox.restore() }) it('CAVERJS-UNIT-TRANSACTIONFDR-125: If feePayerSignatures is empty, appendFeePayerSignatures append feePayerSignatures in transaction', () => { const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const sig = [ '0x0fea', '0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e', '0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e', ] tx.appendFeePayerSignatures(sig) checkFeePayerSignature(tx) }) it('CAVERJS-UNIT-TRANSACTIONFDR-126: If feePayerSignatures is empty, appendFeePayerSignatures append feePayerSignatures with two-dimensional signature array', () => { const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const sig = [ [ '0x0fea', '0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e', '0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e', ], ] tx.appendFeePayerSignatures(sig) checkFeePayerSignature(tx) }) it('CAVERJS-UNIT-TRANSACTIONFDR-127: If feePayerSignatures is not empty, appendFeePayerSignatures should append feePayerSignatures', () => { transactionObj.feePayerSignatures = [ '0x0fea', '0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e', '0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e', ] const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const sig = [ '0x0fea', '0x7a5011b41cfcb6270af1b5f8aeac8aeabb1edb436f028261b5add564de694700', '0x23ac51660b8b421bf732ef8148d0d4f19d5e29cb97be6bccb5ae505ebe89eb4a', ] tx.appendFeePayerSignatures(sig) checkFeePayerSignature(tx, { expectedLength: 2 }) }) it('CAVERJS-UNIT-TRANSACTIONFDR-128: appendFeePayerSignatures should append multiple feePayerSignatures', () => { const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const sig = [ [ '0x0fea', '0xbde66cceed35a576010966338b7ded961f2c160c96f928e193b47aaf4480aa07', '0x546eb193ec138523b7fd34c4f12a1a04d0f74470e8f3bbe91ce0b4ec16e7f0d2', ], [ '0x0fea', '0xade9480f584fe481bf070ab758ecc010afa15debc33e1bd75af637d834073a6e', '0x38160105d78cef4529d765941ad6637d8dcf6bd99310e165fee1c39fff2aa27e', ], ] tx.appendFeePayerSignatures(sig) checkFeePayerSignature(tx, { expectedLength: 2 }) }) }) context('feeDelegatedValueTransferMemoWithRatio.combineSignedRawTransactions', () => { beforeEach(() => { transactionObj = { from: '0xceca418cc3ed540c8d16675fe600d703154e379f', to: '0x7b65b75d204abed71587c9e519a89277766ee1d0', value: '0xa', input: '0x68656c6c6f', gas: '0xf4240', feeRatio: 30, nonce: '0x1', gasPrice: '0x5d21dba00', chainId: '0x7e3', } }) afterEach(() => { sandbox.restore() }) it('CAVERJS-UNIT-TRANSACTIONFDR-129: combineSignedRawTransactions combines single signature and sets signatures in transaction', () => { const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const appendSignaturesSpy = sandbox.spy(tx, 'appendSignatures') const getRLPEncodingSpy = sandbox.spy(tx, 'getRLPEncoding') const rlpEncoded = '0x12f8a0018505d21dba00830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94ceca418cc3ed540c8d16675fe600d703154e379f8568656c6c6f1ef847f845820feaa050edf44854ee83c3ea396614796a19b9ebe4714b6fde40f52ce02b8e7a32be22a01fbbd3dd81af0eadc375e390fd468d9574a76a826cc02abe55f1d1176da4286d940000000000000000000000000000000000000000c4c3018080' const combined = tx.combineSignedRawTransactions([rlpEncoded]) const expectedSignatures = [ [ '0x0fea', '0x50edf44854ee83c3ea396614796a19b9ebe4714b6fde40f52ce02b8e7a32be22', '0x1fbbd3dd81af0eadc375e390fd468d9574a76a826cc02abe55f1d1176da4286d', ], ] expect(appendSignaturesSpy).to.have.been.calledOnce expect(getRLPEncodingSpy).to.have.been.calledOnce expect(combined).to.equal(rlpEncoded) checkSignature(tx, { expectedSignatures }) }) it('CAVERJS-UNIT-TRANSACTIONFDR-130: combineSignedRawTransactions combines multiple signatures and sets signatures in transaction', () => { transactionObj.signatures = [ [ '0x0fea', '0x50edf44854ee83c3ea396614796a19b9ebe4714b6fde40f52ce02b8e7a32be22', '0x1fbbd3dd81af0eadc375e390fd468d9574a76a826cc02abe55f1d1176da4286d', ], ] const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const rlpEncodedStrings = [ '0x12f88c018505d21dba00830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94ceca418cc3ed540c8d16675fe600d703154e379f8568656c6c6f1ef847f845820fe9a03c5bdf4fba47ee89e3072d2c707efb241aef04cb2c7b9771bea2ffd62c2b3807a05d7be6df572fdb60f68a3250da5794a983f609991561d31a9189f0d7212de88c80c4c3018080', '0x12f88c018505d21dba00830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94ceca418cc3ed540c8d16675fe600d703154e379f8568656c6c6f1ef847f845820feaa0f1e794e5f0a28afce80bd9a89883ed55f96a8d45b03ae8355524a0000eac8a2ea0202e179034aefcadcc7a25360c3bb88f1a572c5912e5031bac11d466ebb6727e80c4c3018080', ] const appendSignaturesSpy = sandbox.spy(tx, 'appendSignatures') const getRLPEncodingSpy = sandbox.spy(tx, 'getRLPEncoding') const combined = tx.combineSignedRawTransactions(rlpEncodedStrings) const expectedRLPEncoded = '0x12f9012e018505d21dba00830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94ceca418cc3ed540c8d16675fe600d703154e379f8568656c6c6f1ef8d5f845820feaa050edf44854ee83c3ea396614796a19b9ebe4714b6fde40f52ce02b8e7a32be22a01fbbd3dd81af0eadc375e390fd468d9574a76a826cc02abe55f1d1176da4286df845820fe9a03c5bdf4fba47ee89e3072d2c707efb241aef04cb2c7b9771bea2ffd62c2b3807a05d7be6df572fdb60f68a3250da5794a983f609991561d31a9189f0d7212de88cf845820feaa0f1e794e5f0a28afce80bd9a89883ed55f96a8d45b03ae8355524a0000eac8a2ea0202e179034aefcadcc7a25360c3bb88f1a572c5912e5031bac11d466ebb6727e940000000000000000000000000000000000000000c4c3018080' const expectedSignatures = [ [ '0x0fea', '0x50edf44854ee83c3ea396614796a19b9ebe4714b6fde40f52ce02b8e7a32be22', '0x1fbbd3dd81af0eadc375e390fd468d9574a76a826cc02abe55f1d1176da4286d', ], [ '0x0fe9', '0x3c5bdf4fba47ee89e3072d2c707efb241aef04cb2c7b9771bea2ffd62c2b3807', '0x5d7be6df572fdb60f68a3250da5794a983f609991561d31a9189f0d7212de88c', ], [ '0x0fea', '0xf1e794e5f0a28afce80bd9a89883ed55f96a8d45b03ae8355524a0000eac8a2e', '0x202e179034aefcadcc7a25360c3bb88f1a572c5912e5031bac11d466ebb6727e', ], ] 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-TRANSACTIONFDR-131: combineSignedRawTransactions combines single feePayerSignature and sets feePayerSignatures in transaction', () => { transactionObj.feePayer = '0x188375ff24b14775e1c13d382c2d1ef3a27ca614' const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const appendSignaturesSpy = sandbox.spy(tx, 'appendFeePayerSignatures') const getRLPEncodingSpy = sandbox.spy(tx, 'getRLPEncoding') const rlpEncoded = '0x12f8a0018505d21dba00830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94ceca418cc3ed540c8d16675fe600d703154e379f8568656c6c6f1ec4c301808094188375ff24b14775e1c13d382c2d1ef3a27ca614f847f845820fe9a05610e0b35da77d24c009fd6040a43ee70248b60b91892611a0cf36ef185399a2a05fc451b5b9e90453e8fcdf797e1a0875746ddfe1fdcc6617a21eb8e35b328f76' const combined = tx.combineSignedRawTransactions([rlpEncoded]) const expectedSignatures = [ [ '0x0fe9', '0x5610e0b35da77d24c009fd6040a43ee70248b60b91892611a0cf36ef185399a2', '0x5fc451b5b9e90453e8fcdf797e1a0875746ddfe1fdcc6617a21eb8e35b328f76', ], ] expect(appendSignaturesSpy).to.have.been.calledOnce expect(getRLPEncodingSpy).to.have.been.calledOnce expect(combined).to.equal(rlpEncoded) checkFeePayerSignature(tx, { expectedSignatures }) }) it('CAVERJS-UNIT-TRANSACTIONFDR-132: combineSignedRawTransactions combines multiple feePayerSignatures and sets feePayerSignatures in transaction', () => { transactionObj.feePayer = '0x188375ff24b14775e1c13d382c2d1ef3a27ca614' transactionObj.feePayerSignatures = [ [ '0x0fe9', '0x5610e0b35da77d24c009fd6040a43ee70248b60b91892611a0cf36ef185399a2', '0x5fc451b5b9e90453e8fcdf797e1a0875746ddfe1fdcc6617a21eb8e35b328f76', ], ] const tx = caver.transaction.feeDelegatedValueTransferMemoWithRatio.create(transactionObj) const rlpEncodedStrings = [ '0x12f8a0018505d21dba00830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94ceca418cc3ed540c8d16675fe600d703154e379f8568656c6c6f1ec4c301808094188375ff24b14775e1c13d382c2d1ef3a27ca614f847f845820feaa0defc41992109af25e9956cbe7d593cd3f65dd2bf1e8f71d7ac1799451a90c062a03487aacf56a6f5f4719e51778ac5fac00e6994b0327ffa5edf99d879116e6e5a', '0x12f8a0018505d21dba00830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94ceca418cc3ed540c8d16675fe600d703154e379f8568656c6c6f1ec4c301808094188375ff24b14775e1c13d382c2d1ef3a27ca614f847f845820fe9a09913be30cc8b8c68fd4745f6b04ede43e272496c9245bc0784339cdff8b3c008a02e3b652fa111946ea868e29714370822220dec6c4bfabfcaf1f023df800217d2', ] const appendSignaturesSpy = sandbox.spy(tx, 'appendFeePayerSignatures') const getRLPEncodingSpy = sandbox.spy(tx, 'getRLPEncoding') const combined = tx.combineSignedRawTransactions(rlpEncodedStrings) const expectedRLPEncoded = '0x12f9012e018505d21dba00830f4240947b65b75d204abed71587c9e519a89277766ee1d00a94ceca418cc3ed540c8d16675fe600d703154e379f8568656c6c6f1ec4c301808094188375ff24b14775e1c13d382c2d1ef3a27ca614f8d5f845820fe9a05610e0b35da77d24c009fd6040a43ee70248b60b91892611a0cf36ef185399a2a05fc451b5b9e90453e8