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.
[tests][programmable transactions] Add tests for MakeMoveVec (MystenL…
…abs#9454) ## Description - Added transactional tests for objects - Added "generated" tests for primitive types - BCS bytes are now always checked for `MakeMoveVec` primitive arguments. And checked before args reach the VM. This isn't strictly necessary for safety, but provides a more predicable UX. ## Test Plan - It is 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 - [X] breaking change for FNs (FN binary must upgrade) - [X] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [X] necessitate either a data wipe or data migration ### Release notes
- Loading branch information
Showing
13 changed files
with
691 additions
and
116 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.
30 changes: 30 additions & 0 deletions
30
crates/sui-adapter-transactional-tests/tests/programmable/make_vec_objects.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,30 @@ | ||
processed 8 tasks | ||
|
||
init: | ||
A: object(100), B: object(101) | ||
|
||
task 1 'publish'. lines 8-47: | ||
created: object(106) | ||
written: object(105) | ||
|
||
task 2 'programmable'. lines 48-55: | ||
written: object(107) | ||
|
||
task 3 'programmable'. lines 56-63: | ||
written: object(108) | ||
|
||
task 4 'programmable'. lines 64-68: | ||
written: object(109) | ||
|
||
task 5 'programmable'. lines 69-71: | ||
created: object(111) | ||
written: object(110) | ||
|
||
task 6 'view-object'. lines 73-73: | ||
Owner: Account Address ( A ) | ||
Version: 2 | ||
Contents: test::m1::Pub {id: sui::object::UID {id: sui::object::ID {bytes: fake(111)}}, value: 112u64} | ||
|
||
task 7 'programmable'. lines 75-81: | ||
written: object(112) | ||
deleted: object(111) |
81 changes: 81 additions & 0 deletions
81
crates/sui-adapter-transactional-tests/tests/programmable/make_vec_objects.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,81 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// tessts various vector instantions with objects | ||
|
||
//# init --addresses test=0x0 --accounts A B | ||
|
||
//# publish | ||
module test::m1 { | ||
use sui::object::{Self, UID}; | ||
use sui::tx_context::TxContext; | ||
use std::vector; | ||
|
||
struct Pub has key, store { | ||
id: UID, | ||
value: u64, | ||
} | ||
|
||
struct Cap {} | ||
|
||
struct Cup<T> has key, store { | ||
id: UID, | ||
value: T, | ||
} | ||
|
||
public fun new(ctx: &mut TxContext): Pub { | ||
Pub { id: object::new(ctx), value: 112 } | ||
} | ||
|
||
public fun cup<T>(value: T, ctx: &mut TxContext): Cup<T> { | ||
Cup { id: object::new(ctx), value } | ||
} | ||
|
||
public fun cap(): Cap { | ||
Cap {} | ||
} | ||
|
||
public fun pubs(v: vector<Pub>) { | ||
while (!vector::is_empty(&v)) { | ||
let Pub { id, value: _ } = vector::pop_back(&mut v); | ||
object::delete(id); | ||
}; | ||
vector::destroy_empty(v); | ||
} | ||
} | ||
|
||
// objects | ||
//# programmable --sender A | ||
//> 0: test::m1::new(); | ||
//> 1: test::m1::new(); | ||
//> 2: test::m1::new(); | ||
//> 3: MakeMoveVec([Result(0), Result(1), Result(2)]); | ||
//> test::m1::pubs(Result(3)); | ||
|
||
// annotated objects | ||
//# programmable --sender A | ||
//> 0: test::m1::new(); | ||
//> 1: test::m1::new(); | ||
//> 2: test::m1::new(); | ||
//> 3: MakeMoveVec<test::m1::Pub>([Result(0), Result(1), Result(2)]); | ||
//> test::m1::pubs(Result(3)); | ||
|
||
// empty objects | ||
//# programmable --sender A | ||
//> 0: MakeMoveVec<test::m1::Pub>([]); | ||
//> test::m1::pubs(Result(0)); | ||
|
||
// mixed new and old. Send an object to A and mix it in a vector with the newly created ones. | ||
//# programmable --sender A --inputs @A | ||
//> 0: test::m1::new(); | ||
//> TransferObjects([Result(0)], Input(0)); | ||
|
||
//# view-object 111 | ||
|
||
//# programmable --sender A --inputs object(111) | ||
//> 0: test::m1::new(); | ||
//> 1: test::m1::new(); | ||
//> 2: test::m1::new(); | ||
// use Input and new objects | ||
//> 3: MakeMoveVec([Result(0), Result(1), Input(0), Result(2)]); | ||
//> test::m1::pubs(Result(3)); |
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.