-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample-test.ts
More file actions
49 lines (40 loc) · 1.64 KB
/
sample-test.ts
File metadata and controls
49 lines (40 loc) · 1.64 KB
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
import { expect } from "chai";
import { Contract, Signer } from "locklift";
import { FactorySource } from "../build/factorySource";
let sample: Contract<FactorySource["Sample"]>;
let signer: Signer;
describe("Test Sample contract", async function () {
before(async () => {
signer = (await locklift.keystore.getSigner("0"))!;
});
describe("Contracts", async function () {
it("Load contract factory", async function () {
const sampleData = await locklift.factory.getContractArtifacts("Sample");
expect(sampleData.code).not.to.equal(undefined, "Code should be available");
expect(sampleData.abi).not.to.equal(undefined, "ABI should be available");
expect(sampleData.tvc).not.to.equal(undefined, "tvc should be available");
});
it("Deploy contract", async function () {
const INIT_STATE = 0;
const { contract } = await locklift.factory.deployContract({
contract: "Sample",
publicKey: signer.publicKey,
initParams: {
_nonce: locklift.utils.getRandomNonce(),
},
constructorParams: {
_state: INIT_STATE,
},
value: locklift.utils.toNano(2),
});
sample = contract;
expect(await locklift.provider.getBalance(sample.address).then(balance => Number(balance))).to.be.above(0);
});
it("Interact with contract", async function () {
const NEW_STATE = 1;
await sample.methods.setState({ _state: NEW_STATE }).sendExternal({ publicKey: signer.publicKey });
const response = await sample.methods.getDetails({}).call();
expect(Number(response._state)).to.be.equal(NEW_STATE, "Wrong state");
});
});
});