Commit aff251ee authored by aniket-engg's avatar aniket-engg Committed by Aniket

test passing

parent 63512c83
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
"mocha": "^5.2.0" "mocha": "^5.2.0"
}, },
"scripts": { "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": { "publishConfig": {
"access": "public" "access": "public"
......
import EthJSBlock from 'ethereumjs-block' import EthJSBlock from 'ethereumjs-block'
import { BN } from 'ethereumjs-util' import { BN } from 'ethereumjs-util'
function generateBlock (executionContext) { export function generateBlock (executionContext) {
const block = new EthJSBlock({ const block = new EthJSBlock({
header: { header: {
timestamp: (new Date().getTime() / 1000 | 0), timestamp: (new Date().getTime() / 1000 | 0),
...@@ -19,4 +19,3 @@ function generateBlock (executionContext) { ...@@ -19,4 +19,3 @@ function generateBlock (executionContext) {
}) })
} }
module.exports = generateBlock
import { Provider } from './provider' import { Provider } from './provider'
export { Provider } export default { Provider }
...@@ -9,11 +9,10 @@ import merge from 'merge' ...@@ -9,11 +9,10 @@ import merge from 'merge'
import { Accounts } from './methods/accounts' import { Accounts } from './methods/accounts'
import { Filters } from './methods/filters' import { Filters } from './methods/filters'
import { Misc } from './methods/misc' import { Misc } from './methods/misc'
import { Net } from './methods/net.js' import { Net } from './methods/net'
import { Transactions } from './methods/transactions.js' import { Transactions } from './methods/transactions'
import { Debug } from './methods/debug.js' import { Debug } from './methods/debug'
import { generateBlock } from './genesis'
const generateBlock = require('./genesis.js')
export class Provider { export class Provider {
options options
......
/* global describe, before, it */ /* global describe, before, it */
const Web3 = require('web3') import Web3 from 'web3'
const RemixSim = require('../index.js') import RemixSim from '../src/index'
const web3 = new Web3() const web3 = new Web3()
const assert = require('assert') import * as assert from 'assert'
describe('Accounts', () => { describe('Accounts', () => {
before(function () { before(function () {
const provider = new RemixSim.Provider() const provider: any = new RemixSim.Provider()
web3.setProvider(provider) web3.setProvider(provider)
}) })
......
/* global describe, before, it */ /* global describe, before, it */
const Web3 = require('web3') import Web3 from 'web3'
const RemixSim = require('../index.js') import RemixSim from '../src/index'
const web3 = new Web3() const web3 = new Web3()
const assert = require('assert') import * as assert from 'assert'
describe('blocks', () => { describe('blocks', () => {
before(() => { before(() => {
const provider = new RemixSim.Provider({ const provider: any = new RemixSim.Provider({
coinbase: '0x0000000000000000000000000000000000000001' coinbase: '0x0000000000000000000000000000000000000001'
}) })
web3.setProvider(provider) web3.setProvider(provider)
...@@ -21,7 +21,7 @@ describe('blocks', () => { ...@@ -21,7 +21,7 @@ describe('blocks', () => {
extraData: '0x0', extraData: '0x0',
gasLimit: 8000000, gasLimit: 8000000,
gasUsed: 0, gasUsed: 0,
hash: block.hash.toString('hex'), hash: block.hash.toString(),
logsBloom: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331', logsBloom: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331',
miner: '0x0000000000000000000000000000000000000001', miner: '0x0000000000000000000000000000000000000001',
nonce: '0x0000000000000000', nonce: '0x0000000000000000',
...@@ -92,7 +92,7 @@ describe('blocks', () => { ...@@ -92,7 +92,7 @@ describe('blocks', () => {
it('should get block given its hash', async () => { it('should get block given its hash', async () => {
const correctBlock = await web3.eth.getBlock(0) const correctBlock = await web3.eth.getBlock(0)
const numberTransactions = await (new Promise((resolve, reject) => { 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) if (err) return reject(err)
resolve(numberTransactions) resolve(numberTransactions)
}) })
...@@ -105,7 +105,7 @@ describe('blocks', () => { ...@@ -105,7 +105,7 @@ describe('blocks', () => {
it('should get block given its number', async () => { it('should get block given its number', async () => {
const correctBlock = await web3.eth.getBlock(0) const correctBlock = await web3.eth.getBlock(0)
const numberTransactions = await (new Promise((resolve, reject) => { 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) if (err) return reject(err)
resolve(numberTransactions) resolve(numberTransactions)
}) })
...@@ -116,7 +116,7 @@ describe('blocks', () => { ...@@ -116,7 +116,7 @@ describe('blocks', () => {
describe('eth_getStorageAt', () => { describe('eth_getStorageAt', () => {
it('should get storage at position at given address', async () => { it('should get storage at position at given address', async () => {
const abi = [ const abi: any = [
{ {
'constant': false, 'constant': false,
'inputs': [ 'inputs': [
...@@ -203,7 +203,7 @@ describe('blocks', () => { ...@@ -203,7 +203,7 @@ describe('blocks', () => {
const contract = new web3.eth.Contract(abi) const contract = new web3.eth.Contract(abi)
const accounts = await web3.eth.getAccounts() 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.currentProvider = web3.eth.currentProvider
contractInstance.givenProvider = web3.eth.currentProvider contractInstance.givenProvider = web3.eth.currentProvider
...@@ -223,7 +223,7 @@ describe('blocks', () => { ...@@ -223,7 +223,7 @@ describe('blocks', () => {
describe('eth_call', () => { describe('eth_call', () => {
it('should get a value', async () => { it('should get a value', async () => {
const abi = [ const abi: any = [
{ {
'constant': false, 'constant': false,
'inputs': [ 'inputs': [
...@@ -310,7 +310,7 @@ describe('blocks', () => { ...@@ -310,7 +310,7 @@ describe('blocks', () => {
const contract = new web3.eth.Contract(abi) const contract = new web3.eth.Contract(abi)
const accounts = await web3.eth.getAccounts() 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.currentProvider = web3.eth.currentProvider
contractInstance.givenProvider = web3.eth.currentProvider contractInstance.givenProvider = web3.eth.currentProvider
......
/* global describe, before, it */ /* global describe, before, it */
const Web3 = require('web3') import Web3 from 'web3'
const RemixSim = require('../index.js') import RemixSim from '../src/index'
const web3 = new Web3() const web3 = new Web3()
const assert = require('assert') import * as assert from 'assert'
describe('Misc', () => { describe('Misc', () => {
before(() => { before(() => {
const provider = new RemixSim.Provider() const provider: any = new RemixSim.Provider()
web3.setProvider(provider) web3.setProvider(provider)
}) })
describe('web3_clientVersion', () => { describe('web3_clientVersion', () => {
it('should get correct remix simulator version', async (done) => { 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) { if (err) {
throw new Error(err) throw new Error(err)
} }
...@@ -25,7 +25,7 @@ describe('Misc', () => { ...@@ -25,7 +25,7 @@ describe('Misc', () => {
describe('eth_protocolVersion', () => { describe('eth_protocolVersion', () => {
it('should get protocol version', async () => { 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) { if (err) {
throw new Error(err) throw new Error(err)
} }
...@@ -57,7 +57,7 @@ describe('Misc', () => { ...@@ -57,7 +57,7 @@ describe('Misc', () => {
describe('web3_sha3', () => { describe('web3_sha3', () => {
it('should get result of a sha3', async () => { 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) { if (err) {
throw new Error(err) throw new Error(err)
} }
...@@ -68,7 +68,7 @@ describe('Misc', () => { ...@@ -68,7 +68,7 @@ describe('Misc', () => {
describe('eth_getCompilers', () => { describe('eth_getCompilers', () => {
it('should get list of compilers', async () => { 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) { if (err) {
throw new Error(err) throw new Error(err)
} }
...@@ -79,7 +79,7 @@ describe('Misc', () => { ...@@ -79,7 +79,7 @@ describe('Misc', () => {
describe('eth_compileSolidity', () => { describe('eth_compileSolidity', () => {
it('get unsupported result when requesting solidity compiler', async () => { 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) { if (err) {
throw new Error(err) throw new Error(err)
} }
...@@ -90,7 +90,7 @@ describe('Misc', () => { ...@@ -90,7 +90,7 @@ describe('Misc', () => {
describe('eth_compileLLL', () => { describe('eth_compileLLL', () => {
it('get unsupported result when requesting LLL compiler', async () => { 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) { if (err) {
throw new Error(err) throw new Error(err)
} }
...@@ -101,7 +101,7 @@ describe('Misc', () => { ...@@ -101,7 +101,7 @@ describe('Misc', () => {
describe('eth_compileSerpent', () => { describe('eth_compileSerpent', () => {
it('get unsupported result when requesting serpent compiler', async () => { 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) { if (err) {
throw new Error(err) throw new Error(err)
} }
......
{ {
"extends": "../../tsconfig.json", "extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"types": ["node"] "types": ["node", "mocha"],
"esModuleInterop": true
}, },
"include": ["**/*.ts"] "include": ["**/*.ts"]
} }
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"outDir": "../../dist/out-tsc", "outDir": "../../dist/out-tsc",
"declaration": true, "declaration": true,
"rootDir": "./src", "rootDir": "./src",
"types": ["node"] "types": ["node", "mocha"]
}, },
"exclude": [ "exclude": [
"**/*.spec.ts", "**/*.spec.ts",
......
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