Skip to content

Add check for unique chaincode names across channels #528

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

IITI-tushar
Copy link

fixes : issue#228
This pull request introduces a new validation to ensure that chaincode names are unique across different channels. It includes changes to both the test suite and the core configuration extension logic.

New validation for unique chaincode names:

  • e2e/fabloCommands.test.ts: Added a test case to check for duplicate chaincode names across different channels, ensuring that the validation throws an error when duplicates are found.
  • src/extend-config/extendChaincodesConfig.ts: Introduced the checkUniqueChaincodeNames function to validate that all chaincode names are unique within the provided configuration. This function is called within the extendChaincodesConfig function.

Integration of the new validation:

  • src/extend-config/extendConfig.ts: Imported the checkUniqueChaincodeNames function and integrated it into the extendConfig function to ensure chaincode names are checked for uniqueness during the configuration extension process.

Signed-off-by: IITI-tushar <019saxenatushar@gmail.com>
Copy link
Contributor

@dzikowski dzikowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good. Lets wait for pipelines to pass, and could you also add relevant entry in the CHANGELOG.md file?

@dzikowski dzikowski changed the title updated code to new branch : Add check for unique chaincode names across channels Add check for unique chaincode names across channels Apr 16, 2025
@dzikowski
Copy link
Contributor

Hi @IITI-tushar how is it going? Would you like to complete this PR?

@IITI-tushar
Copy link
Author

@dzikowski
Sir my exams are going on, will complete this issue in a few days.

Signed-off-by: Tushar Saxena <019saxenatushar@gmail.com>
@IITI-tushar
Copy link
Author

@dzikowski
Sir I added this test case.
image

in the file /samples/fablo-config-hlf2-2orgs-2chaincodes-raft.yaml i changed the chaincodes to be same
image

here's the error output
image

should i commit the test case??

@dzikowski
Copy link
Contributor

I would suggest to update the Fablo config file on the fly in test, for instance:

const fabloConfigJson = // read and parse fablo config from file
fabloConfigJson.chaincodes[1].name = fabloConfigJson.chaincodes[0].name;
// save the file to temporary location, and then use it in tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fablo fails if two chaincodes have the same name
2 participants