-
Notifications
You must be signed in to change notification settings - Fork 0
test: add require tests for fields on Revenue Sharing templates #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
299c394
ec425c4
ce666ad
da7a270
389a09e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.15; | ||
|
|
||
| import {Test} from "forge-std/Test.sol"; | ||
| import {DeployFeesDepositor} from "src/template/DeployFeesDepositor.sol"; | ||
|
|
||
| /// @notice Test contract for the DeployFeesDepositor that expect reverts on misconfiguration of required fields. | ||
| contract DeployFeesDepositorRequiredFieldsTest is Test { | ||
| DeployFeesDepositor public template; | ||
|
|
||
| function setUp() public { | ||
| vm.createSelectFork("mainnet", 23197819); | ||
| template = new DeployFeesDepositor(); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when the salt is an empty string. | ||
| function test_deployFeesDepositor_salt_empty_string_reverts() public { | ||
| string memory configPath = "test/template/deploy-fees-depositor/config/salt-empty-string-config.toml"; | ||
| vm.expectRevert("salt must be set"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when the l2Recipient is a zero address. | ||
| function test_deployFeesDepositor_l2Recipient_zero_address_reverts() public { | ||
| string memory configPath = "test/template/deploy-fees-depositor/config/l2Recipient-zero-address-config.toml"; | ||
| vm.expectRevert("l2Recipient must be set"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when the portal is a zero address. | ||
| function test_deployFeesDepositor_portal_zero_address_reverts() public { | ||
| string memory configPath = "test/template/deploy-fees-depositor/config/portal-zero-address-config.toml"; | ||
| vm.expectRevert("portal must be set"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when the gasLimit is zero. | ||
| function test_deployFeesDepositor_gasLimit_zero_reverts() public { | ||
| string memory configPath = "test/template/deploy-fees-depositor/config/gasLimit-zero-config.toml"; | ||
| vm.expectRevert("gasLimit must be set"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when the gasLimit is too high. | ||
| function test_deployFeesDepositor_gasLimit_too_high_reverts() public { | ||
| string memory configPath = "test/template/deploy-fees-depositor/config/gasLimit-too-high-config.toml"; | ||
| vm.expectRevert("gasLimit must be less than uint32.max"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when the proxyAdminOwner is a zero address. | ||
| function test_deployFeesDepositor_proxyAdminOwner_zero_address_reverts() public { | ||
| string memory configPath = "test/template/deploy-fees-depositor/config/proxyAdminOwner-zero-address-config.toml"; | ||
| vm.expectRevert("SimpleAddressRegistry: zero address for ProxyAdminOwner"); | ||
| template.simulate(configPath); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| l2chains = [] | ||
| templateName = "DeployFeesDepositor" | ||
|
|
||
| salt = "test-salt" | ||
| minDepositAmount = 1000000000000000000 | ||
| gasLimit = 4294967296 | ||
| portal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" | ||
| l2Recipient = "0xdeadbeef1234567890abcdef1234567890abcdef" | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| l2chains = [] | ||
| templateName = "DeployFeesDepositor" | ||
|
|
||
| salt = "test-salt" | ||
| gasLimit = 0 | ||
| minDepositAmount = 1000000000000000000 | ||
| l2Recipient = "0xdeadbeef1234567890abcdef1234567890abcdef" | ||
| portal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| l2chains = [] | ||
| templateName = "DeployFeesDepositor" | ||
|
|
||
| minDepositAmount = 1000000000000000000 | ||
| portal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" | ||
| l2Recipient = "0x0000000000000000000000000000000000000000" | ||
| salt = "test-salt" | ||
| gasLimit = 1000000 | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| l2chains = [] | ||
| templateName = "DeployFeesDepositor" | ||
|
|
||
| minDepositAmount = 1000000000000000000 | ||
| portal = "0x0000000000000000000000000000000000000000" | ||
| l2Recipient = "0xdeadbeef1234567890abcdef1234567890abcdef" | ||
| salt = "test-salt" | ||
| gasLimit = 1000000 | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| l2chains = [] | ||
| templateName = "DeployFeesDepositor" | ||
|
|
||
| portal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" | ||
| l2Recipient = "0xdeadbeef1234567890abcdef1234567890abcdef" | ||
| salt = "test-salt" | ||
| gasLimit = 1000000 | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x0000000000000000000000000000000000000000" | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| l2chains = [] | ||
| templateName = "DeployFeesDepositor" | ||
|
|
||
| portal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" | ||
| l2Recipient = "0xdeadbeef1234567890abcdef1234567890abcdef" | ||
| salt = "" | ||
| gasLimit = 1000000 | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -322,3 +322,79 @@ contract LateOptInRevenueShareTest is Test { | |
| } | ||
| } | ||
| } | ||
|
|
||
| /// @notice Test contract for the LateOptInRevenueShare that expect reverts on misconfiguration of required fields. | ||
| contract LateOptInRevenueShareRequiredFieldsTest is Test { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think it's the same as the previous comment.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed here. |
||
| LateOptInRevenueShare public template; | ||
|
|
||
| function setUp() public { | ||
| vm.createSelectFork("mainnet", 23197819); | ||
| template = new LateOptInRevenueShare(); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when the gasLimit is too low. | ||
| function test_lateOptInRevenueShare_too_low_gasLimit_reverts() public { | ||
| string memory configPath = "test/template/late-opt-in-rev-share/config/zero-gas-limit-config.toml"; | ||
| vm.expectRevert("gasLimit must be set"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when the gasLimit is too high. | ||
| function test_lateOptInRevenueShare_too_high_gasLimit_reverts() public { | ||
| string memory configPath = "test/template/late-opt-in-rev-share/config/too-high-gas-limit-config.toml"; | ||
| vm.expectRevert("gasLimit must be less than uint64.max"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when using own calculator and the calculator address is zero. | ||
| function test_lateOptInRevenueShare_calculator_zero_address_reverts() public { | ||
| string memory configPath = "test/template/late-opt-in-rev-share/config/calculator-zero-address-config.toml"; | ||
| vm.expectRevert("calculator address must be set in config if opting to use own calculator"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when using default calculator and the salt seed is an empty string. | ||
| function test_lateOptInRevenueShare_saltSeed_empty_string_reverts() public { | ||
| string memory configPath = "test/template/late-opt-in-rev-share/config/salt-seed-empty-string-config.toml"; | ||
| vm.expectRevert("saltSeed must be set in config"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when using default calculator and the l1 withdrawer recipient is a zero address. | ||
| function test_lateOptInRevenueShare_l1WithdrawerRecipient_zero_address_reverts() public { | ||
| string memory configPath = | ||
| "test/template/late-opt-in-rev-share/config/l1WithdrawerRecipient-zero-address-config.toml"; | ||
| vm.expectRevert("l1WithdrawerRecipient must be set in config"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when using default calculator and the l1 withdrawer gas limit is zero. | ||
| function test_lateOptInRevenueShare_l1WithdrawerGasLimit_zero_reverts() public { | ||
| string memory configPath = "test/template/late-opt-in-rev-share/config/l1WithdrawerGasLimit-zero-config.toml"; | ||
| vm.expectRevert("l1WithdrawerGasLimit must be greater than 0"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when using default calculator and the l1 withdrawer gas limit is too high. | ||
| function test_lateOptInRevenueShare_l1WithdrawerGasLimit_too_high_reverts() public { | ||
| string memory configPath = | ||
| "test/template/late-opt-in-rev-share/config/l1WithdrawerGasLimit-too-high-config.toml"; | ||
| vm.expectRevert("l1WithdrawerGasLimit must be less than uint32.max"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when using default calculator and the chain fees recipient is a zero address. | ||
| function test_lateOptInRevenueShare_scRevShareCalcChainFeesRecipient_zero_address_reverts() public { | ||
| string memory configPath = | ||
| "test/template/late-opt-in-rev-share/config/scRevShareCalcChainFeesRecipient-zero-address-config.toml"; | ||
| vm.expectRevert("scRevShareCalcChainFeesRecipient must be set in config"); | ||
| template.simulate(configPath); | ||
| } | ||
|
|
||
| /// @notice Tests that the template reverts when the portal is a zero address. | ||
| function test_lateOptInRevenueShare_portal_zero_address_reverts() public { | ||
| string memory configPath = "test/template/late-opt-in-rev-share/config/portal-zero-address-config.toml"; | ||
| vm.expectRevert("SimpleAddressRegistry: zero address for OptimismPortal"); | ||
| template.simulate(configPath); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| templateName = "LateOptInRevenueShare" | ||
|
|
||
| # Revenue Share Configuration | ||
| # When using custom calculator, only the calculator address and the gas limit are required | ||
| useOwnCalculator = true | ||
| gasLimit = 300000 | ||
| calculator = "0x0000000000000000000000000000000000000000" | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" | ||
| OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| templateName = "LateOptInRevenueShare" | ||
|
|
||
| # Revenue Share Configuration | ||
| # When using custom calculator, only the calculator address and the gas limit are required | ||
| useOwnCalculator = false | ||
| saltSeed = "DeploymentSalt" | ||
| l1WithdrawerMinWithdrawalAmount = 1000000000000000000 | ||
| l1WithdrawerRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" | ||
| l1WithdrawerGasLimit = 4294967296 # 2^32 | ||
| scRevShareCalcChainFeesRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" | ||
| gasLimit = 300000 | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" | ||
| OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| templateName = "LateOptInRevenueShare" | ||
|
|
||
| # Revenue Share Configuration | ||
| # When using custom calculator, only the calculator address and the gas limit are required | ||
| useOwnCalculator = false | ||
| saltSeed = "DeploymentSalt" | ||
| l1WithdrawerMinWithdrawalAmount = 1000000000000000000 | ||
| l1WithdrawerRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" | ||
| l1WithdrawerGasLimit = 0 | ||
| scRevShareCalcChainFeesRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" | ||
| gasLimit = 300000 | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" | ||
| OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| templateName = "LateOptInRevenueShare" | ||
|
|
||
| # Revenue Share Configuration | ||
| # When using custom calculator, only the calculator address and the gas limit are required | ||
| useOwnCalculator = false | ||
| saltSeed = "DeploymentSalt" | ||
| l1WithdrawerMinWithdrawalAmount = 1000000000000000000 | ||
| l1WithdrawerRecipient = "0x0000000000000000000000000000000000000000" | ||
| l1WithdrawerGasLimit = 300000 | ||
| scRevShareCalcChainFeesRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" | ||
| gasLimit = 300000 | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" | ||
| OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| templateName = "LateOptInRevenueShare" | ||
|
|
||
| # Revenue Share Configuration | ||
| useOwnCalculator = true | ||
| gasLimit = 300000 | ||
| calculator = "0x8B0c0c8B8B0c0C8B8b0C0C8b8B0C0c8b8b0C0c8b" | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" | ||
| OptimismPortal = "0x0000000000000000000000000000000000000000" | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| templateName = "LateOptInRevenueShare" | ||
|
|
||
| # Revenue Share Configuration | ||
| # When using custom calculator, only the calculator address and the gas limit are required | ||
| useOwnCalculator = false | ||
| saltSeed = "" | ||
| gasLimit = 300000 | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" | ||
| OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| templateName = "LateOptInRevenueShare" | ||
|
|
||
| # Revenue Share Configuration | ||
| # When using custom calculator, only the calculator address and the gas limit are required | ||
| useOwnCalculator = false | ||
| saltSeed = "DeploymentSalt" | ||
| l1WithdrawerMinWithdrawalAmount = 1000000000000000000 | ||
| l1WithdrawerRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" | ||
| l1WithdrawerGasLimit = 300000 | ||
| scRevShareCalcChainFeesRecipient = "0x0000000000000000000000000000000000000000" | ||
| gasLimit = 300000 | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" | ||
| OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| templateName = "LateOptInRevenueShare" | ||
|
|
||
| # Revenue Share Configuration | ||
| # When using custom calculator, only the calculator address and the gas limit are required | ||
| useOwnCalculator = false | ||
| saltSeed = "DeploymentSalt" | ||
| l1WithdrawerMinWithdrawalAmount = 1000000000000000000 | ||
| l1WithdrawerRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" | ||
| l1WithdrawerGasLimit = 300000 | ||
| scRevShareCalcChainFeesRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" | ||
| gasLimit = 1.9e64 # Greater than uint64.max | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" | ||
| OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| templateName = "LateOptInRevenueShare" | ||
|
|
||
| # Revenue Share Configuration | ||
| # When using custom calculator, only the calculator address and the gas limit are required | ||
| useOwnCalculator = false | ||
| saltSeed = "DeploymentSalt" | ||
| l1WithdrawerMinWithdrawalAmount = 1000000000000000000 | ||
| l1WithdrawerRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" | ||
| l1WithdrawerGasLimit = 300000 | ||
| scRevShareCalcChainFeesRecipient = "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef" | ||
| gasLimit = 0 # gasLimit must be set | ||
|
|
||
| [addresses] | ||
| ProxyAdminOwner = "0x5a0Aae59D09fccBdDb6C6CcEB07B7279367C3d2A" | ||
| OptimismPortal = "0xbEb5Fc579115071764c7423A4f12eDde41f106Ed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this line on
FeesDepositor:Since it fails before on
.get()There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, thought leaving it for completeness as the require in the script was there already but definitely can be both removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed here.