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.
[move] Add large enum test (MystenLabs#19075)
## Description - Fix compiler's sui-mode entry rules for enums - Add large enum tests for entry functions ## Test plan - Added tests --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API:
- Loading branch information
Showing
8 changed files
with
213 additions
and
3 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
crates/sui-adapter-transactional-tests/tests/entry_points/large_enum.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,22 @@ | ||
processed 4 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1, lines 8-35: | ||
//# publish | ||
created: object(1,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 6452400, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2, lines 37-38: | ||
//# programmable --sender A | ||
//> test::m::x1() | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 3, lines 40-41: | ||
//# programmable --sender A | ||
//> test::m::x3() | ||
Error: Transaction Effects Status: Move Bytecode Verification Error. Please run the Bytecode Verifier for more information. | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: VMVerificationOrDeserializationError, source: Some(VMError { major_status: TOO_MANY_TYPE_NODES, sub_status: None, message: None, exec_state: None, location: Undefined, indices: [], offsets: [] }), command: Some(0) } } |
41 changes: 41 additions & 0 deletions
41
crates/sui-adapter-transactional-tests/tests/entry_points/large_enum.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,41 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// tests error after serializing a large enum return value | ||
|
||
//# init --addresses test=0x0 --accounts A | ||
|
||
//# publish | ||
|
||
module test::m { | ||
|
||
public enum X1 has drop { | ||
Big1(u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8), | ||
} | ||
|
||
public enum X2 has drop { | ||
V1(X1, X1, X1), | ||
V2(X1, X1, X1), | ||
V3(X1, X1, X1), | ||
} | ||
|
||
public enum X3 has drop { | ||
X2(X2, X2, X2), | ||
U64(u64), | ||
} | ||
|
||
entry fun x1(): X1 { | ||
X1::Big1(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) | ||
} | ||
|
||
entry fun x3(): X3 { | ||
X3::U64(0) | ||
} | ||
|
||
} | ||
|
||
//# programmable --sender A | ||
//> test::m::x1() | ||
|
||
//# programmable --sender A | ||
//> test::m::x3() |
15 changes: 15 additions & 0 deletions
15
external-crates/move/crates/move-compiler-transactional-tests/tests/functions/large_enum.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,15 @@ | ||
processed 4 tasks | ||
|
||
task 2, line 34: | ||
//# run 0x42::m::x1 | ||
return values: |0|{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } | ||
|
||
task 3, line 36: | ||
//# run 0x42::m::x3 | ||
Error: Function execution failed with VMError: { | ||
major_status: VERIFICATION_ERROR, | ||
sub_status: None, | ||
location: undefined, | ||
indices: [], | ||
offsets: [], | ||
} |
36 changes: 36 additions & 0 deletions
36
...rnal-crates/move/crates/move-compiler-transactional-tests/tests/functions/large_enum.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,36 @@ | ||
// tests error after serializing a large enum return value | ||
|
||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
|
||
module 0x42::m { | ||
|
||
public enum X1 { | ||
Big(u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8), | ||
} | ||
|
||
public enum X2 { | ||
V1(X1, X1, X1), | ||
V2(X1, X1, X1), | ||
V3(X1, X1, X1), | ||
} | ||
|
||
public enum X3 { | ||
X2(X2, X2, X2), | ||
U64(u64), | ||
} | ||
|
||
entry fun x1(): X1 { | ||
X1::Big(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) | ||
} | ||
|
||
entry fun x3(): X3 { | ||
X3::U64(0) | ||
} | ||
|
||
} | ||
|
||
//# run 0x42::m::x1 | ||
|
||
//# run 0x42::m::x3 |
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
39 changes: 39 additions & 0 deletions
39
...tes/move/crates/move-compiler/tests/sui_mode/move_2024/typing/enum_in_struct_position.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,39 @@ | ||
error[Sui E02007]: invalid object declaration | ||
┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:11:13 | ||
│ | ||
11 │ public enum Obj has key, store { | ||
│ ^^^ --- Enums cannot have the 'key' ability. | ||
│ │ | ||
│ Invalid object 'Obj' | ||
|
||
error[Sui E02002]: invalid 'entry' function signature | ||
┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:18:1 | ||
│ | ||
3 │ public enum E { | ||
│ - To satisfy the constraint, the 'drop' ability would need to be added here | ||
· | ||
18 │ entry fun ret(): E { | ||
│ ^^^^^ - The type 'a::m::E' does not have the ability 'drop' | ||
│ │ | ||
│ Invalid return type for entry function 'ret' | ||
|
||
error[Sui E02002]: invalid 'entry' function signature | ||
┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:22:14 | ||
│ | ||
22 │ entry fun x3(_: E) { | ||
│ ----- ^ - 'entry' parameters must be primitives (by-value), vectors of primitives, objects (by-reference or by-value), vectors of objects, or 'Receiving' arguments (by-reference or by-value) | ||
│ │ │ | ||
│ │ Invalid 'entry' parameter type for parameter '_' | ||
│ 'x3' was declared 'entry' here | ||
|
||
error[Sui E02009]: invalid private transfer call | ||
┌─ tests/sui_mode/move_2024/typing/enum_in_struct_position.move:30:5 | ||
│ | ||
11 │ public enum Obj has key, store { | ||
│ ----- The object has 'store' so 'sui::transfer::public_transfer' can be called instead | ||
· | ||
29 │ public fun transfer(o: a::m::Obj) { | ||
│ --------- The type 'a::m::Obj' is not declared in the current module | ||
30 │ transfer::transfer(o, @0) | ||
│ ^^^^^^^^^^^^^^^^^^^^^^^^^ Invalid private transfer. The function 'sui::transfer::transfer' is restricted to being called in the object's module, 'a::m' | ||
|
42 changes: 42 additions & 0 deletions
42
...es/move/crates/move-compiler/tests/sui_mode/move_2024/typing/enum_in_struct_position.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,42 @@ | ||
module a::m { | ||
|
||
public enum E { | ||
V() | ||
} | ||
|
||
public enum M has drop { | ||
V() | ||
} | ||
|
||
public enum Obj has key, store { | ||
V() | ||
} | ||
|
||
fun init(_: M, _: &mut TxContext) { | ||
} | ||
|
||
entry fun ret(): E { | ||
E::V() | ||
} | ||
|
||
entry fun x3(_: E) { | ||
abort 0 | ||
} | ||
|
||
} | ||
|
||
module a::n { | ||
public fun transfer(o: a::m::Obj) { | ||
transfer::transfer(o, @0) | ||
} | ||
} | ||
|
||
module sui::transfer { | ||
public fun transfer<T: key>(_: T, _: address) { | ||
abort 0 | ||
} | ||
} | ||
|
||
module sui::tx_context{ | ||
public struct TxContext has drop {} | ||
} |