import "mocha" ; import { assert } from "chai" ; import { repoData , rpc , generateBlock , assertThrow } from "./test" ; import { ContractsRepo } from "./ContractsRepo" ; import { IContractInfo } from "./Contract" ; describe ( "EventListener" , ( ) => { const repo = new ContractsRepo ( rpc , repoData ) ; describe ( "#onLog" , ( ) => { const contract = repo . contract ( "test/contracts/Logs.sol" ) ; const listener = repo . eventListener ( ) ; it ( "can receive a log using callback" , ( done ) => { contract . send ( "emitFooEvent" , [ "test!" ] ) ; const cancelOnLog = listener . onLog ( ( entry ) => { const fooEvent = entry . event ! ; assert . deepEqual ( fooEvent , { a : "test!" , type : "FooEvent" } ) ; cancelOnLog ( ) ; done ( ) ; } , { minconf : 0 } ) ; generateBlock ( ) ; } ) ; } ) ; describe ( "#onLog" , ( ) => { const contract = repo . contract ( "test/contracts/Logs.sol" ) ; const listener = repo . eventListener ( ) ; it ( "can receive a log using callback" , ( done ) => { contract . send ( "emitFooEvent" , [ "test!" ] ) ; const cancelOnLog = listener . onLog ( ( entry ) => { const fooEvent = entry . event ! ; assert . deepEqual ( fooEvent , { a : "test!" , type : "FooEvent" } ) ; cancelOnLog ( ) ; done ( ) ; } , { minconf : 0 } ) ; generateBlock ( ) ; } ) ; } ) ; } ) ;