fablo icon indicating copy to clipboard operation
fablo copied to clipboard

Add check for unique chaincode names across channels

Open IITI-tushar opened this issue 8 months ago • 4 comments

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.

IITI-tushar avatar Apr 16 '25 10:04 IITI-tushar

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

dzikowski avatar May 06 '25 11:05 dzikowski

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

IITI-tushar avatar May 08 '25 18:05 IITI-tushar

@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??

IITI-tushar avatar May 17 '25 09:05 IITI-tushar

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

dzikowski avatar May 20 '25 08:05 dzikowski

followed up in #596

dzikowski avatar Aug 22 '25 08:08 dzikowski