Skip to content

Commit 72ac8ed

Browse files
committed
Updated tests to work with github workflows
1 parent 360a375 commit 72ac8ed

File tree

4 files changed

+10
-37
lines changed

4 files changed

+10
-37
lines changed

.github/workflows/node.js.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
with:
2727
node-version: ${{ matrix.node-version }}
2828
cache: 'npm'
29+
- name: Wasm32
30+
run: rustup target add wasm32-unknown-unknown
2931
- run: npm i yarn
3032
- run: yarn
31-
- run: npm test
33+
- run: yarn build
34+
- run: yarn test

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ jobs:
1919
- name: Wasm32
2020
run: rustup target add wasm32-unknown-unknown
2121
- name: Build
22-
run: cargo build --verbose --target wasm32-unknown-unknown
22+
run: cargo build --verbose --target wasm32-unknown-unknown --release
2323
- name: Run tests
2424
run: cargo test --verbose

__tests__/_common.mjs

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,14 @@ if (!globalThis.fetch) {
1414
export async function initCanisters() {
1515
if (context !== undefined) return;
1616
context = new TestContext();
17-
let id = getCanisterId(false, "evm_utils");
18-
await context.deploy(".dfx/local/canisters/evm_utils/evm_utils.wasm", {
19-
id: Principal.from(id),
20-
candid: ".dfx/local/canisters/evm_utils/evm_utils.did"
21-
})
22-
}
23-
24-
25-
export function getCanisterId(useProd, canister) {
26-
let canisterId = null;
27-
28-
if (useProd) {
29-
var data = JSON.parse(fs.readFileSync("../canister_ids.json"))
30-
canisterId = data[canister]["ic"];
31-
32-
} else {
33-
var data = JSON.parse(fs.readFileSync(".dfx/local/canister_ids.json"))
34-
canisterId = data[canister]["local"];
35-
}
36-
37-
console.log(canister + " Canister Id: " + canisterId);
38-
return canisterId;
39-
}
40-
41-
export async function getIdlFactory(canisterName) {
42-
var path = "../.dfx/local/canisters/"+canisterName+"/"+canisterName+".did.js";
43-
let { idlFactory } = await import(path);
44-
45-
return idlFactory;
17+
return await context.deploy("target/wasm32-unknown-unknown/release/evm_utils.wasm")
4618
}
4719

4820
//Returns actor for token canister
4921
export async function getActor(useProd, canisterName) {
50-
await initCanisters();
51-
22+
let canister = await initCanisters();
5223

53-
// let httpAgent = null;
54-
let canisterId = getCanisterId(useProd, canisterName);
55-
let actor = context.getAgent(Principal.anonymous()).getActor(canisterId);
24+
let actor = context.getAgent(Principal.anonymous()).getActor(canister);
5625

5726
return actor;
5827
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
},
2020
"type": "module",
2121
"scripts": {
22-
"test": "node --experimental-vm-modules node_modules/.bin/jest"
22+
"test": "node --experimental-vm-modules node_modules/.bin/jest",
23+
"build": "cargo build --release --target wasm32-unknown-unknown"
2324
}
2425
}

0 commit comments

Comments
 (0)