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

assertion events moved to separate file

parent d46a6fe3
const assertionEvents = [
{
name: 'AssertionEvent',
params: ['bool', 'string']
},
{
name: 'AssertionEventUint',
params: ['bool', 'string', 'uint256', 'uint256']
}
]
export default assertionEvents
\ No newline at end of file
import async from 'async' import async from 'async'
import * as changeCase from 'change-case' import * as changeCase from 'change-case'
import Web3 from 'web3'; import Web3 from 'web3';
import assertionEvents from './assertionEvents'
import { RunListInterface, TestCbInterface, TestResultInterface, ResultCbInterface, import { RunListInterface, TestCbInterface, TestResultInterface, ResultCbInterface,
CompiledContract, AstNode, Options, FunctionDescription, UserDocumentation } from './types' CompiledContract, AstNode, Options, FunctionDescription, UserDocumentation } from './types'
...@@ -228,19 +229,8 @@ export function runTest (testName: string, testObject: any, contractDetails: Com ...@@ -228,19 +229,8 @@ export function runTest (testName: string, testObject: any, contractDetails: Com
method.send(sendParams).on('receipt', (receipt) => { method.send(sendParams).on('receipt', (receipt) => {
try { try {
const time: number = (Date.now() - startTime) / 1000.0 const time: number = (Date.now() - startTime) / 1000.0
const assertionEvents = [
{
name: 'AssertionEvent',
params: ['bool', 'string']
},
{
name: 'AssertionEventUint',
params: ['bool', 'string', 'uint256', 'uint256']
}
]
const assertionEventHashes = assertionEvents.map(e => Web3.utils.sha3(e.name + '(' + e.params.join() + ')') ) const assertionEventHashes = assertionEvents.map(e => Web3.utils.sha3(e.name + '(' + e.params.join() + ')') )
let testPassed = false let testPassed = false
for (const i in receipt.events) { for (const i in receipt.events) {
const event = receipt.events[i] const event = receipt.events[i]
const eIndex = assertionEventHashes.indexOf(event.raw.topics[0]) // event name topic will always be at index 0 const eIndex = assertionEventHashes.indexOf(event.raw.topics[0]) // event name topic will always be at index 0
......
import "remix_tests.sol"; // this import is automatically injected by Remix. import "remix_tests.sol"; // this import is automatically injected by Remix.
contract AssertLesserThanTest { contract AssertLesserThanTest {
......
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