Can't run npm run test on package/cli

Hello,
I’m trying to clone and run tests in openzeppelin-sdk/cli as I want to do some contribution, but I can’t really run the tests. Can you guys help me, please?

:computer: Environment
I just cloned openzeppelin-sdk
v10.16.3

:memo:Details
I did run npm install and then npm run test, and it failt

./scripts/test.sh

Starting our own ganache instance
Ganache CLI v6.3.0 (ganache-core: 2.4.0)
Error: Could not find @openzeppelin/upgrades/contracts/mocks/StorageMocksForComparison.sol from any sources; imported from <my-path>/openzeppelin-sdk/packages/cli/contracts/mocks/Imports.sol
1 Like

Hi @obernardovieira,

Sorry that you are having this issue when wanting to contribute (I get the same error).

If you have time, can you create an issue in the repository.

Hi @obernardovieira,

I have created an Issue: https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1268

Hi @obernardovieira,

I was able to run most of the tests using the following:

Though want to get the contributing guide to have the required procedure.

1 Like

Hi, appreciate it :pray:
after following all that, I still can’t run the tests :frowning:

I’ll try again, maybe I’ve done something wrong

1 Like

Hi @obernardovieira,

I will find out the process and write it up.

1 Like

Hi @obernardovieira,

The repo is moving to Yarn workspaces: https://github.com/OpenZeppelin/openzeppelin-sdk/pull/1241

I still get a couple of failed tests, I assume I am missing some setup (https://github.com/OpenZeppelin/openzeppelin-sdk/pull/1241#issuecomment-547220237)

New steps:
In root directory run yarn

openzeppelin-sdk$ yarn

Then compile some contracts

openzeppelin-sdk/packages/cli$ npx truffle compile

Then run tests

openzeppelin-sdk/packages/cli$ yarn test
openzeppelin-sdk/packages/lib$ yarn test

Hi @obernardovieira,

In root directory run yarn

openzeppelin-sdk$ yarn

Then run tests

openzeppelin-sdk/packages/cli$ yarn test
openzeppelin-sdk/packages/lib$ yarn test
1 Like

Oh, lovely.

There is just one test failing

link command                                                                                                                                                                                                                                                                    
    1) should call link script with a list of dependencies and no install

Reason

Error: OpenZeppelin file .openzeppelin/project.json not found. Run 'openzeppelin init' first to initialize the project.
1 Like

Hi @obernardovieira,

That test passes the first time I run it:

  link command
    ✓ should call link script with a list of dependencies and no install (1882ms)
    ✓ should call push script when passing --push option (1034ms)

I do get issues with

  1) Contract: create script
       on published project
         "before each" hook: setup for "should refuse create a proxy for unlinked dependency":
     Error:
Could not connect to your Ethereum client with the following parameters:
    - host       > localhost
    - port       > 9555
    - network_id > 4447

Also

  2) Contract: update script
       on dependency contract in unpublished mode
         updating on dependency
           "before each" hook: setup for "should upgrade the version of all proxies":
     Failed deployment of dependency mock-stdlib-undeployed with error:
Could not connect to your Ethereum client with the following parameters:
    - host       > localhost
    - port       > 9555
    - network_id > 4447

The second time I run the tests it fails.

  link command
    1) should call link script with a list of dependencies and no install
    ✓ should call push script when passing --push option (186ms)

...

Error: OpenZeppelin file .openzeppelin/project.json not found. Run 'openzeppelin init' first to initialize the project.
    at new LocalController (/mnt/c/Users/andre/Documents/projects/forum/openzeppelin-sdk/packages/cli/src/models/local/LocalController.ts:32:13)