-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathresolve-compute-limit.test.js
49 lines (46 loc) · 1.25 KB
/
resolve-compute-limit.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
import {
initInteraction,
pipe,
makeTransaction,
} from "../interaction/interaction"
import {config} from "@onflow/config"
import {resolveComputeLimit} from "./resolve-compute-limit.js"
describe("resolveComputeLimit", () => {
test("transaction compute limit has priority", async () => {
const TRANSACTION_COMPUTE_LIMIT = 1234
const CONFIG_COMPUTE_LIMIT = 4321
await config.overload(
{
"fcl.limit": CONFIG_COMPUTE_LIMIT,
},
async () => {
const ix = await pipe([
makeTransaction,
ix => ({
...ix,
message: {
...ix.message,
computeLimit: TRANSACTION_COMPUTE_LIMIT,
},
}),
resolveComputeLimit,
])(initInteraction())
expect(ix.message.computeLimit).toBe(TRANSACTION_COMPUTE_LIMIT)
}
)
})
test("config compute limit is used if exists", async () => {
const CONFIG_COMPUTE_LIMIT = 4321
await config.overload(
{
"fcl.limit": CONFIG_COMPUTE_LIMIT,
},
async () => {
const ix = await pipe([makeTransaction, resolveComputeLimit])(
initInteraction()
)
expect(ix.message.computeLimit).toBe(CONFIG_COMPUTE_LIMIT)
}
)
})
})