Unverified Commit db77e930 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #1120 from LeviBarnes/master

Allow timestamps to be passed to rawRun
parents c726b3be 989b6b04
...@@ -22,7 +22,11 @@ class TxRunner { ...@@ -22,7 +22,11 @@ class TxRunner {
} }
rawRun (args, confirmationCb, gasEstimationForceSend, promptCb, cb) { rawRun (args, confirmationCb, gasEstimationForceSend, promptCb, cb) {
run(this, args, Date.now(), confirmationCb, gasEstimationForceSend, promptCb, cb) var timestamp = Date.now()
if (args.timestamp) {
timestamp = args.timestamp
}
run(this, args, timestamp, confirmationCb, gasEstimationForceSend, promptCb, cb)
} }
_executeTx (tx, gasPrice, api, promptCb, callback) { _executeTx (tx, gasPrice, api, promptCb, callback) {
...@@ -81,20 +85,21 @@ class TxRunner { ...@@ -81,20 +85,21 @@ class TxRunner {
self.runInNode(args.from, args.to, data, args.value, args.gasLimit, args.useCall, confirmationCb, gasEstimationForceSend, promptCb, callback) self.runInNode(args.from, args.to, data, args.value, args.gasLimit, args.useCall, confirmationCb, gasEstimationForceSend, promptCb, callback)
} else { } else {
try { try {
self.runInVm(args.from, args.to, data, args.value, args.gasLimit, args.useCall, callback) self.runInVm(args.from, args.to, data, args.value, args.gasLimit, args.useCall, args.timestamp, callback)
} catch (e) { } catch (e) {
callback(e, null) callback(e, null)
} }
} }
} }
runInVm (from, to, data, value, gasLimit, useCall, callback) { runInVm (from, to, data, value, gasLimit, useCall, timestamp, callback) {
const self = this const self = this
var account = self.vmaccounts[from] var account = self.vmaccounts[from]
if (!account) { if (!account) {
return callback('Invalid account selected') return callback('Invalid account selected')
} }
var tx = new EthJSTX({ var tx = new EthJSTX({
timestamp: timestamp,
nonce: new BN(account.nonce++), nonce: new BN(account.nonce++),
gasPrice: new BN(1), gasPrice: new BN(1),
gasLimit: new BN(gasLimit, 10), gasLimit: new BN(gasLimit, 10),
...@@ -108,7 +113,7 @@ class TxRunner { ...@@ -108,7 +113,7 @@ class TxRunner {
const difficulties = [ new BN('69762765929000', 10), new BN('70762765929000', 10), new BN('71762765929000', 10) ] const difficulties = [ new BN('69762765929000', 10), new BN('70762765929000', 10), new BN('71762765929000', 10) ]
var block = new EthJSBlock({ var block = new EthJSBlock({
header: { header: {
timestamp: new Date().getTime() / 1000 | 0, timestamp: timestamp || (new Date().getTime() / 1000 | 0),
number: self.blockNumber, number: self.blockNumber,
coinbase: coinbases[self.blockNumber % coinbases.length], coinbase: coinbases[self.blockNumber % coinbases.length],
difficulty: difficulties[self.blockNumber % difficulties.length], difficulty: difficulties[self.blockNumber % difficulties.length],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment