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.
[package-upgrades] Type param testing (MystenLabs#10271)
## Description Added tests for type parameters.
- Loading branch information
Showing
8 changed files
with
518 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "type_params" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
Sui = { local = "../../../../../sui-framework/packages/sui-framework" } | ||
|
||
[addresses] | ||
type_params = "0x0" |
40 changes: 40 additions & 0 deletions
40
crates/sui-core/src/unit_tests/data/type_params/sources/m1.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,40 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module type_params::m1 { | ||
use sui::object::{Self, UID}; | ||
use sui::tx_context::TxContext; | ||
use sui::transfer; | ||
use type_params::m2; | ||
|
||
struct Object has key, store { | ||
id: UID, | ||
value: u64, | ||
} | ||
|
||
struct GenObject<T: key + store> has key, store { | ||
id: UID, | ||
o: T, | ||
} | ||
|
||
public entry fun create_and_transfer(value: u64, recipient: address, ctx: &mut TxContext) { | ||
transfer::public_transfer( | ||
Object { id: object::new(ctx), value }, | ||
recipient | ||
) | ||
} | ||
|
||
public entry fun create_and_transfer_gen(value: u64, recipient: address, ctx: &mut TxContext) { | ||
let another = m2::create(value, ctx); | ||
transfer::public_transfer( | ||
GenObject { id: object::new(ctx), o: another }, | ||
recipient | ||
) | ||
} | ||
|
||
public entry fun transfer_object<T: key + store>(o: T, recipient: address) { | ||
transfer::public_transfer(o, recipient); | ||
} | ||
|
||
|
||
} |
26 changes: 26 additions & 0 deletions
26
crates/sui-core/src/unit_tests/data/type_params/sources/m2.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,26 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module type_params::m2 { | ||
use sui::object::{Self, UID}; | ||
use sui::tx_context::TxContext; | ||
use sui::transfer; | ||
|
||
struct AnotherObject has key, store { | ||
id: UID, | ||
value: u64, | ||
} | ||
|
||
public entry fun create_and_transfer(value: u64, recipient: address, ctx: &mut TxContext) { | ||
transfer::public_transfer( | ||
AnotherObject { id: object::new(ctx), value }, | ||
recipient | ||
) | ||
} | ||
|
||
public fun create(value: u64, ctx: &mut TxContext): AnotherObject { | ||
AnotherObject { id: object::new(ctx), value } | ||
} | ||
|
||
|
||
} |
12 changes: 12 additions & 0 deletions
12
crates/sui-core/src/unit_tests/data/type_params/sources/m3.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,12 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module type_params::m3 { | ||
use sui::transfer; | ||
|
||
public entry fun transfer_object<T: key + store>(o: T, recipient: address) { | ||
transfer::public_transfer(o, recipient); | ||
} | ||
|
||
|
||
} |
9 changes: 9 additions & 0 deletions
9
crates/sui-core/src/unit_tests/data/type_params_extra/Move.toml
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,9 @@ | ||
[package] | ||
name = "type_params_extra" | ||
version = "0.0.1" | ||
|
||
[dependencies] | ||
Sui = { local = "../../../../../sui-framework/packages/sui-framework" } | ||
|
||
[addresses] | ||
type_params = "0x0" |
12 changes: 12 additions & 0 deletions
12
crates/sui-core/src/unit_tests/data/type_params_extra/sources/m1.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,12 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module type_params::m1 { | ||
use sui::transfer; | ||
|
||
public entry fun transfer_object<T: key + store>(o: T, recipient: address) { | ||
transfer::public_transfer(o, recipient); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.