Skip to content

Commit

Permalink
dont use const
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill committed Feb 9, 2024
1 parent fedf5cb commit 4c04799
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 165 deletions.
2 changes: 1 addition & 1 deletion contracts/src/v0.8/tests/MockChainModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract MockChainModule is IChainModule {
return keccak256(abi.encode(blocknumber));
}

function getL1Fee(bytes calldata txCallData) external view returns (uint256) {
function getCurrentL1Fee() external view returns (uint256) {
return 0;
}

Expand Down
214 changes: 63 additions & 151 deletions contracts/test/v0.8/automation/AutomationRegistry2_2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -995,41 +995,27 @@ describe('AutomationRegistry2_2', () => {
.transfer(await admin.getAddress(), toWei('1000'))
let tx = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
randomBytes,
'0x',
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), randomBytes, '0x')
upkeepId = await getUpkeepID(tx)

autoFunderUpkeep = await upkeepAutoFunderFactory
.connect(owner)
.deploy(linkToken.address, registry.address)
tx = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
autoFunderUpkeep.address,
performGas,
autoFunderUpkeep.address,
randomBytes,
'0x',
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](autoFunderUpkeep.address, performGas, autoFunderUpkeep.address, randomBytes, '0x')
afUpkeepId = await getUpkeepID(tx)

ltUpkeep = await deployMockContract(owner, ILogAutomationactory.abi)
tx = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)'](
ltUpkeep.address,
performGas,
await admin.getAddress(),
Trigger.LOG,
'0x',
logTriggerConfig,
emptyBytes,
)
[
'registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)'
](ltUpkeep.address, performGas, await admin.getAddress(), Trigger.LOG, '0x', logTriggerConfig, emptyBytes)
logUpkeepId = await getUpkeepID(tx)

await autoFunderUpkeep.setUpkeepId(afUpkeepId)
Expand All @@ -1040,13 +1026,9 @@ describe('AutomationRegistry2_2', () => {

tx = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
streamsLookupUpkeep.address,
performGas,
await admin.getAddress(),
randomBytes,
'0x',
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](streamsLookupUpkeep.address, performGas, await admin.getAddress(), randomBytes, '0x')
streamsLookupUpkeepId = await getUpkeepID(tx)
}

Expand All @@ -1064,13 +1046,9 @@ describe('AutomationRegistry2_2', () => {
await mock.setPerformGasToBurn(BigNumber.from('0'))
const tx = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
randomBytes,
'0x',
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), randomBytes, '0x')
const condUpkeepId = await getUpkeepID(tx)
passingConditionalUpkeepIds.push(condUpkeepId)

