Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests for caliper-ethereum #1556

Open
davidkel opened this issue Apr 24, 2024 · 5 comments
Open

Unit tests for caliper-ethereum #1556

davidkel opened this issue Apr 24, 2024 · 5 comments
Labels

Comments

@davidkel
Copy link
Contributor

davidkel commented Apr 24, 2024

This package has no unit tests at all
New tests should not assume that the code is actually correct. It's expected that if the tests finds bugs or relevant situations where unexpected behaviour occurs then the code should also be fixed.

@davidkel davidkel added the test label Apr 24, 2024
@Sweetdevil144
Copy link

Hey @davidkel . I'd like to work on this issue if this is available !

@davidkel
Copy link
Contributor Author

@Sweetdevil144 I've assigned it to you

@Sweetdevil144
Copy link

Thanks @davidkel . Also, can you help me with a heads up for this step? What should be my network configurations when mocking connectorFactory.js?

@davidkel
Copy link
Contributor Author

@Sweetdevil144 all I can suggest is review how the caliper-fabric does it's tests. I'm not actually familiar with the ethereum package sorry. The caliper-fabric tests are the pattern to follow.

@Sweetdevil144
Copy link

Sweetdevil144 commented Apr 30, 2024

Created tests for connector-Factory.js. I'm trying to create tests for ethereum-connector.js but it keeps throwing logs as below when I logged the info as follow :

let configPath = CaliperUtils.resolvePath(ConfigUtil.get(ConfigUtil.keys.NetworkConfig));
        console.log(`Config Path: ${JSON.stringify(configPath)}`);
        let ethereumConfig;
        try {
            ethereumConfig = require(configPath).ethereum;
        } catch (error) {
            console.error(`Error requiring configPath: ${error}`);
            throw error;
        }

Original code lines were as follow : https://github.com/hyperledger/caliper/blob/ae23774d7bba51b55980cdc9110b11729aab96f7/packages/caliper-ethereum/lib/ethereum-connector.js#L46

Error logs :

 TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received undefined
at Module.require (node:internal/modules/cjs/loader:1223:3)
      at require (node:internal/modules/helpers:179:18)
      at new EthereumConnector (lib/ethereum-connector.js:50:30)
      at Context.<anonymous> (test/ethereum-connector.js:100:27)
      at process.processImmediate (node:internal/timers:478:21)

Take a look at my current test file from : here to know how I'm mocking the data. (I found some test network configs for ethereum pre-created, utilising the same for now).

@davidkel davidkel changed the title Add unit tests for caliper-ethereum Unit tests for caliper-ethereum Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants