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.
[adapter] Fix bug for unwrapped but never stored object (MystenLabs#4231
) - Fixed a bug where objects where an invariant violation was thrown for unwrapped objects that did not have a last known version - For deleted unwrapped, we no longer emit a deleted event - For transferred unwrapped, we now mark it as newly created
- Loading branch information
Showing
5 changed files
with
154 additions
and
27 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
crates/sui-adapter-transactional-tests/tests/child_count/unwrap_never_stored.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,16 @@ | ||
processed 4 tasks | ||
|
||
init: | ||
A: object(100), B: object(101) | ||
|
||
task 1 'publish'. lines 8-38: | ||
created: object(105) | ||
written: object(104) | ||
|
||
task 2 'run'. lines 40-40: | ||
created: object(107) | ||
written: object(106) | ||
|
||
task 3 'run'. lines 42-42: | ||
written: object(108) | ||
deleted: object(107) |
42 changes: 42 additions & 0 deletions
42
crates/sui-adapter-transactional-tests/tests/child_count/unwrap_never_stored.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 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// tests deleting a wrapped object that has never been in storage | ||
|
||
//# init --addresses test=0x0 --accounts A B | ||
|
||
//# publish | ||
|
||
module test::m { | ||
use sui::tx_context::{Self, TxContext}; | ||
|
||
struct S has key, store { | ||
id: sui::object::UID, | ||
} | ||
|
||
struct R has key { | ||
id: sui::object::UID, | ||
s: S, | ||
} | ||
|
||
public entry fun create(ctx: &mut TxContext) { | ||
let parent = sui::object::new(ctx); | ||
let child = S { id: sui::object::new(ctx) }; | ||
sui::transfer::transfer(R { id: parent, s: child }, tx_context::sender(ctx)) | ||
} | ||
|
||
public entry fun delete(r: R) { | ||
let R { id, s } = r; | ||
sui::object::delete(id); | ||
let S { id } = s; | ||
sui::object::delete(id); | ||
} | ||
} | ||
|
||
// | ||
// Test sharing | ||
// | ||
|
||
//# run test::m::create --sender A | ||
|
||
//# run test::m::delete --args object(107) --sender A |
17 changes: 17 additions & 0 deletions
17
crates/sui-adapter-transactional-tests/tests/child_count/unwrap_never_stored_transfer.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,17 @@ | ||
processed 4 tasks | ||
|
||
init: | ||
A: object(100), B: object(101) | ||
|
||
task 1 'publish'. lines 8-37: | ||
created: object(105) | ||
written: object(104) | ||
|
||
task 2 'run'. lines 39-39: | ||
created: object(107) | ||
written: object(106) | ||
|
||
task 3 'run'. lines 41-41: | ||
created: object(109) | ||
written: object(108) | ||
deleted: object(107) |
41 changes: 41 additions & 0 deletions
41
crates/sui-adapter-transactional-tests/tests/child_count/unwrap_never_stored_transfer.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) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// tests transferring a wrapped object that has never previously been in storage | ||
|
||
//# init --addresses test=0x0 --accounts A B | ||
|
||
//# publish | ||
|
||
module test::m { | ||
use sui::tx_context::{Self, TxContext}; | ||
|
||
struct S has key, store { | ||
id: sui::object::UID, | ||
} | ||
|
||
struct R has key { | ||
id: sui::object::UID, | ||
s: S, | ||
} | ||
|
||
public entry fun create(ctx: &mut TxContext) { | ||
let parent = sui::object::new(ctx); | ||
let child = S { id: sui::object::new(ctx) }; | ||
sui::transfer::transfer(R { id: parent, s: child }, tx_context::sender(ctx)) | ||
} | ||
|
||
public entry fun unwrap_and_transfer(r: R, ctx: &mut TxContext) { | ||
let R { id, s } = r; | ||
sui::object::delete(id); | ||
sui::transfer::transfer(s, tx_context::sender(ctx)); | ||
} | ||
} | ||
|
||
// | ||
// Test sharing | ||
// | ||
|
||
//# run test::m::create --sender A | ||
|
||
//# run test::m::unwrap_and_transfer --args object(107) --sender A |
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