-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[sui-framework] Reserve addresses for the deny list #17594
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a5d9b06
[sui-framework] Reserve addresses for the deny list
tnowacki 7b5134e
Updated test
tnowacki a631794
Apply suggestions from code review
tnowacki 11fbed4
Fixed docs
tnowacki a2b6193
update snapshot
tnowacki cee90f7
Merge branch 'main' into nonzero
tnowacki fb5d330
snapshot
tnowacki 751f788
Merge branch 'main' into nonzero
tnowacki a57e85e
yet again, fixing snapshots
tnowacki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
crates/sui-framework/packages/sui-framework/tests/deny_list_tests.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#[test_only] | ||
module sui::deny_list_tests { | ||
use sui::deny_list; | ||
use sui::test_scenario; | ||
use std::type_name; | ||
|
||
public struct X() | ||
|
||
#[test, expected_failure(abort_code = sui::deny_list::EInvalidAddress)] | ||
fun add_zero() { | ||
let mut ctx = tx_context::dummy(); | ||
let mut dl = deny_list::new_for_testing(&mut ctx); | ||
let ty = type_name::into_string(type_name::get_with_original_ids<X>()).into_bytes(); | ||
dl.add(1, ty, deny_list::reserved_addresses()[0]); // should error | ||
abort 0 // should not be reached | ||
} | ||
|
||
#[test, expected_failure(abort_code = sui::deny_list::EInvalidAddress)] | ||
fun remove_zero() { | ||
let mut ctx = tx_context::dummy(); | ||
let mut dl = deny_list::new_for_testing(&mut ctx); | ||
let ty = type_name::into_string(type_name::get_with_original_ids<X>()).into_bytes(); | ||
dl.add(1, ty, deny_list::reserved_addresses()[1]); // should error | ||
abort 0 // should not be reached | ||
} | ||
|
||
#[test] | ||
fun contains_zero () { | ||
let mut scenario = test_scenario::begin(@0); | ||
deny_list::create_for_test(scenario.ctx()); | ||
scenario.next_tx(@0); | ||
let dl: deny_list::DenyList = scenario.take_shared(); | ||
let ty = type_name::into_string(type_name::get_with_original_ids<X>()).into_bytes(); | ||
let reserved = deny_list::reserved_addresses(); | ||
let mut i = 0; | ||
let n = reserved.length(); | ||
while (i < n) { | ||
assert!(!dl.contains(1, ty, reserved[i]), 0); | ||
i = i + 1; | ||
}; | ||
test_scenario::return_shared(dl); | ||
scenario.end(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bridge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bridge package (@patrickkuo)
const SUI_BRIDGE_ID: address = @0x9;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bridge object is 0x9 and bridge package is 0xb