test passing

pull/5370/head
aniket-engg 4 years ago committed by Aniket
parent 222ac140c7
commit 47a006cc48
  1. 2
      libs/remix-simulator/package.json
  2. 3
      libs/remix-simulator/src/genesis.ts
  3. 2
      libs/remix-simulator/src/index.ts
  4. 9
      libs/remix-simulator/src/provider.ts
  5. 8
      libs/remix-simulator/test/accounts.ts
  6. 22
      libs/remix-simulator/test/blocks.ts
  7. 22
      libs/remix-simulator/test/misc.ts
  8. 3
      libs/remix-simulator/tsconfig.json
  9. 2
      libs/remix-simulator/tsconfig.lib.json

@ -43,7 +43,7 @@
"mocha": "^5.2.0"
},
"scripts": {
"test": "./../../node_modules/.bin/mocha --require tsconfig-paths/register test/"
"test": "./../../node_modules/.bin/ts-node --require tsconfig-paths/register ./../../node_modules/.bin/mocha test/*.ts"
},
"publishConfig": {
"access": "public"

@ -1,7 +1,7 @@
import EthJSBlock from 'ethereumjs-block'
import { BN } from 'ethereumjs-util'
function generateBlock (executionContext) {
export function generateBlock (executionContext) {
const block = new EthJSBlock({
header: {
timestamp: (new Date().getTime() / 1000 | 0),
@ -19,4 +19,3 @@ function generateBlock (executionContext) {
})
}
module.exports = generateBlock

@ -1,3 +1,3 @@
import { Provider } from './provider'
export { Provider }
export default { Provider }

@ -9,11 +9,10 @@ import merge from 'merge'
import { Accounts } from './methods/accounts'
import { Filters } from './methods/filters'
import { Misc } from './methods/misc'
import { Net } from './methods/net.js'
import { Transactions } from './methods/transactions.js'
import { Debug } from './methods/debug.js'
const generateBlock = require('./genesis.js')
import { Net } from './methods/net'
import { Transactions } from './methods/transactions'
import { Debug } from './methods/debug'
import { generateBlock } from './genesis'
export class Provider {
options

@ -1,12 +1,12 @@
/* global describe, before, it */
const Web3 = require('web3')
const RemixSim = require('../index.js')
import Web3 from 'web3'
import RemixSim from '../src/index'
const web3 = new Web3()
const assert = require('assert')
import * as assert from 'assert'
describe('Accounts', () => {
before(function () {
const provider = new RemixSim.Provider()
const provider: any = new RemixSim.Provider()
web3.setProvider(provider)
})

@ -1,12 +1,12 @@
/* global describe, before, it */
const Web3 = require('web3')
const RemixSim = require('../index.js')
import Web3 from 'web3'
import RemixSim from '../src/index'
const web3 = new Web3()
const assert = require('assert')
import * as assert from 'assert'
describe('blocks', () => {
before(() => {
const provider = new RemixSim.Provider({
const provider: any = new RemixSim.Provider({
coinbase: '0x0000000000000000000000000000000000000001'
})
web3.setProvider(provider)
@ -21,7 +21,7 @@ describe('blocks', () => {
extraData: '0x0',
gasLimit: 8000000,
gasUsed: 0,
hash: block.hash.toString('hex'),
hash: block.hash.toString(),
logsBloom: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331',
miner: '0x0000000000000000000000000000000000000001',
nonce: '0x0000000000000000',
@ -92,7 +92,7 @@ describe('blocks', () => {
it('should get block given its hash', async () => {
const correctBlock = await web3.eth.getBlock(0)
const numberTransactions = await (new Promise((resolve, reject) => {
web3._requestManager.send({method: 'eth_getUncleCountByBlockHash', params: [correctBlock.hash]}, (err, numberTransactions) => {
web3['_requestManager'].send({method: 'eth_getUncleCountByBlockHash', params: [correctBlock.hash]}, (err, numberTransactions) => {
if (err) return reject(err)
resolve(numberTransactions)
})
@ -105,7 +105,7 @@ describe('blocks', () => {
it('should get block given its number', async () => {
const correctBlock = await web3.eth.getBlock(0)
const numberTransactions = await (new Promise((resolve, reject) => {
web3._requestManager.send({method: 'eth_getUncleCountByBlockHash', params: [0]}, (err, numberTransactions) => {
web3['_requestManager'].send({method: 'eth_getUncleCountByBlockHash', params: [0]}, (err, numberTransactions) => {
if (err) return reject(err)
resolve(numberTransactions)
})
@ -116,7 +116,7 @@ describe('blocks', () => {
describe('eth_getStorageAt', () => {
it('should get storage at position at given address', async () => {
const abi = [
const abi: any = [
{
'constant': false,
'inputs': [
@ -203,7 +203,7 @@ describe('blocks', () => {
const contract = new web3.eth.Contract(abi)
const accounts = await web3.eth.getAccounts()
const contractInstance = await contract.deploy({ data: code, arguments: [100] }).send({ from: accounts[0], gas: 400000 })
const contractInstance: any = await contract.deploy({ data: code, arguments: [100] }).send({ from: accounts[0], gas: 400000 })
contractInstance.currentProvider = web3.eth.currentProvider
contractInstance.givenProvider = web3.eth.currentProvider
@ -223,7 +223,7 @@ describe('blocks', () => {
describe('eth_call', () => {
it('should get a value', async () => {
const abi = [
const abi: any = [
{
'constant': false,
'inputs': [
@ -310,7 +310,7 @@ describe('blocks', () => {
const contract = new web3.eth.Contract(abi)
const accounts = await web3.eth.getAccounts()
const contractInstance = await contract.deploy({ data: code, arguments: [100] }).send({ from: accounts[0], gas: 400000 })
const contractInstance: any = await contract.deploy({ data: code, arguments: [100] }).send({ from: accounts[0], gas: 400000 })
contractInstance.currentProvider = web3.eth.currentProvider
contractInstance.givenProvider = web3.eth.currentProvider

@ -1,18 +1,18 @@
/* global describe, before, it */
const Web3 = require('web3')
const RemixSim = require('../index.js')
import Web3 from 'web3'
import RemixSim from '../src/index'
const web3 = new Web3()
const assert = require('assert')
import * as assert from 'assert'
describe('Misc', () => {
before(() => {
const provider = new RemixSim.Provider()
const provider: any = new RemixSim.Provider()
web3.setProvider(provider)
})
describe('web3_clientVersion', () => {
it('should get correct remix simulator version', async (done) => {
web3._requestManager.send({ method: 'web3_clientVersion', params: [] }, (err, version) => {
web3['_requestManager'].send({ method: 'web3_clientVersion', params: [] }, (err, version) => {
if (err) {
throw new Error(err)
}
@ -25,7 +25,7 @@ describe('Misc', () => {
describe('eth_protocolVersion', () => {
it('should get protocol version', async () => {
web3._requestManager.send({ method: 'eth_protocolVersion', params: [] }, (err, result) => {
web3['_requestManager'].send({ method: 'eth_protocolVersion', params: [] }, (err, result) => {
if (err) {
throw new Error(err)
}
@ -57,7 +57,7 @@ describe('Misc', () => {
describe('web3_sha3', () => {
it('should get result of a sha3', async () => {
web3._requestManager.send({ method: 'web3_sha3', params: ['0x68656c6c6f20776f726c64'] }, (err, result) => {
web3['_requestManager'].send({ method: 'web3_sha3', params: ['0x68656c6c6f20776f726c64'] }, (err, result) => {
if (err) {
throw new Error(err)
}
@ -68,7 +68,7 @@ describe('Misc', () => {
describe('eth_getCompilers', () => {
it('should get list of compilers', async () => {
web3._requestManager.send({ method: 'eth_getCompilers', params: [] }, (err, result) => {
web3['_requestManager'].send({ method: 'eth_getCompilers', params: [] }, (err, result) => {
if (err) {
throw new Error(err)
}
@ -79,7 +79,7 @@ describe('Misc', () => {
describe('eth_compileSolidity', () => {
it('get unsupported result when requesting solidity compiler', async () => {
web3._requestManager.send({ method: 'eth_compileSolidity', params: [] }, (err, result) => {
web3['_requestManager'].send({ method: 'eth_compileSolidity', params: [] }, (err, result) => {
if (err) {
throw new Error(err)
}
@ -90,7 +90,7 @@ describe('Misc', () => {
describe('eth_compileLLL', () => {
it('get unsupported result when requesting LLL compiler', async () => {
web3._requestManager.send({ method: 'eth_compileLLL', params: [] }, (err, result) => {
web3['_requestManager'].send({ method: 'eth_compileLLL', params: [] }, (err, result) => {
if (err) {
throw new Error(err)
}
@ -101,7 +101,7 @@ describe('Misc', () => {
describe('eth_compileSerpent', () => {
it('get unsupported result when requesting serpent compiler', async () => {
web3._requestManager.send({ method: 'eth_compileSerpent', params: [] }, (err, result) => {
web3['_requestManager'].send({ method: 'eth_compileSerpent', params: [] }, (err, result) => {
if (err) {
throw new Error(err)
}

@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"types": ["node"]
"types": ["node", "mocha"],
"esModuleInterop": true
},
"include": ["**/*.ts"]
}

@ -5,7 +5,7 @@
"outDir": "../../dist/out-tsc",
"declaration": true,
"rootDir": "./src",
"types": ["node"]
"types": ["node", "mocha"]
},
"exclude": [
"**/*.spec.ts",

Loading…
Cancel
Save