-
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.
[functional tests] allow modules published to be used in later transa…
…ctions As stated, this allows modules published in one transaction to be used in all later transactions. The real problem is that the compiler takes a slice of `CompiledModule` as dependencies, but doesn't have a way to fetch one from the storage. This patch workarounds this limitation by adding modules published to an ever-growing list of dependencies for a given sequence of transactions. It should be pointed out this is a bit hacky and should be replaced by a proper implementation of fetching in the future. Known glitch caused by this: the compiler does not differentiate two modules with same name under different addresses.
- Loading branch information
1 parent
23ec306
commit 20abaaa
Showing
2 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
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
46 changes: 46 additions & 0 deletions
46
...nctional_tests/tests/testsuite/examples/use_module_published_in_previous_transaction.mvir
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,46 @@ | ||
//! account: alice | ||
//! account: bob | ||
|
||
//! sender: alice | ||
modules: | ||
module M { | ||
public foo(x: u64): u64 { | ||
return move(x)*2; | ||
} | ||
|
||
public bar(x: u64, y: u64): u64 { | ||
return move(x) + move(y); | ||
} | ||
} | ||
script: | ||
main() { | ||
return; | ||
} | ||
|
||
|
||
|
||
//! new-transaction | ||
//! sender: alice | ||
|
||
import {{alice}}.M; | ||
|
||
main() { | ||
let x: u64; | ||
x = M.foo(3); | ||
assert(move(x) == 6, 42); | ||
return; | ||
} | ||
|
||
|
||
|
||
//! new-transaction | ||
//! sender: bob | ||
|
||
import {{alice}}.M; | ||
|
||
main() { | ||
let x: u64; | ||
x = M.bar(1, 2); | ||
assert(move(x) == 3, 42); | ||
return; | ||
} |