import { DebuggerClient } from "../debugger-client"
import request from 'sync-request';
import { InitArguments } from "../types";
import { safeNativize } from "../helper";
import { Debugger } from "../debugger";
jest.setTimeout(500000);

describe('Blur debugger', () => {
  let client: DebuggerClient;
  const debug = Debugger.Instance
  beforeAll(async () => {
    client = new DebuggerClient();
    const resp = request('GET', "https://test.sentio.xyz/api/v1/solidity/fetch_and_compile?txHash=0xf86a40d6421b7b0f29a6baacd8d11e1d2444dd4974e4cf554a367c95fdb1d79c", {json: true})
    const body = JSON.parse(resp.body as string);
    const shimmedCompilations = [];
    for (var key in body.result) {
      var value = body.result[key];
      // @ts-ignore
      shimmedCompilations.push(value);
    }
    const init_args: InitArguments = {
      providerURL: 'https://test.sentio.xyz/api/v1/solidity',
      txnHash: "0xf86a40d6421b7b0f29a6baacd8d11e1d2444dd4974e4cf554a367c95fdb1d79c",
      shimmedCompilations: shimmedCompilations,
      chainId: "0x1",
      storageLookup: false
    }
    await client.initialize(init_args);

    await debug.initialize(init_args)
  })

  afterEach(async () => {
    await client.reset();
  })


  it('call trace', async () => {
    const res = await debug.getCallTrace()
    console.log(res)
  })

})