Skip to content

Commit 29904e0

Browse files
committed
fix signature retreival
1 parent 40b9311 commit 29904e0

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

libs/remix-tests/src/testRunner.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import async from 'async'
22
import * as changeCase from 'change-case'
3-
import {keccak256, AbiCoder, ContractTransactionResponse, toUtf8Bytes } from 'ethers'
3+
import {keccak256, AbiCoder, ContractTransactionResponse, toUtf8Bytes, Interface } from 'ethers'
44
import assertionEvents from './assertionEvents'
55
import {
66
RunListInterface, TestCbInterface, TestResultInterface, ResultCbInterface,
@@ -183,28 +183,29 @@ function createRunList (jsonInterface: FunctionDescription[], fileAST: AstNode,
183183
const availableFunctions: string[] = getAvailableFunctions(fileAST, testContractName)
184184
const testFunctionsInterface: FunctionDescription[] = getTestFunctionsInterface(jsonInterface, availableFunctions)
185185
const specialFunctionsInterface: Record<string, FunctionDescription> = getSpecialFunctionsInterface(jsonInterface)
186+
const contractInterface: Interface = new Interface(jsonInterface)
186187
const runList: RunListInterface[] = []
187188

188189
if (availableFunctions.includes('beforeAll')) {
189190
const func = specialFunctionsInterface['beforeAll']
190-
runList.push({ name: 'beforeAll', inputs: func.inputs, signature: func.signature, type: 'internal', constant: isConstant(func), payable: isPayable(func) })
191+
runList.push({ name: 'beforeAll', inputs: func.inputs, signature: contractInterface.getFunction(func.name).selector, type: 'internal', constant: isConstant(func), payable: isPayable(func) })
191192
}
192193

193194
for (const func of testFunctionsInterface) {
194195
if (availableFunctions.includes('beforeEach')) {
195196
const func = specialFunctionsInterface['beforeEach']
196-
runList.push({ name: 'beforeEach', inputs: func.inputs, signature: func.signature, type: 'internal', constant: isConstant(func), payable: isPayable(func) })
197+
runList.push({ name: 'beforeEach', inputs: func.inputs, signature: contractInterface.getFunction(func.name).selector, type: 'internal', constant: isConstant(func), payable: isPayable(func) })
197198
}
198-
if (func.name && func.inputs) runList.push({ name: func.name, inputs: func.inputs, signature: func.signature, type: 'test', constant: isConstant(func), payable: isPayable(func) })
199+
if (func.name && func.inputs) runList.push({ name: func.name, inputs: func.inputs, signature: contractInterface.getFunction(func.name).selector, type: 'test', constant: isConstant(func), payable: isPayable(func) })
199200
if (availableFunctions.indexOf('afterEach') >= 0) {
200201
const func = specialFunctionsInterface['afterEach']
201-
runList.push({ name: 'afterEach', inputs: func.inputs, signature: func.signature, type: 'internal', constant: isConstant(func), payable: isPayable(func) })
202+
runList.push({ name: 'afterEach', inputs: func.inputs, signature: contractInterface.getFunction(func.name).selector, type: 'internal', constant: isConstant(func), payable: isPayable(func) })
202203
}
203204
}
204205

205206
if (availableFunctions.indexOf('afterAll') >= 0) {
206207
const func = specialFunctionsInterface['afterAll']
207-
runList.push({ name: 'afterAll', inputs: func.inputs, signature: func.signature, type: 'internal', constant: isConstant(func), payable: isPayable(func) })
208+
runList.push({ name: 'afterAll', inputs: func.inputs, signature: contractInterface.getFunction(func.name).selector, type: 'internal', constant: isConstant(func), payable: isPayable(func) })
208209
}
209210

210211
return runList

libs/remix-tests/tests/testRunner.spec.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -433,24 +433,24 @@ describe('testRunner', function () {
433433
})
434434

435435
// Test Transaction with custom sender & value
436-
// describe('various sender', function () {
437-
// const filename: string = __dirname + '/various_sender/sender_and_value_test.sol'
436+
describe('various sender', function () {
437+
const filename: string = __dirname + '/various_sender/sender_and_value_test.sol'
438438

439-
// before(done => {
440-
// compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: any, contracts: any, asts: any, accounts: string[], provider: any) {
441-
// runTest('SenderAndValueTest', contracts.SenderAndValueTest, compilationData[filename]['SenderAndValueTest'], asts[filename], { accounts, provider }, testCallback, resultsCallback(done))
442-
// })
443-
// })
439+
before(done => {
440+
compileAndDeploy(filename, function (_err: Error | null | undefined, compilationData: any, contracts: any, asts: any, accounts: string[], provider: any) {
441+
runTest('SenderAndValueTest', contracts.SenderAndValueTest, compilationData[filename]['SenderAndValueTest'], asts[filename], { accounts, provider }, testCallback, resultsCallback(done))
442+
})
443+
})
444444

445-
// after(() => { tests = [] })
445+
after(() => { tests = [] })
446446

447-
// it('should have 17 passing tests', () => {
448-
// assert.equal(results.passingNum, 17)
449-
// })
450-
// it('should have 0 failing tests', () => {
451-
// assert.equal(results.failureNum, 0)
452-
// })
453-
// })
447+
it('should have 17 passing tests', () => {
448+
assert.equal(results.passingNum, 17)
449+
})
450+
it('should have 0 failing tests', () => {
451+
assert.equal(results.failureNum, 0)
452+
})
453+
})
454454

455455
// Test `runTest` method without sending contract object (should throw error)
456456
// describe('runTest method without contract json interface', function () {

0 commit comments

Comments
 (0)