add tests; update web3.js

pull/7/head
Iuri Matias 6 years ago
parent c91ff4337c
commit 4e1752ddbd
  1. 3
      remix-simulator/package.json
  2. 19
      remix-simulator/test/accounts.js
  3. 48
      remix-simulator/test/blocks.js
  4. 50
      remix-simulator/test/misc.js
  5. 19
      remix-simulator/test/whisper.js
  6. 2
      remix-tests/package.json

@ -82,5 +82,8 @@
}
]
]
},
"devDependencies": {
"mocha": "^5.2.0"
}
}

@ -0,0 +1,19 @@
var Web3 = require('web3')
var RemixSim = require('../index.js')
let web3 = new Web3()
var assert = require('assert')
describe("Accounts", function() {
before(function() {
let provider = new RemixSim.Provider()
web3.setProvider(provider)
})
it("should get a list of accounts", async function() {
let accounts = await web3.eth.getAccounts()
assert.notEqual(accounts.length, 0)
})
});

@ -0,0 +1,48 @@
var Web3 = require('web3')
var RemixSim = require('../index.js')
let web3 = new Web3();
var assert = require('assert')
describe("blocks", function() {
before(function() {
let provider = new RemixSim.Provider()
web3.setProvider(provider)
})
it("should get block given its number", async function() {
let block = await web3.eth.getBlock(1)
let expectedBlock = {
difficulty: '0',
extraData: '0x',
gasLimit: 8000000,
gasUsed: 0,
hash: '0xdb731f3622ef37b4da8db36903de029220dba74c41185f8429f916058b86559f',
logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
miner: '0x3333333333333333333333333333333333333333',
mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
nonce: '0x0000000000000042',
number: 0,
parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
size: 504,
stateRoot: '0xb7917653f92e62394d2207d0f39a1320ff1cb93d1cee80d3c492627e00b219ff',
timestamp: 0,
totalDifficulty: '0',
transactions: [],
transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
uncles: []
}
assert.deepEqual(block, expectedBlock)
})
it("should get gas price", async function() {
let gasPrice = await web3.eth.getGasPrice()
assert.equal(gasPrice, 1)
})
});

@ -0,0 +1,50 @@
var Web3 = require('web3')
var RemixSim = require('../index.js')
let web3 = new Web3();
var assert = require('assert')
describe("Misc", function() {
before(function() {
let provider = new RemixSim.Provider()
web3.setProvider(provider)
})
it("should get correct remix simulator version", async function(done) {
web3._requestManager.send({method: 'web3_clientVersion', params: []}, (err, version) => {
let remix_version = require('../package.json').version
assert.equal(version, "Remix Simulator/" + remix_version)
done();
})
})
it("should get protocol version", async function() {
web3._requestManager.send({method: 'eth_protocolVersion', params: []}, (err, result) => {
assert.equal(result, "0x3f")
})
})
it("should get if is syncing", async function() {
let isSyncing = await web3.eth.isSyncing()
assert.equal(isSyncing, false)
})
it("should get if is mining", async function() {
let isMining = await web3.eth.isMining()
assert.equal(isMining, false)
})
it("should get hashrate", async function() {
let hashrate = await web3.eth.getHashrate()
assert.equal(hashrate, 0)
})
it("should get result of a sha3", async function() {
web3._requestManager.send({method: 'web3_sha3', params: ["0x68656c6c6f20776f726c64"]}, (err, result) => {
assert.equal(result, "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad")
})
})
});

@ -0,0 +1,19 @@
var Web3 = require('web3')
var RemixSim = require('../index.js')
let web3 = new Web3();
var assert = require('assert')
describe("Whisper", function() {
before(function() {
let provider = new RemixSim.Provider()
web3.setProvider(provider)
})
it("should get correct remix simulator version", async function() {
let version = await web3.shh.getVersion()
assert.equal(version, 5)
})
});

@ -46,7 +46,7 @@
"signale": "^1.2.1",
"solc": "^0.4.24",
"standard": "^10.0.3",
"web3": "1.0.0-beta.27",
"web3": "1.0.0-beta.34",
"winston": "^3.0.0"
},
"devDependencies": {

Loading…
Cancel
Save