-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move] Add more enums tests (#18241)
## Description Adds some more tests for enums in Move ## Test plan Added a bunch new tests.
- Loading branch information
Showing
25 changed files
with
579 additions
and
1 deletion.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
crates/sui-adapter-transactional-tests/tests/enums/enum_with_key_only.exp
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,17 @@ | ||
processed 6 tasks | ||
|
||
task 1 'publish'. lines 6-37: | ||
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("Enum X cannot have the 'key' ability. Enums cannot have the 'key' ability."), command: Some(0) } } | ||
|
||
task 2 'set-address'. lines 39-39: | ||
Error: INVALID TEST. Unknown object, object(1,0) | ||
|
||
task 3 'run'. lines 41-41: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 4 'run'. lines 43-43: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 5 'run'. lines 45-45: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } |
45 changes: 45 additions & 0 deletions
45
crates/sui-adapter-transactional-tests/tests/enums/enum_with_key_only.mvir
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,45 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --addresses test=0x0 | ||
|
||
//# publish | ||
module 0x0.f { | ||
import 0x2.transfer; | ||
|
||
enum X has key { | ||
A { } | ||
} | ||
|
||
public transfer() { | ||
let x: Self.X; | ||
label l0: | ||
x = X.A { }; | ||
transfer.transfer<Self.X>(move(x), 0x0); | ||
return; | ||
} | ||
|
||
public share() { | ||
let x: Self.X; | ||
label l0: | ||
x = X.A { }; | ||
transfer.share_object<Self.X>(move(x)); | ||
return; | ||
} | ||
|
||
public freezer() { | ||
let x: Self.X; | ||
label l0: | ||
x = X.A { }; | ||
transfer.freeze_object<Self.X>(move(x)); | ||
return; | ||
} | ||
} | ||
|
||
//# set-address test object(1,0) | ||
|
||
//# run test::f::transfer | ||
|
||
//# run test::f::share | ||
|
||
//# run test::f::freezer |
17 changes: 17 additions & 0 deletions
17
crates/sui-adapter-transactional-tests/tests/enums/enum_with_key_only_uid_field.exp
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,17 @@ | ||
processed 6 tasks | ||
|
||
task 1 'publish'. lines 6-45: | ||
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("Enum X cannot have the 'key' ability. Enums cannot have the 'key' ability."), command: Some(0) } } | ||
|
||
task 2 'set-address'. lines 47-47: | ||
Error: INVALID TEST. Unknown object, object(1,0) | ||
|
||
task 3 'run'. lines 49-49: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 4 'run'. lines 51-51: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 5 'run'. lines 53-53: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } |
53 changes: 53 additions & 0 deletions
53
crates/sui-adapter-transactional-tests/tests/enums/enum_with_key_only_uid_field.mvir
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,53 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --addresses test=0x0 | ||
|
||
//# publish | ||
module 0x0.f { | ||
import 0x2.transfer; | ||
import 0x2.object; | ||
import 0x2.tx_context; | ||
|
||
enum X has key { | ||
A { id: object.UID } | ||
} | ||
|
||
public transfer(ctx: &mut tx_context.TxContext) { | ||
let x: Self.X; | ||
let id: object.UID; | ||
label l0: | ||
id = object.new(move(ctx)); | ||
x = X.A { id: move(id) }; | ||
transfer.transfer<Self.X>(move(x), 0x0); | ||
return; | ||
} | ||
|
||
public share(ctx: &mut tx_context.TxContext) { | ||
let x: Self.X; | ||
let id: object.UID; | ||
label l0: | ||
id = object.new(move(ctx)); | ||
x = X.A { id: move(id) }; | ||
transfer.share_object<Self.X>(move(x)); | ||
return; | ||
} | ||
|
||
public freezer(ctx: &mut tx_context.TxContext) { | ||
let x: Self.X; | ||
let id: object.UID; | ||
label l0: | ||
id = object.new(move(ctx)); | ||
x = X.A { id: move(id) }; | ||
transfer.freeze_object<Self.X>(move(x)); | ||
return; | ||
} | ||
} | ||
|
||
//# set-address test object(1,0) | ||
|
||
//# run test::f::transfer | ||
|
||
//# run test::f::share | ||
|
||
//# run test::f::freezer |
32 changes: 32 additions & 0 deletions
32
crates/sui-adapter-transactional-tests/tests/enums/enum_with_key_store.exp
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,32 @@ | ||
processed 11 tasks | ||
|
||
task 1 'publish'. lines 6-88: | ||
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("Enum X cannot have the 'key' ability. Enums cannot have the 'key' ability."), command: Some(0) } } | ||
|
||
task 2 'set-address'. lines 90-90: | ||
Error: INVALID TEST. Unknown object, object(1,0) | ||
|
||
task 3 'run'. lines 92-92: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 4 'run'. lines 94-94: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 5 'run'. lines 96-96: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 6 'run'. lines 98-98: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 7 'run'. lines 100-100: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 8 'run'. lines 102-102: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 9 'run'. lines 104-104: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 10 'run'. lines 106-106: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } |
106 changes: 106 additions & 0 deletions
106
crates/sui-adapter-transactional-tests/tests/enums/enum_with_key_store.mvir
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,106 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --addresses test=0x0 | ||
|
||
//# publish | ||
module 0x0.f { | ||
import 0x2.transfer; | ||
import 0x2.object; | ||
import 0x2.dynamic_field; | ||
import 0x2.dynamic_object_field; | ||
import 0x2.tx_context; | ||
|
||
enum X has store, key { | ||
A { } | ||
} | ||
|
||
public transfer() { | ||
let x: Self.X; | ||
label l0: | ||
x = X.A { }; | ||
transfer.transfer<Self.X>(move(x), 0x0); | ||
return; | ||
} | ||
|
||
public share() { | ||
let x: Self.X; | ||
label l0: | ||
x = X.A { }; | ||
transfer.share_object<Self.X>(move(x)); | ||
return; | ||
} | ||
|
||
public public_transfer() { | ||
let x: Self.X; | ||
label l0: | ||
x = X.A { }; | ||
transfer.public_transfer<Self.X>(move(x), 0x0); | ||
return; | ||
} | ||
|
||
public public_share() { | ||
let x: Self.X; | ||
label l0: | ||
x = X.A { }; | ||
transfer.public_share_object<Self.X>(move(x)); | ||
return; | ||
} | ||
|
||
public freezer() { | ||
let x: Self.X; | ||
label l0: | ||
x = X.A { }; | ||
transfer.freeze_object<Self.X>(move(x)); | ||
return; | ||
} | ||
|
||
public public_freezer() { | ||
let x: Self.X; | ||
label l0: | ||
x = X.A { }; | ||
transfer.public_freeze_object<Self.X>(move(x)); | ||
return; | ||
} | ||
|
||
public add_as_df(ctx: &mut tx_context.TxContext) { | ||
let x: Self.X; | ||
let id: object.UID; | ||
label l0: | ||
id = object.new(move(ctx)); | ||
x = X.A { }; | ||
dynamic_field.add<u64, Self.X>(&mut id, 0, move(x)); | ||
object.delete(move(id)); | ||
return; | ||
|
||
} | ||
|
||
public dof_add(ctx: &mut tx_context.TxContext) { | ||
let x: Self.X; | ||
let id: object.UID; | ||
label l0: | ||
id = object.new(move(ctx)); | ||
x = X.A { }; | ||
dynamic_object_field.add<u64, Self.X>(&mut id, 0, move(x)); | ||
object.delete(move(id)); | ||
return; | ||
} | ||
} | ||
|
||
//# set-address test object(1,0) | ||
|
||
//# run test::f::transfer | ||
|
||
//# run test::f::share | ||
|
||
//# run test::f::public_transfer | ||
|
||
//# run test::f::public_share | ||
|
||
//# run test::f::freezer | ||
|
||
//# run test::f::public_freezer | ||
|
||
//# run test::f::add_df | ||
|
||
//# run test::f::add_dof |
32 changes: 32 additions & 0 deletions
32
crates/sui-adapter-transactional-tests/tests/enums/enum_with_key_store_uid_field.exp
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,32 @@ | ||
processed 11 tasks | ||
|
||
task 1 'publish'. lines 6-104: | ||
Error: Transaction Effects Status: Sui Move Bytecode Verification Error. Please run the Sui Move Verifier for more information. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: SuiMoveVerificationError, source: Some("Enum X cannot have the 'key' ability. Enums cannot have the 'key' ability."), command: Some(0) } } | ||
|
||
task 2 'set-address'. lines 106-106: | ||
Error: INVALID TEST. Unknown object, object(1,0) | ||
|
||
task 3 'run'. lines 108-108: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 4 'run'. lines 110-110: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 5 'run'. lines 112-112: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 6 'run'. lines 114-114: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 7 'run'. lines 116-116: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 8 'run'. lines 118-118: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 9 'run'. lines 120-120: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } | ||
|
||
task 10 'run'. lines 122-122: | ||
Error: Error checking transaction input objects: DependentPackageNotFound { package_id: 0x0000000000000000000000000000000000000000000000000000000000000000 } |
Oops, something went wrong.