Skip to content

Commit

Permalink
add unit test and remove in reverse order
Browse files Browse the repository at this point in the history
  • Loading branch information
shileiwill committed Apr 18, 2024
1 parent ff05527 commit 03a7880
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
44 changes: 25 additions & 19 deletions contracts/src/v0.8/automation/dev/test/AutomationRegistry2_3.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ contract SetConfig is SetUp {
offchainConfigBytes
);

(, IAutomationV21PlusCommon.OnchainConfigLegacy memory onchainConfig1, , ,) = registry.getState();
(, IAutomationV21PlusCommon.OnchainConfigLegacy memory onchainConfig1, , , ) = registry.getState();
assertEq(onchainConfig1.registrars.length, 2);

// BillingConfig2
Expand All @@ -546,23 +546,23 @@ contract SetConfig is SetUp {

// new onchain config with 3 new registrars, all other fields stay the same as the default
AutomationRegistryBase2_3.OnchainConfig memory cfg2 = AutomationRegistryBase2_3.OnchainConfig({
checkGasLimit: 5_000_000,
stalenessSeconds: 90_000,
gasCeilingMultiplier: 0,
maxPerformGas: 10_000_000,
maxCheckDataSize: 5_000,
maxPerformDataSize: 5_000,
maxRevertDataSize: 5_000,
fallbackGasPrice: 20_000_000_000,
fallbackLinkPrice: 2_000_000_000, // $20
fallbackNativePrice: 400_000_000_000, // $4,000
transcoder: 0xB1e66855FD67f6e85F0f0fA38cd6fBABdf00923c,
registrars: newRegistrars,
upkeepPrivilegeManager: PRIVILEGE_MANAGER,
chainModule: module,
reorgProtectionEnabled: true,
financeAdmin: FINANCE_ADMIN
});
checkGasLimit: 5_000_000,
stalenessSeconds: 90_000,
gasCeilingMultiplier: 0,
maxPerformGas: 10_000_000,
maxCheckDataSize: 5_000,
maxPerformDataSize: 5_000,
maxRevertDataSize: 5_000,
fallbackGasPrice: 20_000_000_000,
fallbackLinkPrice: 2_000_000_000, // $20
fallbackNativePrice: 400_000_000_000, // $4,000
transcoder: 0xB1e66855FD67f6e85F0f0fA38cd6fBABdf00923c,
registrars: newRegistrars,
upkeepPrivilegeManager: PRIVILEGE_MANAGER,
chainModule: module,
reorgProtectionEnabled: true,
financeAdmin: FINANCE_ADMIN
});

// the second time uses the new onchain config with 3 new registrars and also new billing tokens/configs
bytes memory onchainConfigBytesWithBilling2 = abi.encode(cfg2, billingTokens2, billingConfigs2);
Expand All @@ -577,7 +577,13 @@ contract SetConfig is SetUp {
offchainConfigBytes
);

(, IAutomationV21PlusCommon.OnchainConfigLegacy memory onchainConfig2, address[] memory signers, address[] memory transmitters, uint8 f) = registry.getState();
(
,
IAutomationV21PlusCommon.OnchainConfigLegacy memory onchainConfig2,
address[] memory signers,
address[] memory transmitters,
uint8 f
) = registry.getState();

assertEq(onchainConfig2.registrars.length, 3);
assertEq(signers, SIGNERS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ contract AutomationRegistry2_3 is AutomationRegistryBase2_3, OCR2Abstract, Chain
offchainConfig
);

for (uint256 idx = 0; idx < s_registrars.length(); idx++) {
s_registrars.remove(s_registrars.at(idx));
for (uint256 idx = s_registrars.length(); idx > 0; idx--) {
s_registrars.remove(s_registrars.at(idx - 1));
}

for (uint256 idx = 0; idx < onchainConfig.registrars.length; idx++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ contract AutomationRegistryLogicC2_3 is AutomationRegistryBase2_3 {
s_transmitters[deactivatedAddr].balance = 0;
}

for (uint256 idx = 0; idx < s_deactivatedTransmitters.length(); idx++) {
s_deactivatedTransmitters.remove(s_deactivatedTransmitters.at(idx));
for (uint256 idx = s_deactivatedTransmitters.length(); idx > 0; idx--) {
s_deactivatedTransmitters.remove(s_deactivatedTransmitters.at(idx - 1));
}

emit NOPsSettledOffchain(payees, payments);
Expand Down
Loading

0 comments on commit 03a7880

Please sign in to comment.