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.
[verifier] Cannot call init (MystenLabs#2151)
* [verifier] Cannot call init - Added rule to stop re-calling init - Added init tests
- Loading branch information
Showing
13 changed files
with
183 additions
and
3 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
crates/sui-adapter-transactional-tests/tests/publish/init_public.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
processed 2 tasks | ||
|
||
task 1 'publish'. lines 5-25: | ||
Error: Failed to verify the Move module, reason: "_::M1. 'init' function cannot be public". | ||
Error: Failed to verify the Move module, reason: "_::M1. 'init' function must be private". |
4 changes: 4 additions & 0 deletions
4
crates/sui-verifier-transactional-tests/tests/init/cannot_call_init.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,4 @@ | ||
processed 1 task | ||
|
||
task 0 'publish'. lines 4-17: | ||
Error: Failed to verify the Move module, reason: "_::M::init at offset 1. Cannot call a module's 'init' function from another Move function". |
17 changes: 17 additions & 0 deletions
17
crates/sui-verifier-transactional-tests/tests/init/cannot_call_init.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,17 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
init(ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
|
||
public(script) init_again(ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
Self.init(move(ctx)); | ||
return; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
crates/sui-verifier-transactional-tests/tests/init/not_generic.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,4 @@ | ||
processed 1 task | ||
|
||
task 0 'publish'. lines 4-11: | ||
Error: Failed to verify the Move module, reason: "_::M. 'init' function cannot have type parameters". |
11 changes: 11 additions & 0 deletions
11
crates/sui-verifier-transactional-tests/tests/init/not_generic.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,11 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
init<T>(ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
crates/sui-verifier-transactional-tests/tests/init/not_private.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,10 @@ | ||
processed 3 tasks | ||
|
||
task 0 'publish'. lines 4-11: | ||
Error: Failed to verify the Move module, reason: "_::M. 'init' function must be private". | ||
|
||
task 1 'publish'. lines 13-20: | ||
Error: Failed to verify the Move module, reason: "_::M. 'init' function must be private". | ||
|
||
task 2 'publish'. lines 22-29: | ||
Error: Failed to verify the Move module, reason: "_::M. 'init' function must be private". |
29 changes: 29 additions & 0 deletions
29
crates/sui-verifier-transactional-tests/tests/init/not_private.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,29 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
public init(ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
} | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
public(script) init(ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
} | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
public(friend) init(ctx: &mut TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
crates/sui-verifier-transactional-tests/tests/init/not_txn_context.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,13 @@ | ||
processed 4 tasks | ||
|
||
task 0 'publish'. lines 4-11: | ||
Error: Failed to verify the Move module, reason: "Expected parameter for _::M::init to be &mut mut Sui::TxContext::TxContext, but found u64". | ||
|
||
task 1 'publish'. lines 13-20: | ||
Error: Failed to verify the Move module, reason: "Expected parameter for _::TxContext::init to be &mut mut Sui::TxContext::TxContext, but found _::TxContext::TxContext". | ||
|
||
task 2 'publish'. lines 22-29: | ||
Error: Failed to verify the Move module, reason: "Expected parameter for _::M::init to be &mut mut Sui::TxContext::TxContext, but found &Sui::TxContext::TxContext". | ||
|
||
task 3 'publish'. lines 32-39: | ||
Error: Failed to verify the Move module, reason: "Expected parameter for _::M::init to be &mut mut Sui::TxContext::TxContext, but found Sui::TxContext::TxContext". |
39 changes: 39 additions & 0 deletions
39
crates/sui-verifier-transactional-tests/tests/init/not_txn_context.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,39 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
init(ctx: u64) { | ||
label l0: | ||
abort 0; | ||
} | ||
} | ||
|
||
//# publish | ||
module 0x0.TxContext { | ||
struct TxContext { value: u64 } | ||
init(ctx: Self.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
} | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
init(ctx: &TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
} | ||
|
||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
init(ctx: TxContext.TxContext) { | ||
label l0: | ||
abort 0; | ||
} | ||
} |
Empty file.
4 changes: 4 additions & 0 deletions
4
crates/sui-verifier-transactional-tests/tests/init/return_values.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,4 @@ | ||
processed 1 task | ||
|
||
task 0 'publish'. lines 4-11: | ||
Error: Failed to verify the Move module, reason: "_::M, 'init' function cannot have return values". |
11 changes: 11 additions & 0 deletions
11
crates/sui-verifier-transactional-tests/tests/init/return_values.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,11 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
init(ctx: &mut TxContext.TxContext): u64 { | ||
label l0: | ||
abort 0; | ||
} | ||
} |
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