-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
143 additions
and
0 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
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
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
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,9 @@ | ||
use ckb_js_tests::read_tx_template; | ||
|
||
pub fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let tx = read_tx_template("templates/fs_module_mount.json")?; | ||
|
||
let json = serde_json::to_string_pretty(&tx).unwrap(); | ||
println!("{}", json); | ||
Ok(()) | ||
} |
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,75 @@ | ||
{ | ||
"mock_info": { | ||
"inputs": [ | ||
{ | ||
"output": { | ||
"capacity": "0x10000000", | ||
"lock": { | ||
"args": "0x0000{{ ref_type js-code-file }}01", | ||
"code_hash": "0x{{ ref_type ckb-js-vm }}", | ||
"hash_type": "type" | ||
}, | ||
"type": null | ||
}, | ||
"data": "0x" | ||
} | ||
], | ||
"cell_deps": [ | ||
{ | ||
"output": { | ||
"capacity": "0x10000000", | ||
"lock": { | ||
"args": "0x00AE9DF3447C404A645BC48BEA4B7643B95AC5C3AE", | ||
"code_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"hash_type": "data1" | ||
}, | ||
"type": "{{ def_type ckb-js-vm }}" | ||
}, | ||
"data": "0x{{ data ../../../build/ckb-js-vm }}" | ||
}, | ||
{ | ||
"output": { | ||
"capacity": "0x10000000", | ||
"lock": { | ||
"args": "0x00AE9DF3447C404A645BC48BEA4B7643B95AC5C3AE", | ||
"code_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"hash_type": "data1" | ||
}, | ||
"type": "{{ def_type js-code-file }}" | ||
}, | ||
"data": "0x{{ data ../test_data/fs_module_mount/main.js }}" | ||
}, | ||
{ | ||
"output": { | ||
"capacity": "0x10000000", | ||
"lock": { | ||
"args": "0x00AE9DF3447C404A645BC48BEA4B7643B95AC5C3AE", | ||
"code_hash": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"hash_type": "data1" | ||
}, | ||
"type": "{{ def_type fib_module }}" | ||
}, | ||
"data": "0x{{ data ../../../build/fib_module.bin }}" | ||
} | ||
], | ||
"header_deps": [] | ||
}, | ||
"tx": { | ||
"outputs": [ | ||
{ | ||
"capacity": "0x0", | ||
"lock": { | ||
"args": "0x00AE9DF3447C404A645BC48BEA4B7643B95AC5C3AE", | ||
"code_hash": "0x{{ ref_type ckb-js-vm }}", | ||
"hash_type": "type" | ||
} | ||
} | ||
], | ||
"witnesses": [ | ||
"0x55000000100000005500000055000000410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" | ||
], | ||
"outputs_data": [ | ||
"0x" | ||
] | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/ckb_js_tests/test_data/fs_module_mount/fib_module.js
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,10 @@ | ||
/* fib module */ | ||
export function fib(n) | ||
{ | ||
if (n <= 0) | ||
return 0; | ||
else if (n == 1) | ||
return 1; | ||
else | ||
return fib(n - 1) + fib(n - 2); | ||
} |
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,11 @@ | ||
/* example of JS module */ | ||
|
||
ckb.mount(2, 3) | ||
|
||
import('./fib_module.js') | ||
.then((module) => { | ||
console.log("fib(10)=", module.fib(10)) | ||
}) | ||
.catch((err) => { | ||
console.log(err) | ||
}); |