Skip to content

Commit

Permalink
[verifier] Migrate struct_with_key tests (MystenLabs#1991)
Browse files Browse the repository at this point in the history
- Migrated to expected output tests
  • Loading branch information
tnowacki authored May 17, 2022
1 parent 6a5c379 commit 553a4cf
Show file tree
Hide file tree
Showing 22 changed files with 152 additions and 171 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"crates/sui-transactional-test-runner",
"crates/sui-types",
"crates/sui-verifier",
"crates/sui-verifier-transactional-tests",
"crates/x",
"sui",
"sui/open_rpc",
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-adapter-transactional-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "sui-adapter-transactional-tests"
version = "0.1.0"
authors = ["Mysten Labs <[email protected]>"]
description = "Adapter and accompanying CLI for local sui development"
description = "Transactional tests for Sui Adapter"
license = "Apache-2.0"
publish = false
edition = "2021"
Expand Down
26 changes: 12 additions & 14 deletions crates/sui-transactional-test-runner/src/test_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,6 @@ impl<'a> MoveTestAdapter<'a> for SuiTestAdapter<'a> {
extra: Self::ExtraPublishArgs,
) -> anyhow::Result<(Option<String>, CompiledModule)> {
let SuiPublishArgs { sender } = extra;
let named_addr = named_addr_opt.expect(
"Cannot publish without a named address. \
This named address will be associated with the published package",
);
let module_name = module.self_id().name().to_string();
let module_bytes = {
let mut buf = vec![];
Expand All @@ -234,17 +230,19 @@ impl<'a> MoveTestAdapter<'a> for SuiTestAdapter<'a> {
})
.unwrap();
let package_addr = NumericalAddress::new(created_package.into_bytes(), NumberFormat::Hex);
let prev_package = self
.compiled_state
.named_address_mapping
.insert(named_addr.to_string(), package_addr);
match prev_package.map(|a| a.into_inner()) {
Some(addr) if addr != AccountAddress::ZERO => panic!(
"Cannot reuse named address '{}' for multiple packages. \
if let Some(named_addr) = named_addr_opt {
let prev_package = self
.compiled_state
.named_address_mapping
.insert(named_addr.to_string(), package_addr);
match prev_package.map(|a| a.into_inner()) {
Some(addr) if addr != AccountAddress::ZERO => panic!(
"Cannot reuse named address '{}' for multiple packages. \
It should be set to 0 initially",
named_addr
),
_ => (),
named_addr
),
_ => (),
}
}
let view_events = false;
let output = self.object_summary_output(&summary, view_events);
Expand Down
16 changes: 16 additions & 0 deletions crates/sui-verifier-transactional-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "sui-verifier-transactional-tests"
version = "0.1.0"
authors = ["Mysten Labs <[email protected]>"]
description = "Transactional tests for Sui Verifier"
license = "Apache-2.0"
publish = false
edition = "2021"

[dev-dependencies]
datatest-stable = "0.1.1"
sui-transactional-test-runner = { path = "../sui-transactional-test-runner" }

[[test]]
name = "tests"
harness = false
6 changes: 6 additions & 0 deletions crates/sui-verifier-transactional-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

#![forbid(unsafe_code)]

// Empty src/lib.rs to get rusty-tags working.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
processed 1 task

task 0 'publish'. lines 4-10:
Error: Failed to verify the Move module, reason: "First field of struct S must be 'id', flag found".
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct S has key {
flag: bool
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
processed 1 task

task 0 'publish'. lines 4-11:
Error: Failed to verify the Move module, reason: "First field of struct S must be of type Sui::ID::VersionedID, _::ID::VersionedID type found".
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.ID {
import 0x2.ID;
struct VersionedID has store { flag: bool }
struct S has key {
id: Self.VersionedID
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
processed 1 task

task 0 'publish'. lines 4-10:
Error: Failed to verify the Move module, reason: "First field of struct S must be of type Sui::ID::VersionedID, Sui::ID::ID type found".
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct S has key {
id: ID.ID
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
processed 1 task

task 0 'publish'. lines 4-10:
Error: Failed to verify the Move module, reason: "First field of struct S must be of ID type, Bool type found".
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct S has key {
id: bool
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
processed 1 task

task 0 'publish'. lines 4-10:
created: object(103)
written: object(102)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct S has key {
id: ID.VersionedID
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
processed 1 task

task 0 'publish'. lines 4-11:
Error: Failed to verify the Move module, reason: "First field of struct S must be 'id', flag found".
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct S has key {
flag: bool,
id: ID.VersionedID,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
processed 1 task

task 0 'publish'. lines 4-10:
Error: Failed to verify the Move module, reason: "Struct S cannot have both key and drop abilities".
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# publish
module 0x0.M {
import 0x2.ID;
struct S has key, drop {
flag: bool
}
}
7 changes: 7 additions & 0 deletions crates/sui-verifier-transactional-tests/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

pub const TEST_DIR: &str = "tests";
use sui_transactional_test_runner::run_test;

datatest_stable::harness!(run_test, TEST_DIR, r".*\.(mvir|move)$");
156 changes: 0 additions & 156 deletions crates/sui-verifier/tests/struct_with_key_verification_test.rs

This file was deleted.

0 comments on commit 553a4cf

Please sign in to comment.