Skip to content

Commit

Permalink
Make test clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
lxfind committed Sep 17, 2024
1 parent 580b929 commit ff1d04a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -1,87 +1,68 @@
processed 13 tasks
processed 12 tasks

task 1, lines 6-19:
task 1, lines 6-23:
//# publish
created: object(1,0)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 5175600, storage_rebate: 0, non_refundable_storage_fee: 0
gas summary: computation_cost: 1000000, storage_cost: 5608800, storage_rebate: 0, non_refundable_storage_fee: 0

task 2, line 21:
//# run Test::M1::create --args 0 @A
task 2, line 25:
//# run Test::M1::create --args 0
created: object(2,0)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 2302800, storage_rebate: 978120, non_refundable_storage_fee: 9880

task 3, line 23:
task 3, line 27:
//# create-checkpoint
Checkpoint created: 1

task 4, line 25:
task 4, line 29:
//# advance-epoch
Epoch advanced: 0

task 5, line 27:
//# run Test::M1::create --args 1 @A
created: object(5,0)
mutated: object(0,0)
gas summary: computation_cost: 1000000, storage_cost: 2302800, storage_rebate: 978120, non_refundable_storage_fee: 9880
task 5, line 31:
//# run Test::M1::mutate --args object(2,0) 1
mutated: object(0,0), object(2,0)
gas summary: computation_cost: 1000000, storage_cost: 2302800, storage_rebate: 2279772, non_refundable_storage_fee: 23028

task 6, line 33:
//# create-checkpoint
Checkpoint created: 3

task 6, lines 29-34:
task 7, lines 35-40:
//# run-graphql
Response: {
"data": {
"object": {
"digest": "Nj3zEXbNMaKqUFUTpaTk3sMinxpRvMwq1WBDRt2L27Q"
"digest": "BMwy6uHLQwfAxLGdMQFWFR5faQkHUnhxDuaLdd3vngpt"
}
}
}

task 7, lines 36-45:
task 8, lines 42-47:
//# run-graphql
Response: {
"data": {
"address": {
"objects": {
"nodes": [
{
"digest": "Nj3zEXbNMaKqUFUTpaTk3sMinxpRvMwq1WBDRt2L27Q"
}
]
}
"object": {
"digest": "D7Sc2kjsUCZBRvwM2ByFZPKAz3EG1m1qyjxpesN1j97f"
}
}
}

task 8, line 47:
//# create-checkpoint
Checkpoint created: 3

task 9, lines 49-51:
task 9, line 49:
//# advance-epoch
Epoch advanced: 1

task 10, lines 52-54:
task 10, lines 51-53:
//# create-checkpoint
Checkpoint created: 5

task 11, lines 55-60:
task 11, lines 54-59:
//# run-graphql --wait-for-checkpoint-pruned 0
Response: {
"data": {
"object": {
"digest": "Nj3zEXbNMaKqUFUTpaTk3sMinxpRvMwq1WBDRt2L27Q"
}
}
}

task 12, lines 62-71:
//# run-graphql
Response: {
"data": {
"address": {
"objects": {
"nodes": []
}
"digest": "BMwy6uHLQwfAxLGdMQFWFR5faQkHUnhxDuaLdd3vngpt"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# init --addresses Test=0x0 A=0x42 --simulator --epochs-to-keep 1
//# init --addresses Test=0x0 --simulator --epochs-to-keep 1

//# publish
module Test::M1 {
Expand All @@ -10,21 +10,27 @@ module Test::M1 {
value: u64,
}

public entry fun create(value: u64, recipient: address, ctx: &mut TxContext) {
public entry fun create(value: u64, ctx: &mut TxContext) {
transfer::public_transfer(
Object { id: object::new(ctx), value },
recipient
ctx.sender(),
)
}

public entry fun mutate(obj: &mut Object, value: u64) {
obj.value = value;
}
}

//# run Test::M1::create --args 0 @A
//# run Test::M1::create --args 0

//# create-checkpoint

//# advance-epoch

//# run Test::M1::create --args 1 @A
//# run Test::M1::mutate --args object(2,0) 1

//# create-checkpoint

//# run-graphql
{
Expand All @@ -35,37 +41,19 @@ module Test::M1 {

//# run-graphql
{
address(address: "@{A}") {
objects {
nodes {
digest
}
}
object(address: "@{obj_2_0}", version: 4) {
digest
}
}

//# create-checkpoint

//# advance-epoch

# We must create a checkpoint so that available checkpoint range is still valid after pruning.
//# create-checkpoint

# After pruning, we can still read the object, but won't be able to read indexed data such as address owned objects.
# After pruning, we can still read all historical objects.
//# run-graphql --wait-for-checkpoint-pruned 0
{
object(address: "@{obj_2_0}", version: 3) {
digest
}
}

//# run-graphql
{
address(address: "@{A}") {
objects {
nodes {
digest
}
}
}
}

0 comments on commit ff1d04a

Please sign in to comment.