forked from move-language/move
-
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.
[move-cli][test] trigger the cyclic check on the VM side
The goal of this test case is to check that the VM properly rejects a module with cyclic dependencies even in the multi-module publishing setting. Here is the procedure: 1. publish two modules with dependencies `B --depends_on--> A`. (See the code in package `p1`) 2. compile a set of modules with dependencies `A --may_use--> C --depends_on--> B'` (See the code in package `p2`) NOTE that module `B'` is an update to module `B` with dependency to module `A` removed. We need this tweak here, otherwise, the compiler will flag the cyclic dependency and we can never reach the publishing step to test the VM. 3. publish the modules compiled in step 2, but only module `A` and `C` with the `--override-ordering` flag. Without this flag, all modules will be published. This will trigger the check on the VM side and the VM aborts correctly with `INVALID_FRIEND_DECL_WITH_MODULES_IN_DEPENDENCIES Closes: move-language#39
- Loading branch information
1 parent
927c229
commit 7dc417f
Showing
7 changed files
with
44 additions
and
17 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
language/tools/move-cli/tests/testsuite/cyclic_multi_module_publish/README.md
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,26 @@ | ||
## Test Case Explanation | ||
|
||
The goal of this test case is to check that the VM properly rejects a module | ||
with cyclic dependencies even in the multi-module publishing setting. | ||
|
||
Here is the procedure: | ||
|
||
1. publish two modules with dependencies `B --depends_on--> A`. | ||
|
||
(See the code in package `p1`) | ||
|
||
|
||
2. compile a set of modules with dependencies `A --may_use--> C --depends_on--> B'` | ||
|
||
(See the code in package `p2`) | ||
|
||
NOTE that module `B'` is an update to module `B` with dependency to module | ||
`A` removed. We need this tweak here, otherwise, the compiler will flag the | ||
cyclic dependency and we can never reach the publishing step to test the VM. | ||
|
||
|
||
3. publish the modules compiled in step 2, but only module `A` and `C` with the | ||
`--override-ordering` flag. Without this flag, all modules will be published. | ||
|
||
This will trigger the check on the VM side and the VM aborts correctly with | ||
`INVALID_FRIEND_DECL_WITH_MODULES_IN_DEPENDENCIES`. |
22 changes: 8 additions & 14 deletions
22
language/tools/move-cli/tests/testsuite/cyclic_multi_module_publish/args.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 |
---|---|---|
@@ -1,14 +1,8 @@ | ||
Command `sandbox publish --override-ordering A --override-ordering B -v`: | ||
error[E02004]: invalid 'module' declaration | ||
┌─ ./sources/CyclicFriendsPart2.move:8:24 | ||
│ | ||
7 │ friend 0x3::A; | ||
│ -------------- '0x3::A' is a friend of '0x3::C' | ||
8 │ public fun foo() { 0x3::B::foo() } | ||
│ ^^^^^^^^^^^ '0x3::B' uses '0x3::C'. This 'use' relationship creates a dependency cycle. | ||
│ | ||
┌─ ./sources/CyclicFriendsPart1.move:6:24 | ||
│ | ||
6 │ public fun foo() { 0x3::A::foo() } | ||
│ ----------- '0x3::A' uses '0x3::B' | ||
|
||
Command `-p p1 sandbox publish --override-ordering A --override-ordering B -v`: | ||
Found 2 modules | ||
Publishing a new module 00000000000000000000000000000003::A (wrote 82 bytes) | ||
Publishing a new module 00000000000000000000000000000003::B (wrote 93 bytes) | ||
Wrote 175 bytes of module ID's and code | ||
Command `-p p2 sandbox publish --override-ordering A --override-ordering C -v`: | ||
Found 3 modules | ||
Invalid multi-module publishing: VMError with status INVALID_FRIEND_DECL_WITH_MODULES_IN_DEPENDENCIES at location Module ModuleId { address: 00000000000000000000000000000003, name: Identifier("C") } and message At least one module, 00000000000000000000000000000003::A, appears in both the dependency set and the friend set |
3 changes: 2 additions & 1 deletion
3
language/tools/move-cli/tests/testsuite/cyclic_multi_module_publish/args.txt
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
sandbox publish --override-ordering A --override-ordering B -v | ||
-p p1 sandbox publish --override-ordering A --override-ordering B -v | ||
-p p2 sandbox publish --override-ordering A --override-ordering C -v |
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
language/tools/move-cli/tests/testsuite/cyclic_multi_module_publish/p2/Move.toml
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,3 @@ | ||
[package] | ||
name = "cyclic_multi_module_publish" | ||
version = "0.0.0" |
7 changes: 5 additions & 2 deletions
7
...e_publish/sources/CyclicFriendsPart2.move → ...ublish/p2/sources/CyclicFriendsPart2.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