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.
[transactional tests] Add support for PT Publish and Upgrade commands (…
…MystenLabs#11206) ## Description - Factored out some shared publishing/upgrading logic - Added a "staging" command for publish to compile a package but use it in a later command - Added a set-address command that sets the address via a value or an object ID - Added support for `Publish` and `Upgrade` commands ## Test Plan - Example tests --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
- Loading branch information
Showing
11 changed files
with
624 additions
and
149 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
crates/sui-adapter-transactional-tests/tests/programmable_transaction_examples/publish.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 9 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 3 'programmable'. lines 27-32: | ||
created: object(3,0), object(3,1), object(3,2), object(3,3), object(3,4) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 8876800, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 6 'programmable'. lines 38-40: | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 7 'publish'. lines 42-47: | ||
created: object(7,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 5221200, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 8 'run'. lines 49-49: | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 |
49 changes: 49 additions & 0 deletions
49
crates/sui-adapter-transactional-tests/tests/programmable_transaction_examples/publish.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,49 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// simple test of publish | ||
|
||
//# init --addresses p=0x0 q=0x0 r=0x0 --accounts A | ||
|
||
//# stage-package | ||
module p::m { | ||
public fun foo(x: u64) { | ||
p::n::bar(x) | ||
} | ||
} | ||
module p::n { | ||
public fun bar(x: u64) { | ||
assert!(x == 0, 0); | ||
} | ||
} | ||
|
||
|
||
//# stage-package | ||
module q::m { | ||
public fun x(): u64 { 0 } | ||
} | ||
|
||
|
||
//# programmable --sender A --inputs 10 @A | ||
//> 0: SplitCoins(Gas, [Input(0)]); | ||
//> 1: Publish(q, []); | ||
//> 2: TransferObjects([Result(0)], Input(1)); | ||
//> 3: Publish(p, []); | ||
//> TransferObjects([Result(1), Result(3)], Input(1)) | ||
|
||
//# set-address p object(3,1) | ||
|
||
//# set-address q object(3,0) | ||
|
||
//# programmable --sender A | ||
//> 0: q::m::x(); | ||
//> p::m::foo(Result(0)) | ||
|
||
//# publish --dependencies p q | ||
module r::all { | ||
public fun foo_x() { | ||
p::m::foo(q::m::x()) | ||
} | ||
} | ||
|
||
//# run r::all::foo_x |
41 changes: 41 additions & 0 deletions
41
crates/sui-adapter-transactional-tests/tests/programmable_transaction_examples/upgrade.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,41 @@ | ||
processed 11 tasks | ||
|
||
init: | ||
A: object(0,0) | ||
|
||
task 1 'publish'. lines 8-18: | ||
created: object(1,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 4354800, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 2 'publish'. lines 20-23: | ||
created: object(2,0), object(2,1) | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 5076800, storage_rebate: 0, non_refundable_storage_fee: 0 | ||
|
||
task 3 'publish'. lines 25-28: | ||
created: object(3,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 3442800, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 5 'programmable'. lines 36-41: | ||
created: object(5,0), object(5,1) | ||
mutated: object(0,0), object(2,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 7052800, storage_rebate: 2595780, non_refundable_storage_fee: 26220 | ||
|
||
task 6 'programmable'. lines 43-45: | ||
Error: Transaction Effects Status: Move Runtime Abort. Location: p::n::bar (function index 0) at offset 6, Abort Code: 0 | ||
Execution Error: ExecutionError: ExecutionError { inner: ExecutionErrorInner { kind: MoveAbort(MoveLocation { module: ModuleId { address: p, name: Identifier("n") }, function: 0, instruction: 6, function_name: Some("bar") }, 0), source: Some(VMError { major_status: ABORTED, sub_status: Some(0), message: Some("p::n::bar at offset 6"), exec_state: Some(ExecutionState { stack_trace: [(Some(ModuleId { address: p, name: Identifier("m") }), FunctionDefinitionIndex(0), 1)] }), location: Module(ModuleId { address: p, name: Identifier("n") }), indices: [], offsets: [(FunctionDefinitionIndex(0), 6)] }), command: Some(1) } } | ||
|
||
task 8 'programmable'. lines 49-51: | ||
mutated: object(0,0) | ||
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 9 'publish'. lines 53-58: | ||
created: object(9,0) | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 5768400, storage_rebate: 978120, non_refundable_storage_fee: 9880 | ||
|
||
task 10 'run'. lines 60-60: | ||
mutated: object(0,1) | ||
gas summary: computation_cost: 1000000, storage_cost: 988000, storage_rebate: 978120, non_refundable_storage_fee: 9880 |
60 changes: 60 additions & 0 deletions
60
crates/sui-adapter-transactional-tests/tests/programmable_transaction_examples/upgrade.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,60 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// simple test of upgrade | ||
|
||
//# init --addresses p=0x0 q=0x0 q_2=0x0 r=0x0 s=0x0 --accounts A | ||
|
||
//# publish | ||
module p::m { | ||
public fun foo(x: u64) { | ||
p::n::bar(x) | ||
} | ||
} | ||
module p::n { | ||
public fun bar(x: u64) { | ||
assert!(x == 1, 0); | ||
} | ||
} | ||
|
||
//# publish --upgradeable --sender A | ||
module q::m { | ||
public fun x(): u64 { 0 } | ||
} | ||
|
||
//# publish | ||
module r::m { | ||
public fun y(): u64 { 0 } | ||
} | ||
|
||
//# stage-package --dependencies r | ||
module q_2::m { | ||
public fun x(): u64 { y() + 1 } | ||
public fun y(): u64 { r::m::y() } | ||
} | ||
|
||
//# programmable --sender A --inputs 10 @A object(2,1) 0u8 digest(q_2) | ||
//> 0: sui::package::authorize_upgrade(Input(2), Input(3), Input(4)); | ||
//> 1: SplitCoins(Gas, [Input(0)]); | ||
//> 2: Upgrade(q_2, [sui,std,r], q, Result(0)); | ||
//> TransferObjects([Result(1)], Input(1)); | ||
//> sui::package::commit_upgrade(Input(2), Result(2)) | ||
|
||
//# programmable --sender A | ||
//> 0: q::m::x(); | ||
//> p::m::foo(Result(0)) | ||
|
||
//# set-address q_2 object(5,0) | ||
|
||
//# programmable --sender A | ||
//> 0: q_2::m::x(); | ||
//> p::m::foo(Result(0)) | ||
|
||
//# publish --dependencies p q_2 r | ||
module s::all { | ||
public fun foo_x() { | ||
p::m::foo(q::m::x()) | ||
} | ||
} | ||
|
||
//# run s::all::foo_x |
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
Oops, something went wrong.