forked from near/near-sdk-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-highlevel-minimal.ava.js
60 lines (47 loc) · 1.63 KB
/
test-highlevel-minimal.ava.js
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
55
56
57
58
59
60
import { Worker } from "near-workspaces";
import test from "ava";
import { generateGasObject, logTestResults } from "./util.js";
import { addTestResults } from "./results-store.js";
test.before(async (t) => {
// Init the worker and start a Sandbox server
const worker = await Worker.init();
// Prepare sandbox for tests, create accounts, deploy contracts, etx.
const root = worker.rootAccount;
// Deploy the test contract.
const highlevelContract = await root.devDeploy(
"build/highlevel-minimal.wasm"
);
const highlevelContractRs = await root.devDeploy(
"res/highlevel_minimal.wasm"
);
// Test users
const ali = await root.createSubAccount("ali");
const bob = await root.createSubAccount("bob");
const carl = await root.createSubAccount("carl");
// Save state for test runs
t.context.worker = worker;
t.context.accounts = {
root,
highlevelContract,
highlevelContractRs,
ali,
bob,
carl,
};
});
test("JS highlevel minimal contract", async (t) => {
const { bob, highlevelContract } = t.context.accounts;
let r = await bob.callRaw(highlevelContract, "empty", "");
t.is(r.result.status.SuccessValue, "");
logTestResults(r);
const gasObject = generateGasObject(r, true);
addTestResults("JS_highlevel_minimal_contract", gasObject);
});
test("RS highlevel minimal contract", async (t) => {
const { bob, highlevelContractRs } = t.context.accounts;
let r = await bob.callRaw(highlevelContractRs, "empty", "");
t.is(r.result.status.SuccessValue, "");
logTestResults(r);
const gasObject = generateGasObject(r, true);
addTestResults("RS_highlevel_minimal_contract", gasObject);
});