hashed-io / hashed-pallets

Hashed Network pallets
MIT License
0 stars 0 forks source link

Out of bounds marketplace application #41

Closed didiermis closed 7 months ago

didiermis commented 7 months ago

Validation Fixes and Tests in Gated Marketplace

Overview

The changes implemented focus on enhancing the gated marketplace pallet by introducing error handling for application setup and enforcing validation checks. The motivation behind these changes is to ensure that applications to the marketplace meet specific criteria, such as having the required fields and adhering to the constraints for custodian relationships. This improvement in validation prevents potential runtime errors and enhances the overall robustness of the marketplace application process.

Tickets

Implementation notes

The implementation involves modifying the set_up_application function to return a Result type, enabling the function to handle errors gracefully by leveraging Rust's error handling paradigm. Additional checks are introduced to ensure that:

These checks are accomplished using the ensure! macro for concise assertions and the .map_err method to transform errors from the try_from method into pallet-specific errors.

Furthermore, corresponding changes are made in the callers of set_up_application within the module to handle the Result returned by the

Interesting/controversial decisions

The decision to enforce strict validation at the application setup stage could be seen as restrictive, especially in scenarios where marketplace dynamics might demand more flexibility.

Test coverage

New tests were added in tests.rs to cover scenarios involving the new validations. These include tests for applying without fields, applying with mismatched numbers of fields and custodian fields, and exceeding the maximum allowed fields. The tests verify that the system correctly rejects invalid or incomplete applications, and they help ensure that the validations work as intended.

github-actions[bot] commented 7 months ago

GPT summary of e97d36e502d8ded02fb27a0990b59ebebbe8c8dc:

Error: couldn't generate summary

github-actions[bot] commented 7 months ago

GPT summary of e89fe523538dae9996be3fd36aa916ad80d4e905:

Error: couldn't generate summary

PR summary so far:

Error: couldn't generate summary

github-actions[bot] commented 7 months ago

GPT summary of 34bfd70d2616af2c454e1188d2f49db57f341ebe:

Error: couldn't generate summary

github-actions[bot] commented 7 months ago

GPT summary of 3d96012d3f36a62255c1d058b0819a438f30edc1:

Error: couldn't generate summary

PR summary so far:

Error: couldn't generate summary

github-actions[bot] commented 7 months ago

GPT summary of 0b8e196b77980c39cd12a8cb29be8378dfa5dd32:

Error: couldn't generate summary

PR summary so far:

Error: couldn't generate summary

github-actions[bot] commented 7 months ago

GPT summary of a92088c1d41bb859cdc21f9635712a0c2796a780:

Error: couldn't generate summary

PR summary so far:

Error: couldn't generate summary

github-actions[bot] commented 7 months ago

GPT summary of ae9340d0ac83185f41de011115929dfcb0e5c6f6:

Error: couldn't generate summary

PR summary so far:

Error: couldn't generate summary