This repository was archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathchannelMastercopy.spec.ts
More file actions
78 lines (68 loc) · 2.89 KB
/
channelMastercopy.spec.ts
File metadata and controls
78 lines (68 loc) · 2.89 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
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
75
76
77
78
import { expect } from "@connext/vector-utils";
import { AddressZero, HashZero, Zero } from "@ethersproject/constants";
import { deployments } from "hardhat";
import { ChannelMastercopy } from "../../typechain";
import { alice } from "../constants";
import { getContract } from "../utils";
describe("ChannelMastercopy", function () {
this.timeout(120_000);
let mastercopy: ChannelMastercopy;
beforeEach(async () => {
await deployments.fixture(); // Start w fresh deployments
mastercopy = await getContract("ChannelMastercopy", alice);
});
it("should deploy without error", async () => {
expect(mastercopy.address).to.be.a("string");
});
it("all public methods should revert bc it's the mastercopy", async () => {
const BalanceZero = [
[Zero, Zero],
[AddressZero, AddressZero],
];
const WithdrawDataZero = [AddressZero, AddressZero, AddressZero, Zero, Zero, AddressZero, Zero, "0x"];
const CoreChannelStateZero = [AddressZero, AddressZero, AddressZero, [], [], [], [], [], Zero, Zero, HashZero];
const CoreTransferStateZero = [
AddressZero,
HashZero,
AddressZero,
AddressZero,
AddressZero,
AddressZero,
BalanceZero,
Zero,
HashZero,
];
for (const method of [
// from ICMCCore
{ name: "setup", args: [AddressZero, AddressZero] },
{ name: "getAlice", args: [] },
{ name: "getBob", args: [] },
// from ICMCAsset
{ name: "getTotalTransferred", args: [AddressZero] },
{ name: "getExitableAmount", args: [AddressZero, AddressZero] },
{ name: "exit", args: [AddressZero, AddressZero, AddressZero] },
// from ICMCDeposit
{ name: "getTotalDepositsAlice", args: [AddressZero] },
{ name: "getTotalDepositsBob", args: [AddressZero] },
{ name: "depositAlice", args: [AddressZero, Zero /*, HashZero */] },
// from ICMCWithdraw
{ name: "getWithdrawalTransactionRecord", args: [WithdrawDataZero] },
{ name: "withdraw", args: [WithdrawDataZero, HashZero, HashZero] },
// from ICMCAdjudicator
{ name: "getChannelDispute", args: [] },
{ name: "getDefundNonce", args: [AddressZero] },
{ name: "getTransferDispute", args: [HashZero] },
{ name: "disputeChannel", args: [CoreChannelStateZero, HashZero, HashZero] },
{ name: "defundChannel", args: [CoreChannelStateZero, [AddressZero], [Zero]] },
{ name: "disputeTransfer", args: [CoreTransferStateZero, []] },
{ name: "defundTransfer", args: [CoreTransferStateZero, HashZero, HashZero, HashZero] },
]) {
await expect((mastercopy as any)[method.name](...method.args)).to.be.revertedWith("Mastercopy: ONLY_VIA_PROXY");
}
});
it("should revert if sent eth bc it's the mastercopy", async () => {
await expect(alice.sendTransaction({ to: mastercopy.address, value: Zero })).to.be.revertedWith(
"Mastercopy: ONLY_VIA_PROXY",
);
});
});