-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathfib-contract.test.ts
30 lines (25 loc) · 1.18 KB
/
fib-contract.test.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
import { expect } from "chai";
import { starknet } from "hardhat";
import { TIMEOUT } from "../constants";
import { getOZAccount } from "../util";
describe("Fib Contract", function () {
this.timeout(TIMEOUT);
it("should declare + deploy + call", async function () {
const account = await getOZAccount();
const contractFactory = await starknet.getContractFactory(
"sample_package_name_FibContract"
);
const txHash = await account.declare(contractFactory, { maxFee: 1e18 });
console.log("Declaration tx hash", txHash);
const initial_balance = 42n;
const fibContract = await account.deploy(contractFactory, { initial_balance });
console.log("Deployment tx hash", fibContract.deployTxHash);
console.log("Deployed to", fibContract.address);
const retrievedBalance = await fibContract.call("get_balance");
expect(retrievedBalance).to.equal(initial_balance);
const fibResult = await fibContract.call("get_fib", { n: 5 });
const expectedLast = 5n;
const expectedSize = 5n;
expect(fibResult).to.deep.equal([[1n, 1n, 2n, 3n, 5n], expectedLast, expectedSize]);
});
});