|
1 | 1 | import async from 'async' |
2 | 2 | import * as changeCase from 'change-case' |
3 | | -import {keccak256, AbiCoder, ContractTransactionResponse, toUtf8Bytes } from 'ethers' |
| 3 | +import {keccak256, AbiCoder, ContractTransactionResponse, toUtf8Bytes, Interface } from 'ethers' |
4 | 4 | import assertionEvents from './assertionEvents' |
5 | 5 | import { |
6 | 6 | RunListInterface, TestCbInterface, TestResultInterface, ResultCbInterface, |
@@ -183,28 +183,29 @@ function createRunList (jsonInterface: FunctionDescription[], fileAST: AstNode, |
183 | 183 | const availableFunctions: string[] = getAvailableFunctions(fileAST, testContractName) |
184 | 184 | const testFunctionsInterface: FunctionDescription[] = getTestFunctionsInterface(jsonInterface, availableFunctions) |
185 | 185 | const specialFunctionsInterface: Record<string, FunctionDescription> = getSpecialFunctionsInterface(jsonInterface) |
| 186 | + const contractInterface: Interface = new Interface(jsonInterface) |
186 | 187 | const runList: RunListInterface[] = [] |
187 | 188 |
|
188 | 189 | if (availableFunctions.includes('beforeAll')) { |
189 | 190 | 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) }) |
191 | 192 | } |
192 | 193 |
|
193 | 194 | for (const func of testFunctionsInterface) { |
194 | 195 | if (availableFunctions.includes('beforeEach')) { |
195 | 196 | 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) }) |
197 | 198 | } |
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) }) |
199 | 200 | if (availableFunctions.indexOf('afterEach') >= 0) { |
200 | 201 | 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) }) |
202 | 203 | } |
203 | 204 | } |
204 | 205 |
|
205 | 206 | if (availableFunctions.indexOf('afterAll') >= 0) { |
206 | 207 | 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) }) |
208 | 209 | } |
209 | 210 |
|
210 | 211 | return runList |
|
0 commit comments