Skip to content

Commit e90fa1f

Browse files
construct tests for proxy deploys
1 parent 84fc440 commit e90fa1f

File tree

4 files changed

+141
-4
lines changed

4 files changed

+141
-4
lines changed

src/concrete/deploy/OffchainAssetReceiptVaultBeaconSetDeployer.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import {
1919

2020
struct OffchainAssetReceiptVaultBeaconSetDeployerConfig {
2121
address initialOwner;
22-
Receipt initialReceiptImplementation;
23-
OffchainAssetReceiptVault initialOffchainAssetReceiptVaultImplementation;
22+
address initialReceiptImplementation;
23+
address initialOffchainAssetReceiptVaultImplementation;
2424
}
2525

2626
contract OffchainAssetReceiptVaultBeaconSetDeployer {

test/abstract/OffchainAssetReceiptVaultTest.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ contract OffchainAssetReceiptVaultTest is Test {
3232
I_DEPLOYER = new OffchainAssetReceiptVaultBeaconSetDeployer(
3333
OffchainAssetReceiptVaultBeaconSetDeployerConfig({
3434
initialOwner: address(this),
35-
initialReceiptImplementation: I_RECEIPT_IMPLEMENTATION,
36-
initialOffchainAssetReceiptVaultImplementation: I_IMPLEMENTATION
35+
initialReceiptImplementation: address(I_RECEIPT_IMPLEMENTATION),
36+
initialOffchainAssetReceiptVaultImplementation: address(I_IMPLEMENTATION)
3737
})
3838
);
3939
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// SPDX-License-Identifier: LicenseRef-DCL-1.0
2+
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
3+
pragma solidity =0.8.25;
4+
5+
import {Test} from "forge-std/Test.sol";
6+
7+
import {
8+
ERC20PriceOracleReceiptVaultCloneDeployer,
9+
ERC20PriceOracleReceiptVaultCloneDeployerConfig
10+
} from "src/concrete/deploy/ERC20PriceOracleReceiptVaultCloneDeployer.sol";
11+
import {ZeroReceiptImplementation, ZeroVaultImplementation} from "src/error/ErrDeployer.sol";
12+
13+
contract ERC20PriceOracleReceiptVaultCloneDeployerConstructTest is Test {
14+
function testERC20PriceOracleReceiptVaultCloneDeployerConstructZeroReceiptImplementation(
15+
address erc20PriceOracleReceiptVaultImplementation
16+
) external {
17+
vm.assume(erc20PriceOracleReceiptVaultImplementation != address(0));
18+
vm.expectRevert(abi.encodeWithSelector(ZeroReceiptImplementation.selector));
19+
new ERC20PriceOracleReceiptVaultCloneDeployer(
20+
ERC20PriceOracleReceiptVaultCloneDeployerConfig({
21+
receiptImplementation: address(0),
22+
erc20PriceOracleReceiptVaultImplementation: erc20PriceOracleReceiptVaultImplementation
23+
})
24+
);
25+
}
26+
27+
function testERC20PriceOracleReceiptVaultCloneDeployerConstructZeroVaultImplementation(
28+
address receiptImplementation
29+
) external {
30+
vm.assume(receiptImplementation != address(0));
31+
vm.expectRevert(abi.encodeWithSelector(ZeroVaultImplementation.selector));
32+
new ERC20PriceOracleReceiptVaultCloneDeployer(
33+
ERC20PriceOracleReceiptVaultCloneDeployerConfig({
34+
receiptImplementation: receiptImplementation,
35+
erc20PriceOracleReceiptVaultImplementation: address(0)
36+
})
37+
);
38+
}
39+
40+
function testERC20PriceOracleReceiptVaultCloneDeployerConstruct(
41+
ERC20PriceOracleReceiptVaultCloneDeployerConfig memory config
42+
) external {
43+
vm.assume(config.receiptImplementation != address(0));
44+
vm.assume(config.erc20PriceOracleReceiptVaultImplementation != address(0));
45+
46+
ERC20PriceOracleReceiptVaultCloneDeployer deployer = new ERC20PriceOracleReceiptVaultCloneDeployer(config);
47+
48+
vm.assertEq(deployer.I_RECEIPT_IMPLEMENTATION(), config.receiptImplementation);
49+
vm.assertEq(
50+
deployer.I_ERC20_PRICE_ORACLE_RECEIPT_VAULT_IMPLEMENTATION(),
51+
config.erc20PriceOracleReceiptVaultImplementation
52+
);
53+
}
54+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// SPDX-License-Identifier: LicenseRef-DCL-1.0
2+
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
3+
pragma solidity =0.8.25;
4+
5+
import {Test} from "forge-std/Test.sol";
6+
7+
import {
8+
OffchainAssetReceiptVaultBeaconSetDeployer,
9+
OffchainAssetReceiptVaultBeaconSetDeployerConfig
10+
} from "src/concrete/deploy/OffchainAssetReceiptVaultBeaconSetDeployer.sol";
11+
import {ZeroReceiptImplementation, ZeroVaultImplementation, ZeroBeaconOwner} from "src/error/ErrDeployer.sol";
12+
import {OffchainAssetReceiptVault} from "src/concrete/vault/OffchainAssetReceiptVault.sol";
13+
import {Receipt as ReceiptContract} from "src/concrete/receipt/Receipt.sol";
14+
15+
contract OffchainAssetReceiptVaultBeaconSetDeployerConstructTest is Test {
16+
function testOffchainAssetReceiptVaultBeaconSetDeployerConstructZeroReceiptImplementation(
17+
address initialOffchainAssetReceiptVaultImplementation,
18+
address initialOwner
19+
) external {
20+
vm.assume(initialOffchainAssetReceiptVaultImplementation != address(0));
21+
vm.assume(initialOwner != address(0));
22+
vm.expectRevert(abi.encodeWithSelector(ZeroReceiptImplementation.selector));
23+
new OffchainAssetReceiptVaultBeaconSetDeployer(
24+
OffchainAssetReceiptVaultBeaconSetDeployerConfig({
25+
initialOwner: initialOwner,
26+
initialReceiptImplementation: address(0),
27+
initialOffchainAssetReceiptVaultImplementation: initialOffchainAssetReceiptVaultImplementation
28+
})
29+
);
30+
}
31+
32+
function testOffchainAssetReceiptVaultBeaconSetDeployerConstructZeroVaultImplementation(
33+
address initialReceiptImplementation,
34+
address initialOwner
35+
) external {
36+
vm.assume(initialReceiptImplementation != address(0));
37+
vm.assume(initialOwner != address(0));
38+
vm.expectRevert(abi.encodeWithSelector(ZeroVaultImplementation.selector));
39+
new OffchainAssetReceiptVaultBeaconSetDeployer(
40+
OffchainAssetReceiptVaultBeaconSetDeployerConfig({
41+
initialOwner: initialOwner,
42+
initialReceiptImplementation: initialReceiptImplementation,
43+
initialOffchainAssetReceiptVaultImplementation: address(0)
44+
})
45+
);
46+
}
47+
48+
function testOffchainAssetReceiptVaultBeaconSetDeployerConstructZeroBeaconOwner(
49+
address initialReceiptImplementation,
50+
address initialOffchainAssetReceiptVaultImplementation
51+
) external {
52+
vm.assume(initialReceiptImplementation != address(0));
53+
vm.assume(initialOffchainAssetReceiptVaultImplementation != address(0));
54+
vm.expectRevert(abi.encodeWithSelector(ZeroBeaconOwner.selector));
55+
new OffchainAssetReceiptVaultBeaconSetDeployer(
56+
OffchainAssetReceiptVaultBeaconSetDeployerConfig({
57+
initialOwner: address(0),
58+
initialReceiptImplementation: initialReceiptImplementation,
59+
initialOffchainAssetReceiptVaultImplementation: initialOffchainAssetReceiptVaultImplementation
60+
})
61+
);
62+
}
63+
64+
function testOffchainAssetReceiptVaultBeaconSetDeployerConstructSuccess(address initialOwner) external {
65+
vm.assume(initialOwner != address(0));
66+
ReceiptContract initialReceiptImplementation = new ReceiptContract();
67+
OffchainAssetReceiptVault initialOffchainAssetReceiptVaultImplementation = new OffchainAssetReceiptVault();
68+
69+
OffchainAssetReceiptVaultBeaconSetDeployer deployer = new OffchainAssetReceiptVaultBeaconSetDeployer(
70+
OffchainAssetReceiptVaultBeaconSetDeployerConfig({
71+
initialOwner: initialOwner,
72+
initialReceiptImplementation: address(initialReceiptImplementation),
73+
initialOffchainAssetReceiptVaultImplementation: address(initialOffchainAssetReceiptVaultImplementation)
74+
})
75+
);
76+
77+
vm.assertEq(address(deployer.I_RECEIPT_BEACON().implementation()), address(initialReceiptImplementation));
78+
vm.assertEq(
79+
address(deployer.I_OFFCHAIN_ASSET_RECEIPT_VAULT_BEACON().implementation()),
80+
address(initialOffchainAssetReceiptVaultImplementation)
81+
);
82+
}
83+
}

0 commit comments

Comments
 (0)