hadronous / pic-js

An Internet Computer Protocol canister testing library for TypeScript and JavaScript.
https://hadronous.github.io/pic-js/
Apache License 2.0
11 stars 5 forks source link

Tests failing on second attempt of running them #37

Open jake-beardo opened 6 months ago

jake-beardo commented 6 months ago

I managed to run 1 test sucessfully using bun test but since then pocketjs is failing

bun test                                                                                                                                          08:42:18 PM
bun test v1.0.30 (1424a196)

src/orderbook/test/integration/main.test.ts:
✓ OrderBook > should start at [8.09ms]

 1 pass
 0 fail
Ran 1 tests across 1 files. [2.84s]
add-pocket-ic = > bun test                                                                                                                                          08:42:23 PM
bun test v1.0.30 (1424a196)

src/orderbook/test/integration/main.test.ts:
thread 'tokio-runtime-worker' panicked at library/std/src/io/stdio.rs:1021:9:
failed printing to stdout: Broken pipe (os error 32)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at rs/pocket_ic_server/src/state_api/state.rs:495:45:
join failed!: JoinError::Panic(Id(25), ...)
ConnectionClosed: The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()
 path: "http://127.0.0.1:56209/instances/1/update/execute_ingress_message"
✗ OrderBook > should start at [46.10ms]
✗ OrderBook > should start at

 0 pass
 2 fail
Ran 2 tests across 1 files. [120.00ms]

this is my test file

import { resolve } from 'node:path';
import { Principal } from '@dfinity/principal';
import {  PocketIc } from '@hadronous/pic';
import type { Actor } from '@hadronous/pic';
import { IDL } from '@dfinity/candid';
import { idlFactory, init } from '../../../declarations/orderbook/orderbook.did.js';
import type { _SERVICE } from '../../../declarations/orderbook/orderbook.did';

const WASM_PATH = resolve(
  __dirname,
  '..',
  '..',
  '..',
  '..',
  '.dfx',
  'local',
  'canisters',
  'orderbook',
  'orderbook.wasm',
);

describe('OrderBook', () => {
  let pic: PocketIc;
  let actor: Actor<_SERVICE>;
  let canisterId: Principal;

  beforeEach(async () => {
    pic = await PocketIc.create();
    const fixture = await pic.setupCanister<_SERVICE>({
      idlFactory,
      wasm: WASM_PATH,
      arg: IDL.encode(init({ IDL }), [Principal.fromText('aaaaa-aa')]),
    });
    actor = fixture.actor;
    canisterId = fixture.canisterId;
  });

  afterEach(async () => {
    await pic.tearDown();
  });

  it(`should start at`, async () => {
    const result = await actor.getEventDetails();
  });
});
nathanosdev commented 6 months ago

I've been having some issues with bun test since v1.0.27 and I opened a ticket for that: https://github.com/oven-sh/bun/issues/8958. So far there's been no luck with that and I'm now considering dropping Bun from the repo and the docs until they stabilize it better.

Could you try rolling back to v1.0.26 to see if it helps?

curl -fsSL https://bun.sh/install | bash -s "bun-v1.0.26"