• Matthew Slipper's avatar
    Add actor testing framework, basic actor tests · 3ce64804
    Matthew Slipper authored
    Metadata:
    
    - Fixes ENG-1662
    - Fixes ENG-1664
    - Fixes ENG-1663
    
    Adds the actor testing framework and implements some basic actor tests. The tests are:
    
    - An actor that makes repeated deposits
    - An actor that makes repeated transfers
    
    For information on how the framework works, see [integration-tests/actor-tests/README.md](integration-tests/actor-tests/README.md).
    3ce64804
logger.ts 780 Bytes
import { sanitizeForMetrics } from './metrics'

abstract class Logger {
  log(msg: string) {
    const date = new Date()
    process.stderr.write(`[${date.toISOString()}] ${msg}\n`)
  }
}

export class ActorLogger extends Logger {
  private readonly name: string

  constructor(name: string) {
    super()
    this.name = name
  }

  log(msg: string) {
    super.log(`[actor:${sanitizeForMetrics(this.name)}] ${msg}`)
  }
}

export class WorkerLogger extends Logger {
  private readonly name: string

  private readonly workerId: number

  constructor(name: string, workerId: number) {
    super()
    this.name = name
    this.workerId = workerId
  }

  log(msg: string) {
    super.log(
      `[bench:${sanitizeForMetrics(this.name)}] [wid:${this.workerId}] ${msg}`
    )
  }
}