Skip to content

Commit eb6be0a

Browse files
committed
no web3 in misc ut
1 parent 0ed22e9 commit eb6be0a

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

libs/remix-simulator/test/misc.ts

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,84 @@
11
/* global describe, before, it */
2-
import { Web3 } from 'web3'
32
import { Provider } from '../src/index'
4-
const web3 = new Web3()
53
import * as assert from 'assert'
4+
import { ethers, BrowserProvider } from "ethers"
65

76
describe('Misc', () => {
7+
let ethersProvider: BrowserProvider
88
before(async () => {
99
const provider = new Provider()
1010
await provider.init()
11-
web3.setProvider(provider as any)
11+
ethersProvider = new ethers.BrowserProvider(provider as any)
1212
})
1313

1414
describe('web3_clientVersion', () => {
1515
it('should get correct remix simulator version', async () => {
16-
web3['_requestManager'].send({ method: 'web3_clientVersion', params: []})
17-
.then(version => {
18-
const remixVersion = require('../package.json').version
19-
assert.equal(version, 'Remix Simulator/' + remixVersion)
20-
})
21-
.catch(err => { throw new Error(err) })
16+
const version = await ethersProvider.send("web3_clientVersion", [])
17+
const remixVersion = require('../package.json').version
18+
assert.equal(version, 'Remix Simulator/' + remixVersion)
2219
})
2320
})
2421

2522
describe('eth_protocolVersion', () => {
2623
it('should get protocol version', async () => {
27-
web3['_requestManager'].send({ method: 'eth_protocolVersion', params: []})
28-
.then(result => assert.equal(result, '0x3f'))
29-
.catch(err => { throw new Error(err) })
24+
const result = await ethersProvider.send("eth_protocolVersion", [])
25+
assert.equal(result, '0x3f')
3026
})
3127
})
3228

3329
describe('eth_syncing', () => {
3430
it('should get if is syncing', async () => {
35-
const isSyncing = await web3.eth.isSyncing()
31+
const isSyncing = await ethersProvider.send("eth_syncing", [])
3632
assert.equal(isSyncing, false)
3733
})
3834
})
3935

4036
describe('eth_mining', () => {
4137
it('should get if is mining', async () => {
42-
const isMining = await web3.eth.isMining()
38+
const isMining = await ethersProvider.send("eth_mining", [])
4339
assert.equal(isMining, false)
4440
})
4541
})
4642

4743
describe('eth_hashrate', () => {
4844
it('should get hashrate', async () => {
49-
const hashrate = await web3.eth.getHashrate()
45+
const hashrate = await ethersProvider.send("eth_hashrate", [])
5046
assert.equal(hashrate, 0)
5147
})
5248
})
5349

5450
describe('web3_sha3', () => {
5551
it('should get result of a sha3', async () => {
56-
web3['_requestManager'].send({ method: 'web3_sha3', params: ['0x68656c6c6f20776f726c64']})
57-
.then(result => assert.equal(result, '0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad'))
58-
.catch(err => { throw new Error(err)} )
52+
const result = await ethersProvider.send("web3_sha3", ['0x68656c6c6f20776f726c64'])
53+
assert.equal(result, '0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad')
5954
})
6055
})
6156

6257
describe('eth_getCompilers', () => {
6358
it('should get list of compilers', async () => {
64-
web3['_requestManager'].send({ method: 'eth_getCompilers', params: []})
65-
.then(result => assert.equal(result, 0))
66-
.catch(err => { throw new Error(err) })
59+
const result = await ethersProvider.send("eth_getCompilers", [])
60+
assert.equal(result, 0)
6761
})
6862
})
6963

7064
describe('eth_compileSolidity', () => {
7165
it('get unsupported result when requesting solidity compiler', async () => {
72-
web3['_requestManager'].send({ method: 'eth_compileSolidity', params: []})
73-
.then(result => assert.equal(result, 'unsupported'))
74-
.catch(err => { throw new Error(err) })
66+
const result = await ethersProvider.send("eth_compileSolidity", [])
67+
assert.equal(result, 'unsupported')
7568
})
7669
})
7770

7871
describe('eth_compileLLL', () => {
7972
it('get unsupported result when requesting LLL compiler', async () => {
80-
web3['_requestManager'].send({ method: 'eth_compileLLL', params: []})
81-
.then(result => assert.equal(result, 'unsupported'))
82-
.catch(err => { throw new Error(err) })
73+
const result = await ethersProvider.send("eth_compileLLL", [])
74+
assert.equal(result, 'unsupported')
8375
})
8476
})
8577

8678
describe('eth_compileSerpent', () => {
8779
it('get unsupported result when requesting serpent compiler', async () => {
88-
web3['_requestManager'].send({ method: 'eth_compileSerpent', params: []})
89-
.then(result => assert.equal(result, 'unsupported'))
90-
.catch(err => { throw new Error(err)} )
80+
const result = await ethersProvider.send("eth_compileSerpent", [])
81+
assert.equal(result, 'unsupported')
9182
})
9283
})
9384
})

0 commit comments

Comments
 (0)