Expand All @@ -1083,15 +1061,9 @@ describe('AutomationRegistry2_2', () => {
await mock.setPerformGasToBurn(BigNumber.from('0'))
const tx = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
Trigger.LOG,
'0x',
logTriggerConfig,
emptyBytes,
)
[
'registerUpkeep(address,uint32,address,uint8,bytes,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), Trigger.LOG, '0x', logTriggerConfig, emptyBytes)
const logUpkeepId = await getUpkeepID(tx)
passingLogUpkeepIds.push(logUpkeepId)

Expand All @@ -1104,13 +1076,9 @@ describe('AutomationRegistry2_2', () => {
await mock.setPerformGasToBurn(BigNumber.from('0'))
const tx = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
randomBytes,
'0x',
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), randomBytes, '0x')
const failingUpkeepId = await getUpkeepID(tx)
failingUpkeepIds.push(failingUpkeepId)
}
Expand Down Expand Up @@ -1592,13 +1560,9 @@ describe('AutomationRegistry2_2', () => {

let tx = await arbRegistry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
randomBytes,
'0x',
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), randomBytes, '0x')
const testUpkeepId = await getUpkeepID(tx)
await arbRegistry.connect(owner).addFunds(testUpkeepId, toWei('100'))

Expand Down Expand Up @@ -2648,13 +2612,9 @@ describe('AutomationRegistry2_2', () => {
// add funds to upkeep 1 and perform and withdraw some payment
const tx = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
emptyBytes,
emptyBytes,
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), emptyBytes, emptyBytes)

const id1 = await getUpkeepID(tx)
await registry.connect(admin).addFunds(id1, toWei('5'))
Expand All @@ -2676,13 +2636,9 @@ describe('AutomationRegistry2_2', () => {
// add funds to upkeep 2 and perform and withdraw some payment
const tx2 = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
emptyBytes,
emptyBytes,
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), emptyBytes, emptyBytes)
const id2 = await getUpkeepID(tx2)
await registry.connect(admin).addFunds(id2, toWei('5'))

Expand Down Expand Up @@ -2760,23 +2716,15 @@ describe('AutomationRegistry2_2', () => {
it('uses maxPerformData size in checkUpkeep but actual performDataSize in transmit', async () => {
const tx1 = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
randomBytes,
'0x',
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), randomBytes, '0x')
const upkeepID1 = await getUpkeepID(tx1)
const tx2 = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
randomBytes,
'0x',
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), randomBytes, '0x')
const upkeepID2 = await getUpkeepID(tx2)
await mock.setCanCheck(true)
await mock.setCanPerform(true)
Expand Down Expand Up @@ -2839,13 +2787,9 @@ describe('AutomationRegistry2_2', () => {
beforeEach(async () => {
const tx = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
randomBytes,
'0x',
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), randomBytes, '0x')
upkeepId2 = await getUpkeepID(tx)

await registry.connect(admin).addFunds(upkeepId, toWei('100'))
Expand Down Expand Up @@ -3985,13 +3929,9 @@ describe('AutomationRegistry2_2', () => {
await evmRevert(
registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
emptyBytes,
'0x',
),
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), emptyBytes, '0x'),
'RegistryPaused()',
)
})
Expand All @@ -4000,13 +3940,9 @@ describe('AutomationRegistry2_2', () => {
await evmRevert(
registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
zeroAddress,
performGas,
await admin.getAddress(),
emptyBytes,
'0x',
),
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](zeroAddress, performGas, await admin.getAddress(), emptyBytes, '0x'),
'NotAContract()',
)
})
Expand All @@ -4015,13 +3951,9 @@ describe('AutomationRegistry2_2', () => {
await evmRevert(
registry
.connect(keeper1)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
emptyBytes,
'0x',
),
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), emptyBytes, '0x'),
'OnlyCallableByOwnerOrRegistrar()',
)
})
Expand All @@ -4030,13 +3962,9 @@ describe('AutomationRegistry2_2', () => {
await evmRevert(
registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
2299,
await admin.getAddress(),
emptyBytes,
'0x',
),
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, 2299, await admin.getAddress(), emptyBytes, '0x'),
'GasLimitOutsideRange()',
)
})
Expand All @@ -4045,13 +3973,9 @@ describe('AutomationRegistry2_2', () => {
await evmRevert(
registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
5000001,
await admin.getAddress(),
emptyBytes,
'0x',
),
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, 5000001, await admin.getAddress(), emptyBytes, '0x'),
'GasLimitOutsideRange()',
)
})
Expand All @@ -4064,13 +3988,9 @@ describe('AutomationRegistry2_2', () => {
await evmRevert(
registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
longBytes,
'0x',
),
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), longBytes, '0x'),
'CheckDataExceedsLimit()',
)
})
Expand All @@ -4085,13 +4005,9 @@ describe('AutomationRegistry2_2', () => {
const checkData = checkDatas[kdx]
const tx = await registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
checkData,
'0x',
)
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), checkData, '0x')

//confirm the upkeep details and verify emitted events
const testUpkeepId = await getUpkeepID(tx)
Expand Down Expand Up @@ -4754,13 +4670,9 @@ describe('AutomationRegistry2_2', () => {
await evmRevert(
registry
.connect(owner)
['registerUpkeep(address,uint32,address,bytes,bytes)'](
mock.address,
performGas,
await admin.getAddress(),
emptyBytes,
'0x',
),
[
'registerUpkeep(address,uint32,address,bytes,bytes)'
](mock.address, performGas, await admin.getAddress(), emptyBytes, '0x'),
'RegistryPaused()',
)
})
Expand Down
13 changes: 4 additions & 9 deletions contracts/test/v0.8/automation/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@ import { AutomationRegistryLogicB2_2__factory as AutomationRegistryLogicBFactory
import { IAutomationRegistryMaster as IAutomationRegistry } from '../../../typechain/IAutomationRegistryMaster'
import { IAutomationRegistryMaster__factory as IAutomationRegistryMasterFactory } from '../../../typechain/factories/IAutomationRegistryMaster__factory'

const ZERO = 0
const ONE = 1
const TWO = 2
const THREE = 3

export const deployRegistry21 = async (
from: Signer,
mode: Parameters<KeeperRegistryLogicBFactory['deploy']>[ZERO],
link: Parameters<KeeperRegistryLogicBFactory['deploy']>[ONE],
linkNative: Parameters<KeeperRegistryLogicBFactory['deploy']>[TWO],
fastgas: Parameters<KeeperRegistryLogicBFactory['deploy']>[THREE],
mode: Parameters<KeeperRegistryLogicBFactory['deploy']>[0],
link: Parameters<KeeperRegistryLogicBFactory['deploy']>[1],
linkNative: Parameters<KeeperRegistryLogicBFactory['deploy']>[2],
fastgas: Parameters<KeeperRegistryLogicBFactory['deploy']>[3],
): Promise<IKeeperRegistry> => {
const logicBFactory = await ethers.getContractFactory(
'KeeperRegistryLogicB2_1',
Expand Down
Loading

0 comments on commit 4c04799

Please sign in to comment.