This repository has been archived by the owner on Aug 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtest.spec.ts
54 lines (45 loc) · 1.7 KB
/
test.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Testing your code using the hard hat StarkNet plugin
// You will find more information on testing in Hard Hat by following this link https://github.com/Shard-Labs/starknet-hardhat-plugin#testing
import { expect } from "chai";
import { starknet } from "hardhat";
import {
StarknetContract,
StarknetContractFactory,
} from "hardhat/types/runtime";
const toStruct = (first: number, second: number) => {
return { first_member: first, second_member: second };
};
const ARRAY = [1, 2, 3, 4, 5, 6];
describe("Testing the contracts", async function () {
this.timeout(6_000_000);
let mockContractFactory: StarknetContractFactory;
let mockContract: StarknetContract;
let arrayContractFactory: StarknetContractFactory;
let arrayContract: StarknetContract;
before(async () => {
arrayContractFactory = await starknet.getContractFactory("array_contract");
arrayContract = await arrayContractFactory.deploy();
mockContractFactory = await starknet.getContractFactory("mock_contract");
mockContract = await mockContractFactory.deploy({
array: ARRAY,
});
});
describe("Test that you debugged the mock contract correctly", async () => {
it("Let's see if you made it", async () => {
expect(
(
await arrayContract.call("view_product", {
array: [toStruct(1, 2), toStruct(3, 4)],
})
).res
).to.deep.eq(BigInt(arrayContract.address) + BigInt(24));
});
});
describe("Test that you debugged the array contract correctly", async () => {
it("Let's see if you made it", async () => {
expect((await mockContract.call("product_mapping")).res).to.deep.eq(
BigInt(ARRAY.reduce((a, b) => a * b, 1))
);
});
});
});