Skip to content

Commit def3a9b

Browse files
committed
Expand & fix
1 parent ce79cf6 commit def3a9b

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

contracts/ZkSync_SpokePool.sol

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ contract ZkSync_SpokePool is SpokePool, CircleCCTPAdapter {
6969
if (address(_zkUSDCBridge) == zero && address(_cctpTokenMessenger) == zero) {
7070
revert InvalidBridgeConfig();
7171
}
72+
73+
// Bridged and Native USDC are mutually exclusive.
74+
if (address(_zkUSDCBridge) != zero && address(_cctpTokenMessenger) != zero) {
75+
revert InvalidBridgeConfig();
76+
}
7277
}
7378

7479
zkUSDCBridge = _zkUSDCBridge;

test/evm/hardhat/chain-specific-spokepools/ZkSync_SpokePool.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
SignerWithAddress,
88
toWei,
99
getContractFactory,
10+
randomAddress,
1011
seedContract,
1112
avmL1ToL2Alias,
1213
} from "../../../../utils/utils";
@@ -73,7 +74,7 @@ describe("ZkSync Spoke Pool", function () {
7374
await owner.sendTransaction({ to: crossDomainAliasAddress, value: toWei("1") });
7475

7576
zkErc20Bridge = await smock.fake(abiData.erc20DefaultBridge.abi, { address: ERC20_BRIDGE });
76-
zkUSDCBridge = zkErc20Bridge;
77+
zkUSDCBridge = await smock.fake(abiData.erc20DefaultBridge.abi, { address: USDC_BRIDGE });
7778
l2Eth = await smock.fake(abiData.eth.abi, { address: abiData.eth.address });
7879
constructorArgs = [
7980
weth.address,
@@ -123,9 +124,42 @@ describe("ZkSync Spoke Pool", function () {
123124
});
124125
await expect(implementation).to.not.be.reverted;
125126

127+
// Configure cctp
128+
_constructorArgs = [...constructorArgs];
129+
_constructorArgs[2] = ZERO_ADDRESS;
130+
_constructorArgs[3] = randomAddress();
131+
implementation = hre.upgrades.deployImplementation(await getContractFactory("ZkSync_SpokePool", owner), {
132+
kind: "uups",
133+
unsafeAllow: ["delegatecall"],
134+
constructorArgs: _constructorArgs,
135+
});
136+
await expect(implementation).to.not.be.reverted;
137+
138+
// Configure bridged USDC
139+
_constructorArgs = [...constructorArgs];
140+
_constructorArgs[3] = ZERO_ADDRESS;
141+
implementation = hre.upgrades.deployImplementation(await getContractFactory("ZkSync_SpokePool", owner), {
142+
kind: "uups",
143+
unsafeAllow: ["delegatecall"],
144+
constructorArgs: _constructorArgs,
145+
});
146+
await expect(implementation).to.not.be.reverted;
147+
148+
// Configure none (misconfigured)
149+
_constructorArgs = [...constructorArgs];
126150
_constructorArgs[2] = ZERO_ADDRESS;
127151
_constructorArgs[3] = ZERO_ADDRESS;
152+
implementation = hre.upgrades.deployImplementation(await getContractFactory("ZkSync_SpokePool", owner), {
153+
kind: "uups",
154+
unsafeAllow: ["delegatecall"],
155+
constructorArgs: _constructorArgs,
156+
});
157+
await expect(implementation).to.be.reverted;
128158

159+
// Configure both (misconfigured)
160+
_constructorArgs = [...constructorArgs];
161+
_constructorArgs[2] = zkUSDCBridge.address;
162+
_constructorArgs[3] = randomAddress();
129163
implementation = hre.upgrades.deployImplementation(await getContractFactory("ZkSync_SpokePool", owner), {
130164
kind: "uups",
131165
unsafeAllow: ["delegatecall"],

0 commit comments

Comments
 (0)