parent
9d03238bd1
commit
7696ff1db1
@ -1,16 +1,6 @@ |
||||
'use strict' |
||||
module.exports = { |
||||
rule: { |
||||
'width': '600px' |
||||
}, |
||||
runner: { |
||||
'position': 'absolute', |
||||
'width': '16px', |
||||
'height': '16px', |
||||
'margin': '0', |
||||
'padding': '0', |
||||
'overflow': 'hidden', |
||||
'border': '1px solid #a4bed4', |
||||
'background-color': '#f1f7ff' |
||||
'width': '98%' |
||||
} |
||||
} |
||||
|
@ -0,0 +1,77 @@ |
||||
function loadJSON (url, callback) { |
||||
var xobj = new XMLHttpRequest() |
||||
xobj.overrideMimeType('application/json') |
||||
xobj.open('GET', url, true) |
||||
xobj.onreadystatechange = function () { |
||||
if (xobj.readyState == 4 && xobj.status == '200') { |
||||
callback(xobj.responseText) |
||||
} |
||||
} |
||||
xobj.send(null) |
||||
} |
||||
|
||||
function loadTestWeb3 (data) { |
||||
var container = document.getElementById('app') |
||||
var vmdebugger = container.debugger |
||||
var uiTestweb3 = {} |
||||
uiTestweb3.eth = {} |
||||
uiTestweb3.debug = {} |
||||
uiTestweb3.eth.getCode = function (address, callback) { |
||||
if (callback) { |
||||
callback(null, data.testCodes[address]) |
||||
} else { |
||||
return data.testCodes[address] |
||||
} |
||||
} |
||||
|
||||
uiTestweb3.debug.traceTransaction = function (txHash, options, callback) { |
||||
callback(null, data.testTraces[txHash]) |
||||
} |
||||
|
||||
uiTestweb3.debug.storageAt = function (blockNumber, txIndex, address, callback) { |
||||
callback(null, {}) |
||||
} |
||||
|
||||
uiTestweb3.eth.getTransaction = function (txHash, callback) { |
||||
if (callback) { |
||||
callback(null, data.testTxs[txHash]) |
||||
} else { |
||||
return data.testTxs[txHash] |
||||
} |
||||
} |
||||
|
||||
uiTestweb3.eth.getTransactionFromBlock = function (blockNumber, txIndex, callback) { |
||||
if (callback) { |
||||
callback(null, data.testTxsByBlock[blockNumber + '-' + txIndex]) |
||||
} else { |
||||
return data.testTxsByBlock[blockNumber + '-' + txIndex] |
||||
} |
||||
} |
||||
|
||||
uiTestweb3.eth.getBlockNumber = function (callback) { callback(null, 'web3 modified for testing purposes :)') } |
||||
|
||||
uiTestweb3.providers = { 'HttpProvider': function (url) {} } |
||||
|
||||
uiTestweb3.setProvider = function (provider) {} |
||||
|
||||
uiTestweb3.currentProvider = {host: 'web3 modified for testing purposes :)'}
|
||||
vmdebugger.addProvider('TEST', uiTestweb3) |
||||
vmdebugger.switchProvider('TEST') |
||||
} |
||||
|
||||
function waitForRemix (data) { |
||||
setTimeout(function () { |
||||
if (!document.getElementById('app').debugger) { |
||||
waitForRemix(data) |
||||
} else { |
||||
loadTestWeb3(data) |
||||
} |
||||
}, 500) |
||||
} |
||||
|
||||
loadJSON('/test/resources/testWeb3.json', function (result) { |
||||
var data = JSON.parse(result) |
||||
waitForRemix(data) |
||||
}) |
||||
|
||||
|
Loading…
Reference in new issue