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

Set prot cfg fields in test #13178

Merged
merged 6 commits into from
Jul 27, 2023
Merged

Set prot cfg fields in test #13178

merged 6 commits into from
Jul 27, 2023

Conversation

oxade
Copy link
Contributor

@oxade oxade commented Jul 27, 2023

Description

Allows setting/overriding protocol config fields more easily in tests either by calling functions or referencing fields by string name.
This will be used to power CLI features for overriding prot configs in test and debug.

Examples

       let mut prot: ProtocolConfig =
            ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
  • By value in function call
        prot.set_max_arguments_for_testing(123);
        assert_eq!(prot.max_arguments(), 123);
  • By string value in function call
        prot.set_max_arguments_from_str_for_testing("321".to_string());
        assert_eq!(prot.max_arguments(), 321);
  • By string value and string field name
        prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
        assert_eq!(prot.max_arguments(), 456);

  • Unset a field
        prot.disable_max_arguments_for_testing();
        assert_eq!(prot.max_arguments_as_option(), None);

Test Plan

Unit tests


If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.

Type of Change (Check all that apply)

  • protocol change
  • user-visible impact
  • breaking change for a client SDKs
  • breaking change for FNs (FN binary must upgrade)
  • breaking change for validators or node operators (must upgrade binaries)
  • breaking change for on-chain data layout
  • necessitate either a data wipe or data migration

Release notes

@oxade oxade requested a review from mystenmark as a code owner July 27, 2023 12:11
@vercel
Copy link

vercel bot commented Jul 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
explorer ✅ Ready (Inspect) Visit Preview Jul 27, 2023 0:11am
multisig-toolkit ✅ Ready (Inspect) Visit Preview Jul 27, 2023 0:11am
mysten-ui ✅ Ready (Inspect) Visit Preview Jul 27, 2023 0:11am
sui-kiosk ✅ Ready (Inspect) Visit Preview Jul 27, 2023 0:11am
sui-typescript-docs ✅ Ready (Inspect) Visit Preview Jul 27, 2023 0:11am
sui-wallet-kit ✅ Ready (Inspect) Visit Preview Jul 27, 2023 0:11am

@@ -1384,12 +1384,6 @@ impl ProtocolConfig {

// Setters for tests
impl ProtocolConfig {
pub fn set_max_function_definitions_for_testing(&mut self, m: u64) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed these as they're now auto-derived

Copy link
Member

@amnn amnn left a comment

Choose a reason for hiding this comment

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

Changes LGTM, but to clarify the initial request that I think this is for, the feature request was to be able to apply the limits from an actual protocol config when running the tests by default so that an operation that would fail on-chain would also fail locally, rather than having a way to override an individual config for tests.

@oxade
Copy link
Contributor Author

oxade commented Jul 27, 2023

Changes LGTM, but to clarify the initial request that I think this is for, the feature request was to be able to apply the limits from an actual protocol config when running the tests by default so that an operation that would fail on-chain would also fail locally, rather than having a way to override an individual config for tests.

@amnn yes this PR was already in the works and is for a whole different feature needed by replay tool and Sui CLI.
The other feature for test support will come shortly; the timing was just coincidental.

@oxade oxade merged commit bbb9170 into main Jul 27, 2023
@oxade oxade deleted the set_prot_cfg_fields_in_test branch July 27, 2023 15:34
ebmifa added a commit that referenced this pull request Jul 27, 2023
ebmifa added a commit that referenced this pull request Jul 27, 2023
ebmifa pushed a commit that referenced this pull request Aug 10, 2023
## Description 

Allows setting/overriding protocol config fields more easily in tests
either by calling functions or referencing fields by string name.
This will be used to power CLI features for overriding prot configs in
test and debug.

Examples

```
       let mut prot: ProtocolConfig =
            ProtocolConfig::get_for_version(ProtocolVersion::new(1), Chain::Unknown);
```

* By value in function call 
```            
        prot.set_max_arguments_for_testing(123);
        assert_eq!(prot.max_arguments(), 123);
```

* By string value in function call
```
        prot.set_max_arguments_from_str_for_testing("321".to_string());
        assert_eq!(prot.max_arguments(), 321);
```

* By string value and string field name
```
        prot.set_attr_for_testing("max_arguments".to_string(), "456".to_string());
        assert_eq!(prot.max_arguments(), 456);

```


* Unset a field
```
        prot.disable_max_arguments_for_testing();
        assert_eq!(prot.max_arguments_as_option(), None);
```

## Test Plan 

Unit tests

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
ebmifa added a commit that referenced this pull request Aug 10, 2023
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.

2 participants