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][adapter] Optional TxContext for entry points (MystenLabs#2219
) * [verifier][adapter] Optional TxContext for entry points - Made &mut TxContext optional for entry points - Made it mandatory again for init functions, since its kind of useless to have an init function without it
- Loading branch information
Showing
9 changed files
with
172 additions
and
71 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
crates/sui-adapter-transactional-tests/tests/entry_points/no_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,15 @@ | ||
processed 4 tasks | ||
|
||
init: | ||
A: object(100) | ||
|
||
task 1 'publish'. lines 6-24: | ||
created: object(104) | ||
written: object(103) | ||
|
||
task 2 'run'. lines 26-26: | ||
created: object(106) | ||
written: object(105) | ||
|
||
task 3 'run'. lines 28-28: | ||
written: object(106), object(107) |
28 changes: 28 additions & 0 deletions
28
crates/sui-adapter-transactional-tests/tests/entry_points/no_txn_context.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,28 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# init --addresses Test=0x0 --accounts A | ||
|
||
//# publish | ||
module Test::M { | ||
use Sui::TxContext::{Self, TxContext}; | ||
struct Obj has key { | ||
id: Sui::ID::VersionedID, | ||
value: u64 | ||
} | ||
|
||
public(script) fun mint(ctx: &mut TxContext) { | ||
Sui::Transfer::transfer( | ||
Obj { id: TxContext::new_id(ctx), value: 0 }, | ||
TxContext::sender(ctx), | ||
) | ||
} | ||
|
||
public(script) fun incr(obj: &mut Obj) { | ||
obj.value = obj.value + 1 | ||
} | ||
} | ||
|
||
//# run Test::M::mint --sender A | ||
|
||
//# run Test::M::incr --sender A --args object(106) |
2 changes: 1 addition & 1 deletion
2
crates/sui-adapter-transactional-tests/tests/publish/init_param.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-24: | ||
Error: Failed to verify the Move module, reason: "'init' function can have 0 or 1 parameter(s)". | ||
Error: Failed to verify the Move module, reason: "Expected exactly one parameter for _::M1::init of type &mut Sui::TxContext::TxContext". |
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
9 changes: 9 additions & 0 deletions
9
crates/sui-verifier-transactional-tests/tests/entry_points/optional_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,9 @@ | ||
processed 2 tasks | ||
|
||
task 0 'publish'. lines 4-11: | ||
created: object(103) | ||
written: object(102) | ||
|
||
task 1 'publish'. lines 14-23: | ||
created: object(105) | ||
written: object(104) |
23 changes: 23 additions & 0 deletions
23
crates/sui-verifier-transactional-tests/tests/entry_points/optional_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,23 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
public(script) t() { | ||
label l0: | ||
abort 0; | ||
} | ||
} | ||
|
||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
import 0x2.ID; | ||
struct Obj has key { id: ID.VersionedID } | ||
public(script) t(flag: bool, arg: &mut Self.Obj) { | ||
label l0: | ||
abort 0; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/sui-verifier-transactional-tests/tests/init/must_have_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,7 @@ | ||
processed 2 tasks | ||
|
||
task 0 'publish'. lines 4-11: | ||
Error: Failed to verify the Move module, reason: "Expected exactly one parameter for _::M::init of type &mut Sui::TxContext::TxContext". | ||
|
||
task 1 'publish'. lines 14-21: | ||
Error: Failed to verify the Move module, reason: "Expected exactly one parameter for _::M::init of type &mut Sui::TxContext::TxContext". |
21 changes: 21 additions & 0 deletions
21
crates/sui-verifier-transactional-tests/tests/init/must_have_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,21 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
init() { | ||
label l0: | ||
abort 0; | ||
} | ||
} | ||
|
||
|
||
//# publish | ||
module 0x0.M { | ||
import 0x2.TxContext; | ||
init(ctx: &mut TxContext.TxContext, ctx2: &mut TxContext.TxContext) { | ||
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