remix-lib tests working fine

toaster-react
aniket-engg 4 years ago committed by Aniket
parent 8b521cefbb
commit a5aa8cdca3
  1. 2
      libs/remix-lib/src/execution/execution-context.ts
  2. 16
      libs/remix-lib/test/eventManager.ts
  3. 10
      libs/remix-lib/test/tests.ts
  4. 21
      libs/remix-lib/test/txFormat.ts
  5. 4
      libs/remix-lib/test/txHelper.ts
  6. 7
      libs/remix-lib/test/txResultHelper.ts
  7. 4
      libs/remix-lib/test/util.ts
  8. 14
      workspace.json

@ -7,7 +7,7 @@ import { Web3VmProvider } from '../web3Provider/web3VmProvider'
const EthJSVM = require('ethereumjs-vm').default const EthJSVM = require('ethereumjs-vm').default
const StateManager = require('ethereumjs-vm/dist/state/stateManager').default const StateManager = require('ethereumjs-vm/dist/state/stateManager').default
const LogsManager = require('./logsManager.js') import { LogsManager } from './logsManager'
declare let ethereum: any declare let ethereum: any
let web3 let web3

@ -1,33 +1,33 @@
'use strict' 'use strict'
const tape = require('tape') import tape from 'tape'
const EventManager = require('../src/eventManager') import { EventManager } from '../src/eventManager'
tape('eventManager', function (t) { tape('eventManager', function (t) {
t.test('eventManager', function (st) { t.test('eventManager', function (st) {
const events = new EventManager() const events = new EventManager()
const listenner = {} const listenner = {}
let trace = '' let trace = ''
listenner.listen = function (data1) { listenner['listen'] = function (data1) {
trace += data1 trace += data1
} }
const registeredFunction = function (data) { const registeredFunction = function (data) {
trace += data trace += data
} }
events.register('event1', listenner, listenner.listen) events.register('event1', listenner, listenner['listen'])
events.register('event2', registeredFunction) events.register('event2', registeredFunction, null)
events.trigger('event1', ['event1']) events.trigger('event1', ['event1'])
events.trigger('event2', ['event2']) events.trigger('event2', ['event2'])
st.equal(trace, 'event1event2') st.equal(trace, 'event1event2')
events.unregister('event1', listenner.listen) events.unregister('event1', listenner['listen'], null)
st.equal(events.registered['event1'].length, 1) st.equal(events.registered['event1'].length, 1)
st.equal(events.registered['event2'].length, 1) st.equal(events.registered['event2'].length, 1)
events.unregister('event1', listenner, listenner.listen) events.unregister('event1', listenner, listenner['listen'])
st.equal(events.registered['event1'].length, 0) st.equal(events.registered['event1'].length, 0)
st.equal(events.registered['event2'].length, 1) st.equal(events.registered['event2'].length, 1)
events.unregister('event2', registeredFunction) events.unregister('event2', registeredFunction, null)
st.equal(events.registered['event1'].length, 0) st.equal(events.registered['event1'].length, 0)
st.equal(events.registered['event2'].length, 0) st.equal(events.registered['event2'].length, 0)
st.end() st.end()

@ -1,5 +1,5 @@
require('./eventManager.js') require('./eventManager.ts')
require('./util.js') require('./util.ts')
require('./txFormat.js') require('./txFormat.ts')
require('./txHelper.js') require('./txHelper.ts')
require('./txResultHelper.js') require('./txResultHelper.ts')

@ -1,11 +1,12 @@
'use strict' 'use strict'
import * as tape from 'tape' import tape from 'tape'
const txFormat = require('../src/execution/txFormat') import * as txFormat from '../src/execution/txFormat'
const txHelper = require('../src/execution/txHelper') import * as txHelper from '../src/execution/txHelper'
const util = require('../src/util') import { hexToIntArray } from '../src/util'
let compiler = require('solc') let compiler = require('solc')
const compilerInput = require('../src/helpers/compilerHelper').compilerInput import { compilerInput } from '../src/helpers/compilerHelper'
const executionContext = require('../').execution.executionContext import { ExecutionContext } from '../src/execution/execution-context'
const executionContext = new ExecutionContext()
const solidityVersion = 'v0.6.0+commit.26b70077' const solidityVersion = 'v0.6.0+commit.26b70077'
/* tape *********************************************************** */ /* tape *********************************************************** */
@ -150,7 +151,7 @@ function testInvalidTupleInput (st, params) {
/* tape *********************************************************** */ /* tape *********************************************************** */
tape('ContractParameters - (TxFormat.buildData) - link Libraries', function (t) { tape('ContractParameters - (TxFormat.buildData) - link Libraries', function (t) {
executionContext.setContext('vm') executionContext.setContext('vm', null, null, null)
const compileData = compiler.compile(compilerInput(deploySimpleLib)) const compileData = compiler.compile(compilerInput(deploySimpleLib))
const fakeDeployedContracts = { const fakeDeployedContracts = {
@ -293,7 +294,7 @@ tape('test abiEncoderV2', function (t) {
console.log(error) console.log(error)
st.equal(encoded.dataHex, functionId + encodedData.replace('0x', '')) st.equal(encoded.dataHex, functionId + encodedData.replace('0x', ''))
}) })
let decoded = txFormat.decodeResponse(util.hexToIntArray(encodedData), contract.abi[0]) let decoded = txFormat.decodeResponse(hexToIntArray(encodedData), contract.abi[0])
console.log(decoded) console.log(decoded)
st.equal(decoded[0], `tuple(uint256,uint256,string): ${value1},${value2},${value3}`) st.equal(decoded[0], `tuple(uint256,uint256,string): ${value1},${value2},${value3}`)
}) })
@ -314,14 +315,14 @@ tape('test abiEncoderV2 array of tuple', function (t) {
const contract = output.contracts['test.sol']['test'] const contract = output.contracts['test.sol']['test']
txFormat.encodeParams('[34, "test"]', contract.abi[1], (error, encoded) => { txFormat.encodeParams('[34, "test"]', contract.abi[1], (error, encoded) => {
console.log(error) console.log(error)
const decoded = txFormat.decodeResponse(util.hexToIntArray(encoded.dataHex), contract.abi[1]) const decoded = txFormat.decodeResponse(hexToIntArray(encoded.dataHex), contract.abi[1])
console.log(decoded) console.log(decoded)
st.equal(decoded[0], 'tuple(uint256,string): _strucmts 34,test') st.equal(decoded[0], 'tuple(uint256,string): _strucmts 34,test')
}) })
txFormat.encodeParams('[[34, "test"], [123, "test2"]]', contract.abi[2], (error, encoded) => { txFormat.encodeParams('[[34, "test"], [123, "test2"]]', contract.abi[2], (error, encoded) => {
console.log(error) console.log(error)
const decoded = txFormat.decodeResponse(util.hexToIntArray(encoded.dataHex), contract.abi[2]) const decoded = txFormat.decodeResponse(hexToIntArray(encoded.dataHex), contract.abi[2])
console.log(decoded) console.log(decoded)
st.equal(decoded[0], 'tuple(uint256,string)[]: strucmts 34,test,123,test2') st.equal(decoded[0], 'tuple(uint256,string)[]: strucmts 34,test,123,test2')
}) })

@ -1,6 +1,6 @@
'use strict' 'use strict'
const tape = require('tape') import tape from 'tape'
const txHelper = require('../src/execution/txHelper') import * as txHelper from '../src/execution/txHelper'
tape('getFunction', function (st) { tape('getFunction', function (st) {
st.plan(6) st.plan(6)

@ -1,9 +1,8 @@
'use strict' 'use strict'
const tape = require('tape') import tape from 'tape'
const { BN, toBuffer } = require('ethereumjs-util') import { BN, toBuffer } from 'ethereumjs-util'
import { resultToRemixTx } from '../src/helpers/txResultHelper'
const { resultToRemixTx } = require('../src/helpers/txResultHelper')
const TRANSACTION_HASH = '0x538ad944d09c2df403f064c1e4556fae877fe3f1b600c567622e330c2bdbbe2e' const TRANSACTION_HASH = '0x538ad944d09c2df403f064c1e4556fae877fe3f1b600c567622e330c2bdbbe2e'
const CONTRACT_ADDRESS_HEX = '0x692a70d2e424a56d2c6c27aa97d1a86395877b3a' const CONTRACT_ADDRESS_HEX = '0x692a70d2e424a56d2c6c27aa97d1a86395877b3a'

@ -1,6 +1,6 @@
'use strict' 'use strict'
const tape = require('tape') import tape from 'tape'
const util = require('../src/util') import * as util from '../src/util'
tape('Util', function (t) { tape('Util', function (t) {
t.test('lowerbound', function (st) { t.test('lowerbound', function (st) {

@ -128,7 +128,7 @@
"test": { "test": {
"builder": "@nrwl/workspace:run-commands", "builder": "@nrwl/workspace:run-commands",
"options": { "options": {
"commands": ["npm-run-all test"], "commands": ["./../../node_modules/.bin/npm-run-all test"],
"cwd": "libs/remix-analyzer" "cwd": "libs/remix-analyzer"
} }
}, },
@ -162,7 +162,7 @@
"test": { "test": {
"builder": "@nrwl/workspace:run-commands", "builder": "@nrwl/workspace:run-commands",
"options": { "options": {
"commands": ["npm-run-all test"], "commands": ["./../../node_modules/.bin/npm-run-all test"],
"cwd": "libs/remix-astwalker" "cwd": "libs/remix-astwalker"
} }
}, },
@ -196,7 +196,7 @@
"test": { "test": {
"builder": "@nrwl/workspace:run-commands", "builder": "@nrwl/workspace:run-commands",
"options": { "options": {
"commands": ["npm-run-all test"], "commands": ["./../../node_modules/.bin/npm-run-all test"],
"cwd": "libs/remix-debug" "cwd": "libs/remix-debug"
} }
}, },
@ -241,7 +241,7 @@
"test": { "test": {
"builder": "@nrwl/workspace:run-commands", "builder": "@nrwl/workspace:run-commands",
"options": { "options": {
"commands": ["npm-run-all test"], "commands": ["./../../node_modules/.bin/npm-run-all test"],
"cwd": "libs/remix-lib" "cwd": "libs/remix-lib"
} }
}, },
@ -275,7 +275,7 @@
"test": { "test": {
"builder": "@nrwl/workspace:run-commands", "builder": "@nrwl/workspace:run-commands",
"options": { "options": {
"commands": ["npm-run-all test"], "commands": ["./../../node_modules/.bin/npm-run-all test"],
"cwd": "libs/remix-simulator" "cwd": "libs/remix-simulator"
} }
}, },
@ -320,7 +320,7 @@
"test": { "test": {
"builder": "@nrwl/workspace:run-commands", "builder": "@nrwl/workspace:run-commands",
"options": { "options": {
"commands": ["npm-run-all test"], "commands": ["./../../node_modules/.bin/npm-run-all test"],
"cwd": "libs/remix-solidity" "cwd": "libs/remix-solidity"
} }
}, },
@ -402,7 +402,7 @@
"test": { "test": {
"builder": "@nrwl/workspace:run-commands", "builder": "@nrwl/workspace:run-commands",
"options": { "options": {
"commands": ["npm-run-all test"], "commands": ["./../../node_modules/.bin/npm-run-all test"],
"cwd": "libs/remix-url-resolver" "cwd": "libs/remix-url-resolver"
} }
}, },

Loading…
Cancel
Save