-
Notifications
You must be signed in to change notification settings - Fork 647
/
pox_Commands.ts
61 lines (59 loc) · 1.52 KB
/
pox_Commands.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
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
import fc from "fast-check";
import { Real, Stub, StxAddress, Wallet } from "./pox_CommandModel";
import { GetStackingMinimumCommand } from "./pox_GetStackingMinimumCommand";
import { GetStxAccountCommand } from "./pox_GetStxAccountCommand";
import { StackStxCommand } from "./pox_StackStxCommand";
export function PoxCommands(
wallets: Map<StxAddress, Wallet>,
): fc.Arbitrary<Iterable<fc.Command<Stub, Real>>> {
const cmds = [
// GetStackingMinimumCommand
fc.record({
wallet: fc.constantFrom(...wallets.values()),
}).map((
r: {
wallet: Wallet;
},
) =>
new GetStackingMinimumCommand(
r.wallet,
)
),
// StackStxCommand
fc.record({
wallet: fc.constantFrom(...wallets.values()),
authId: fc.nat(),
period: fc.integer({ min: 1, max: 7 }),
margin: fc.integer({ min: 2, max: 9 }),
}).map((
r: {
wallet: Wallet;
authId: number;
period: number;
margin: number;
},
) =>
new StackStxCommand(
r.wallet,
r.authId,
r.period,
r.margin,
)
),
// GetStxAccountCommand
fc.record({
wallet: fc.constantFrom(...wallets.values()),
}).map((
r: {
wallet: Wallet;
},
) =>
new GetStxAccountCommand(
r.wallet,
)
),
];
// More on size: https://github.com/dubzzz/fast-check/discussions/2978
// More on cmds: https://github.com/dubzzz/fast-check/discussions/3026
return fc.commands(cmds, { size: "large" });
}