inkdevhub / swanky-cli

The all-in-one developer environment for Parity pallet-contracts based smart contracts!
https://docs.astar.network/docs/build/wasm/swanky-suite/cli/
MIT License
70 stars 29 forks source link

[BUG] swanky contract test not working #124

Closed kziemianek closed 1 year ago

kziemianek commented 1 year ago

Description

Hi, so I've upgraded my local swanky to new 2.0 version and it seems like contract tests are not working. Additionally messages about conflicting packages started to popping up: #46

Steps to Reproduce init new project with flipper ink example build contract and then test it with command swanky contract test flipper

Environment @astar-network/swanky-cli/2.0.0 darwin-x64 node-v18.2.0

Logs, Errors or Screenshots

kziemianek@Kaspers-MBP foobar % swanky contract test flipper   
@polkadot/util has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 11.0.1  node_modules/@polkadot/util/cjs
    cjs 11.0.1  node_modules/@polkadot/util/cjs
@polkadot/api-contract has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 10.0.1  node_modules/@polkadot/api-contract/cjs
    cjs 10.0.1  node_modules/@polkadot/api-contract/cjs
@polkadot/types has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 10.0.1  node_modules/@polkadot/types/cjs
    cjs 10.0.1  node_modules/@polkadot/types/cjs
@polkadot/types-create has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 10.0.1  node_modules/@polkadot/types-create/cjs
    cjs 10.0.1  node_modules/@polkadot/types-create/cjs
@polkadot/types-codec has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 10.0.1  node_modules/@polkadot/types-codec/cjs
    cjs 10.0.1  node_modules/@polkadot/types-codec/cjs
@polkadot/util-crypto has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 11.0.1  node_modules/@polkadot/util-crypto/cjs
    cjs 11.0.1  node_modules/@polkadot/util-crypto/cjs
@polkadot/wasm-crypto has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 7.0.2   node_modules/@polkadot/wasm-crypto/cjs
    cjs 7.0.2   node_modules/@polkadot/wasm-crypto/cjs
@polkadot/wasm-bridge has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 7.0.2   node_modules/@polkadot/wasm-bridge/cjs
    cjs 7.0.2   node_modules/@polkadot/wasm-bridge/cjs
@polkadot/wasm-crypto-wasm has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 7.0.2   node_modules/@polkadot/wasm-crypto-wasm/cjs
    cjs 7.0.2   node_modules/@polkadot/wasm-crypto-wasm/cjs
@polkadot/wasm-util has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 7.0.2   node_modules/@polkadot/wasm-util/cjs
    cjs 7.0.2   node_modules/@polkadot/wasm-util/cjs
@polkadot/api has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 10.0.1  node_modules/@polkadot/api/cjs
    cjs 10.0.1  node_modules/@polkadot/api/cjs
@polkadot/rpc-augment has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 10.0.1  node_modules/@polkadot/rpc-augment/cjs
    cjs 10.0.1  node_modules/@polkadot/rpc-augment/cjs
@polkadot/keyring has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 11.0.1  node_modules/@polkadot/keyring/cjs
    cjs 11.0.1  node_modules/@polkadot/keyring/cjs
@polkadot/rpc-provider has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 10.0.1  node_modules/@polkadot/rpc-provider/cjs
    cjs 10.0.1  node_modules/@polkadot/rpc-provider/cjs
@polkadot/api-derive has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 10.0.1  node_modules/@polkadot/api-derive/cjs
    cjs 10.0.1  node_modules/@polkadot/api-derive/cjs
@polkadot/rpc-core has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 10.0.1  node_modules/@polkadot/rpc-core/cjs
    cjs 10.0.1  node_modules/@polkadot/rpc-core/cjs
@polkadot/types-known has multiple versions, ensure that there is only one installed.
Either remove and explicitly install matching versions or dedupe using your package manager.
The following conflicting packages were found:
    cjs 10.0.1  node_modules/@polkadot/types-known/cjs
    cjs 10.0.1  node_modules/@polkadot/types-known/cjs

2023-03-09 13:07:59          API-WS: disconnected from ws://127.0.0.1:9944: 1006:: Abnormal Closure
  flipper test
2023-03-09 13:08:01          API-WS: disconnected from ws://127.0.0.1:9944: 1006:: Abnormal Closure
....
    1) "before all" hook: setup for "Sets the initial state"
    2) "after all" hook: tearDown for "Can flip the state"

  0 passing (3m)
  2 failing

  1) flipper test
       "before all" hook: setup for "Sets the initial state":
     Error: Timeout of 200000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/kziemianek/projects/priv/astar/foobar/test/flipper/flipper.test.ts)
      at listOnTimeout (node:internal/timers:564:17)
      at processTimers (node:internal/timers:507:7)

  2) flipper test
       "after all" hook: tearDown for "Can flip the state":
     TypeError: Cannot read properties of undefined (reading 'disconnect')
      at Context.tearDown (test/flipper/flipper.test.ts:37:15)
      at processImmediate (node:internal/timers:471:21)

2023-03-09 13:14:50          API-WS: disconnected from ws://127.0.0.1:9944: 1006:: Abnormal Closure
...
codespool commented 1 year ago

Thanks for reporting! Looking at this line:

API-WS: disconnected from ws://127.0.0.1:9944: 1006:: Abnormal Closure

it seems your node either didn't start or crashed. (swanky will not run it for you, you need to start it yourself with swanky node start Can you verify that the node is running?

The warning are actually correct in this case because the test file includes the utils, but so does the swanky-cli itself. We haven't observed any negative effects of those apart from it being annoying :) and I haven't managed to find a way to suppress them. I'm considering making @polkadot/utils a peer dependency, so that the host project is responsible for adding it, but I have to look closer at the possible implications of that.

kziemianek commented 1 year ago

Totally forgot to run node 😫 . Thanks for clarification.