                     XCTAssertTrue(self.read)
                 }
 
-                XCTAssertTrue(assertEventFn(event))
+                XCTAssertTrue(assertEventFn(self.unwrapInboundUserEventIn(event)))
                 ctx.close(promise: nil)
             }
             

                if writeToChannel {
                    var buffer = ctx.channel!.allocator.buffer(capacity: 4)
                    buffer.write(staticString: "test")
                    ctx.writeAndFlush(data: NIOAny(buffer), promise: nil)
                }
            }
        }

class IdleStateHandlerTest : XCTestCase {
    
    func testIdleRead() throws {
        try testIdle(IdleStateHandler(readTimeout: .seconds(1)), false, { $0 == IdleStateHandler.IdleStateEvent.read })
    }
    
    func testIdleWrite() throws {
        try testIdle(IdleStateHandler(writeTimeout: .seconds(1)), true, { $0 == IdleStateHandler.IdleStateEvent.write })
    }
    
    func testIdleAllWrite() throws {
        try testIdle(IdleStateHandler(allTimeout: .seconds(1)), true, { $0 == IdleStateHandler.IdleStateEvent.all })
    }
    
    func testIdleAllRead() throws {
        try testIdle(IdleStateHandler(allTimeout: .seconds(1)), false, { $0 == IdleStateHandler.IdleStateEvent.all })
    }
    
    private func testIdle(_ handler: IdleStateHandler, _ writeToChannel: Bool, _ assertEventFn: @escaping (IdleStateHandler.IdleStateEvent) -> Bool) throws {
        let group = try MultiThreadedEventLoopGroup(numThreads: 1)
        defer {
            try! group.syncShutdownGracefully()
        }
        
        class TestWriteHandler: ChannelInboundHandler {
            typealias InboundIn = ByteBuffer
            typealias OutboundOut = ByteBuffer
            typealias InboundUserEventIn = IdleStateHandler.IdleStateEvent
            
            private var read = false
            private let writeToChannel: Bool
            private let assertEventFn: (IdleStateHandler.IdleStateEvent) -> Bool
            
            init(_ writeToChannel: Bool, _ assertEventFn: @escaping (IdleStateHandler.IdleStateEvent) -> Bool) {
                self.writeToChannel = writeToChannel
                self.assertEventFn = assertEventFn
            }
