forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request MystenLabs#334 from MystenLabs/get-id
Implement get_id native function
- Loading branch information
Showing
4 changed files
with
40 additions
and
6 deletions.
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
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,20 @@ | ||
#[test_only] | ||
module FastX::IDTests { | ||
use FastX::ID; | ||
use FastX::TxContext; | ||
|
||
const ID_BYTES_MISMATCH: u64 = 0; | ||
|
||
struct Object has key, drop { | ||
id: ID::ID, | ||
} | ||
|
||
#[test] | ||
fun test_get_id() { | ||
let ctx = TxContext::dummy(); | ||
let id = TxContext::new_id(&mut ctx); | ||
let id_bytes = *ID::get_inner(&id); | ||
let obj = Object { id }; | ||
assert!(ID::get_inner(ID::get_id(&obj)) == &id_bytes, ID_BYTES_MISMATCH); | ||
} | ||
} |