Merge pull request #1409 from ethereum/fix/#958

Json interface unavailability handled
pull/5370/head
yann300 5 years ago committed by GitHub
commit ccfdf50dff
  1. 13
      remix-tests/src/testRunner.ts
  2. 26
      remix-tests/tests/testRunner.ts

@ -136,12 +136,15 @@ function createRunList (jsonInterface: FunctionDescription[], fileAST: AstNode,
} }
export function runTest (testName: string, testObject: any, contractDetails: CompiledContract, fileAST: AstNode, opts: Options, testCallback: TestCbInterface, resultsCallback: ResultCbInterface): void { export function runTest (testName: string, testObject: any, contractDetails: CompiledContract, fileAST: AstNode, opts: Options, testCallback: TestCbInterface, resultsCallback: ResultCbInterface): void {
const runList: RunListInterface[] = createRunList(testObject._jsonInterface, fileAST, testName)
let passingNum: number = 0 let passingNum: number = 0
let failureNum: number = 0 let failureNum: number = 0
let timePassed: number = 0 let timePassed: number = 0
const web3 = new Web3() const isJSONInterfaceAvailable = testObject && testObject.options && testObject.options.jsonInterface
if(!isJSONInterfaceAvailable)
return resultsCallback(new Error('Contract interface not available'), { passingNum, failureNum, timePassed })
const runList: RunListInterface[] = createRunList(testObject.options.jsonInterface, fileAST, testName)
const web3 = new Web3()
const accts: TestResultInterface = { const accts: TestResultInterface = {
type: 'accountList', type: 'accountList',
value: opts.accounts value: opts.accounts
@ -260,10 +263,6 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
}) })
} }
}, function(error) { }, function(error) {
resultsCallback(error, { resultsCallback(error, { passingNum, failureNum, timePassed })
passingNum: passingNum,
failureNum: failureNum,
timePassed: timePassed
})
}) })
} }

@ -253,5 +253,31 @@ describe('testRunner', () => {
assert.equal(results.failureNum, 0) assert.equal(results.failureNum, 0)
}) })
}) })
// Test `runTest` method without sending contract object (should throw error)
describe('runTest method without contract json interface', function () {
const filename: string = 'tests/various_sender/sender_and_value_test.sol'
const errorCallback: Function = (done) => {
return (err, _results) => {
if (err && err.message.includes('Contract interface not available')) {
results = _results
done()
}
else throw err
}
}
before(function (done) {
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: object, contracts: any, asts: any, accounts: string[]) {
runTest('SenderAndValueTest', undefined, compilationData[filename]['SenderAndValueTest'], asts[filename], { accounts }, testCallback, errorCallback(done))
})
})
it('should have 0 passing tests', function () {
assert.equal(results.passingNum, 0)
})
it('should have 0 failing tests', function () {
assert.equal(results.failureNum, 0)
})
})
}) })
}) })

Loading…
Cancel
Save