aboutsummaryrefslogtreecommitdiffstats
path: root/test/lib
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-08-22 02:35:18 +0800
committerDan Finlay <dan@danfinlay.com>2017-08-22 02:35:51 +0800
commitc76194d7c315f9fb8e536328f97a2ac2dc411097 (patch)
tree25bac5fdfbe2b4db0540c489f1037a392ceb79e8 /test/lib
parent1ffb40648066189cd9e3abffc94299bbeecb6334 (diff)
downloadtangerine-wallet-browser-c76194d7c315f9fb8e536328f97a2ac2dc411097.tar
tangerine-wallet-browser-c76194d7c315f9fb8e536328f97a2ac2dc411097.tar.gz
tangerine-wallet-browser-c76194d7c315f9fb8e536328f97a2ac2dc411097.tar.bz2
tangerine-wallet-browser-c76194d7c315f9fb8e536328f97a2ac2dc411097.tar.lz
tangerine-wallet-browser-c76194d7c315f9fb8e536328f97a2ac2dc411097.tar.xz
tangerine-wallet-browser-c76194d7c315f9fb8e536328f97a2ac2dc411097.tar.zst
tangerine-wallet-browser-c76194d7c315f9fb8e536328f97a2ac2dc411097.zip
Move mock txs to tx mocking class
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/mock-tx-gen.js40
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