Skip to content

Commit 9ce203c

Browse files
authored
Merge pull request #3466 from demergent-labs/testing_ai
minor changes while testing AI
2 parents ac7a9e6 + 1c56a4d commit 9ce203c

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

AGENTS.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,29 @@ The Rust code for static binary template creation and manipulation of those temp
1818

1919
Whenever you are working on a feature, unless otherwise noted in the issue or it makes sense not to do this, you should generally use the following commands to test any changes you make by generating the stable and experimental templates, running one or more of the example tests locally, and linting. You should do this BEFORE COMMITTING ANY CHANGES.
2020

21+
### Starting dfx
22+
23+
First check if there is already a running replica:
24+
25+
```
26+
dfx ping
27+
```
28+
29+
If it's running, you'll see output including `"replica_health_status": "healthy"`.
30+
31+
If `dfx` is not available as a command try this:
32+
33+
```
34+
export PATH="$HOME/.local/share/dfx/bin:$PATH"
35+
dfx --version
36+
```
37+
38+
If `dfx` now exists as a command then start up a replica:
39+
40+
```
41+
dfx start --clean --background --artificial-delay 0
42+
```
43+
2144
### Generating the Wasm binary canister templates
2245

2346
Here's how to generate the stable and experimental Wasm binary canister templates with one command. Always run this command from the Azle root directory:
7.29 KB
Binary file not shown.

src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/web_assembly/instantiate.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,7 @@ impl JsFn for NativeFunction {
1818
panic!("conversion from JsValue to JsArrayBuffer failed")
1919
};
2020

21-
let engine = wasmi::Engine::default();
22-
let module = wasmi::Module::new(&engine, &mut &wasm_bytes[..]).unwrap();
23-
24-
let linker = <wasmi::Linker<()>>::new(&engine);
25-
26-
let mut store = wasmi::Store::new(&engine, ());
27-
28-
let instance = linker
29-
.instantiate(&mut store, &module)
30-
.unwrap()
31-
.start(&mut store)
32-
.unwrap();
21+
let (instance, mut store) = instantiate_wasm_module(&wasm_bytes);
3322

3423
let mut exports_js_object = context.new_object();
3524

@@ -193,3 +182,12 @@ impl JsFn for NativeFunction {
193182
instantiated_source_js_object.into()
194183
}
195184
}
185+
186+
fn instantiate_wasm_module(wasm_bytes: &[u8]) -> (wasmi::Instance, wasmi::Store<()>) {
187+
let engine = wasmi::Engine::default();
188+
let module = wasmi::Module::new(&engine, &mut &wasm_bytes[..]).unwrap();
189+
let linker = <wasmi::Linker<()>>::new(&engine);
190+
let mut store = wasmi::Store::new(&engine, ());
191+
let instance = linker.instantiate_and_start(&mut store, &module).unwrap();
192+
(instance, store)
193+
}

0 commit comments

Comments
 (0)