Skip to content

Commit

Permalink
[verifier] Migrate global_storage_access tests (MystenLabs#2017)
Browse files Browse the repository at this point in the history
- Migrated global_storage_access Rust tests to expected output tests
  • Loading branch information
tnowacki authored May 17, 2022
1 parent 284c4e5 commit c33c4d6
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
processed 1 task

task 0 'publish'. lines 4-31:
Error: Failed to verify the Move module, reason: "Access to Move global storage is not allowed. Found in function no: [Exists(StructDefinitionIndex(0)), ExistsGeneric(StructDefInstantiationIndex(0)), ImmBorrowGlobal(StructDefinitionIndex(0)), ImmBorrowGlobalGeneric(StructDefInstantiationIndex(0)), MutBorrowGlobal(StructDefinitionIndex(0)), MutBorrowGlobalGeneric(StructDefInstantiationIndex(0)), MoveFrom(StructDefinitionIndex(0)), MoveFromGeneric(StructDefInstantiationIndex(0)), MoveTo(StructDefinitionIndex(0)), MoveToGeneric(StructDefInstantiationIndex(0))]".
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct R has key { id: ID.VersionedID }
struct G<phantom T> has key { id: ID.VersionedID }


no<T>(s: &signer, addr: address, r: Self.R, g: Self.G<T>) acquires R, G {
label l0:
_ = exists<R>(copy(addr));
_ = exists<G<T>>(copy(addr));
_ = borrow_global<R>(copy(addr));
_ = borrow_global<G<T>>(copy(addr));
_ = borrow_global_mut<R>(copy(addr));
_ = borrow_global_mut<G<T>>(copy(addr));
Self.consume<Self.R>(move_from<R>(copy(addr)));
Self.consume<Self.G<T>>(move_from<G<T>>(copy(addr)));
move_to<R>(copy(s), move(r));
move_to<G<T>>(copy(s), move(g));
return;
}

consume<T>(t: T) {
label l0:
abort 0;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
processed 2 tasks

task 0 'publish'. lines 4-15:
Error: Failed to verify the Move module, reason: "Access to Move global storage is not allowed. Found in function no: [ImmBorrowGlobal(StructDefinitionIndex(0))]".

task 1 'publish'. lines 17-27:
Error: Failed to verify the Move module, reason: "Access to Move global storage is not allowed. Found in function no: [ImmBorrowGlobalGeneric(StructDefInstantiationIndex(0))]".
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct R has key { id: ID.VersionedID }

no(addr: address) acquires R {
label l0:
_ = borrow_global<R>(move(addr));
return;
}

}

//# publish
module 0x0.M {
import 0x2.ID;
struct R<phantom T> has key { id: ID.VersionedID }

no<T>(addr: address) acquires R {
label l0:
_ = borrow_global<R<T>>(move(addr));
return;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
processed 2 tasks

task 0 'publish'. lines 4-15:
Error: Failed to verify the Move module, reason: "Access to Move global storage is not allowed. Found in function no: [MutBorrowGlobal(StructDefinitionIndex(0))]".

task 1 'publish'. lines 17-27:
Error: Failed to verify the Move module, reason: "Access to Move global storage is not allowed. Found in function no: [MutBorrowGlobalGeneric(StructDefInstantiationIndex(0))]".
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct R has key { id: ID.VersionedID }

no(addr: address) acquires R {
label l0:
_ = borrow_global_mut<R>(move(addr));
return;
}

}

//# publish
module 0x0.M {
import 0x2.ID;
struct R<phantom T> has key { id: ID.VersionedID }

no<T>(addr: address) acquires R {
label l0:
_ = borrow_global_mut<R<T>>(move(addr));
return;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
processed 2 tasks

task 0 'publish'. lines 4-14:
Error: Failed to verify the Move module, reason: "Access to Move global storage is not allowed. Found in function no: [Exists(StructDefinitionIndex(0))]".

task 1 'publish'. lines 16-25:
Error: Failed to verify the Move module, reason: "Access to Move global storage is not allowed. Found in function no: [ExistsGeneric(StructDefInstantiationIndex(0))]".
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct R has key { id: ID.VersionedID }

no(addr: address): bool {
label l0:
return exists<R>(move(addr));
}

}

//# publish
module 0x0.M {
import 0x2.ID;
struct R<phantom T> has key { id: ID.VersionedID }

no<T>(addr: address): bool {
label l0:
return exists<R<T>>(move(addr));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
processed 2 tasks

task 0 'publish'. lines 4-20:
Error: Failed to verify the Move module, reason: "Access to Move global storage is not allowed. Found in function no: [MoveFrom(StructDefinitionIndex(0))]".

task 1 'publish'. lines 22-38:
Error: Failed to verify the Move module, reason: "Access to Move global storage is not allowed. Found in function no: [MoveFromGeneric(StructDefInstantiationIndex(0))]".
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct R has key { id: ID.VersionedID }

no(addr: address) acquires R {
label l0:
Self.consume<Self.R>(move_from<R>(move(addr)));
return;
}

consume<T>(t: T) {
label l0:
abort 0;
}

}

//# publish
module 0x0.M {
import 0x2.ID;
struct R<phantom T> has key { id: ID.VersionedID }

no<T>(addr: address) acquires R {
label l0:
Self.consume<Self.R<T>>(move_from<R<T>>(move(addr)));
return;
}

consume<T>(t: T) {
label l0:
abort 0;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
processed 2 tasks

task 0 'publish'. lines 4-15:
Error: Failed to verify the Move module, reason: "Access to Move global storage is not allowed. Found in function no: [MoveTo(StructDefinitionIndex(0))]".

task 1 'publish'. lines 17-27:
Error: Failed to verify the Move module, reason: "Access to Move global storage is not allowed. Found in function no: [MoveToGeneric(StructDefInstantiationIndex(0))]".
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct R has key { id: ID.VersionedID }

no(s: &signer, r: Self.R) {
label l0:
move_to<R>(copy(s), move(r));
abort 0;
}

}

//# publish
module 0x0.M {
import 0x2.ID;
struct R<phantom T> has key { id: ID.VersionedID }

no<T>(s: &signer, r: Self.R<T>) {
label l0:
move_to<R<T>>(copy(s), move(r));
abort 0;
}
}

This file was deleted.

0 comments on commit c33c4d6

Please sign in to comment.