-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathsdk.test.js
74 lines (66 loc) · 1.97 KB
/
sdk.test.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import assert from "assert"
import {
build,
resolve,
ref,
transaction,
limit,
proposer,
authorizations,
payer,
authorization,
VERSION,
} from "./sdk"
test("fcl.VERSION needs to match version in package.json", () => {
expect(VERSION).toBe("TESTVERSION")
})
describe("build", () => {
it("returns the correct limit when building a transaction", async () => {
const one = await resolve(
await build([
transaction``,
limit(156),
proposer(authorization("01", () => ({signature: "123"}), 1, 123)),
authorizations([
authorization("01", () => ({signature: "123"}), 1, 123),
]),
payer(authorization("01", () => ({signature: "123"}), 1, 123)),
ref("123"),
])
)
const two = await resolve(
await build([
limit(156),
transaction``,
proposer(authorization("01", () => ({signature: "123"}), 1, 123)),
authorizations([
authorization("01", () => ({signature: "123"}), 1, 123),
]),
payer(authorization("01", () => ({signature: "123"}), 1, 123)),
ref("123"),
])
)
// console.log("one", one)
// console.log("two", two)
assert.equal(one.message.computeLimit, 156)
assert.equal(two.message.computeLimit, 156)
assert.deepEqual(one.message.limit, two.message.limit)
})
it("returns the correct proposer when building a transaction with a known proposer", async () => {
const ix = await resolve(
await build([
transaction``,
proposer(authorization("01", () => ({signature: "123"}), 1, 123)),
authorizations([
authorization("01", () => ({signature: "123"}), 1, 123),
]),
payer(authorization("01", () => ({signature: "123"}), 1, 123)),
ref("123"),
])
)
const txProposer = ix.accounts[ix.proposer]
assert.deepEqual(txProposer.addr, "01")
assert.deepEqual(txProposer.keyId, 1)
assert.deepEqual(txProposer.sequenceNum, 123)
})
})