diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-09-07 04:45:03 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-09-07 04:45:03 +0800 |
commit | 6c83ba762e73419c6db444dde05b3ebe31d7028e (patch) | |
tree | 0a1655190af8d8076de514452a70a8b54d27d371 /test/lib/mock-tx-gen.js | |
parent | 15c12ca4bb6996f43518630ded12c0d7be2d571b (diff) | |
parent | 47340ca550cf8bc6738a6970e10b599416da3a39 (diff) | |
download | tangerine-wallet-browser-6c83ba762e73419c6db444dde05b3ebe31d7028e.tar tangerine-wallet-browser-6c83ba762e73419c6db444dde05b3ebe31d7028e.tar.gz tangerine-wallet-browser-6c83ba762e73419c6db444dde05b3ebe31d7028e.tar.bz2 tangerine-wallet-browser-6c83ba762e73419c6db444dde05b3ebe31d7028e.tar.lz tangerine-wallet-browser-6c83ba762e73419c6db444dde05b3ebe31d7028e.tar.xz tangerine-wallet-browser-6c83ba762e73419c6db444dde05b3ebe31d7028e.tar.zst tangerine-wallet-browser-6c83ba762e73419c6db444dde05b3ebe31d7028e.zip |
Merge branch 'master' into transactionControllerRefractorPt3
Diffstat (limited to 'test/lib/mock-tx-gen.js')
-rw-r--r-- | test/lib/mock-tx-gen.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/lib/mock-tx-gen.js b/test/lib/mock-tx-gen.js new file mode 100644 index 000000000..7aea09c59 --- /dev/null +++ b/test/lib/mock-tx-gen.js @@ -0,0 +1,40 @@ +const extend = require('xtend') +const BN = require('ethereumjs-util').BN +const template = { + 'status': 'submitted', + 'txParams': { + 'from': '0x7d3517b0d011698406d6e0aed8453f0be2697926', + 'gas': '0x30d40', + 'value': '0x0', + 'nonce': '0x3', + }, +} + +class TxGenerator { + + constructor () { + this.txs = [] + } + + generate (tx = {}, opts = {}) { + let { count, fromNonce } = opts + let nonce = fromNonce || this.txs.length + let txs = [] + for (let i = 0; i < count; i++) { + txs.push(extend(template, { + txParams: { + nonce: hexify(nonce++), + } + }, tx)) + } + this.txs = this.txs.concat(txs) + return txs + } + +} + +function hexify (number) { + return '0x' + (new BN(number)).toString(16) +} + +module.exports = TxGenerator |