-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add getCapabilities * Fix comments * Add deprecateCapability * Wrappers + changesets * Name fixes
- Loading branch information
Showing
7 changed files
with
356 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"chainlink": patch | ||
--- | ||
|
||
#internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@chainlink/contracts": patch | ||
--- | ||
|
||
#internal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
contracts/src/v0.8/keystone/test/CapabilityRegistry_DeprecateCapability.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {BaseTest} from "./BaseTest.t.sol"; | ||
|
||
import {CapabilityRegistry} from "../CapabilityRegistry.sol"; | ||
|
||
contract CapabilityRegistry_AddCapabilityTest is BaseTest { | ||
event CapabilityDeprecated(bytes32 indexed capabilityId); | ||
|
||
function setUp() public override { | ||
BaseTest.setUp(); | ||
|
||
s_capabilityRegistry.addCapability(s_basicCapability); | ||
s_capabilityRegistry.addCapability(s_capabilityWithConfigurationContract); | ||
} | ||
|
||
function test_RevertWhen_CalledByNonAdmin() public { | ||
changePrank(STRANGER); | ||
bytes32 capabilityId = s_capabilityRegistry.getCapabilityID( | ||
s_basicCapability.capabilityType, | ||
s_basicCapability.version | ||
); | ||
|
||
vm.expectRevert("Only callable by owner"); | ||
s_capabilityRegistry.deprecateCapability(capabilityId); | ||
} | ||
|
||
function test_RevertWhen_CapabilityDoesNotExist() public { | ||
bytes32 capabilityId = s_capabilityRegistry.getCapabilityID("non-existent-capability", "1.0.0"); | ||
|
||
vm.expectRevert(abi.encodeWithSelector(CapabilityRegistry.CapabilityDoesNotExist.selector, capabilityId)); | ||
s_capabilityRegistry.deprecateCapability(capabilityId); | ||
} | ||
|
||
function test_RevertWhen_CapabilityAlreadyDeprecated() public { | ||
bytes32 capabilityId = s_capabilityRegistry.getCapabilityID( | ||
s_basicCapability.capabilityType, | ||
s_basicCapability.version | ||
); | ||
|
||
s_capabilityRegistry.deprecateCapability(capabilityId); | ||
|
||
vm.expectRevert(abi.encodeWithSelector(CapabilityRegistry.CapabilityAlreadyDeprecated.selector, capabilityId)); | ||
s_capabilityRegistry.deprecateCapability(capabilityId); | ||
} | ||
|
||
function test_DeprecatesCapability() public { | ||
bytes32 capabilityId = s_capabilityRegistry.getCapabilityID( | ||
s_basicCapability.capabilityType, | ||
s_basicCapability.version | ||
); | ||
|
||
s_capabilityRegistry.deprecateCapability(capabilityId); | ||
|
||
assertEq(s_capabilityRegistry.isCapabilityDeprecated(capabilityId), true); | ||
} | ||
|
||
function test_EmitsEvent() public { | ||
bytes32 capabilityId = s_capabilityRegistry.getCapabilityID( | ||
s_basicCapability.capabilityType, | ||
s_basicCapability.version | ||
); | ||
|
||
vm.expectEmit(address(s_capabilityRegistry)); | ||
emit CapabilityDeprecated(capabilityId); | ||
s_capabilityRegistry.deprecateCapability(capabilityId); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
contracts/src/v0.8/keystone/test/CapabilityRegistry_GetCapabilities.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {BaseTest} from "./BaseTest.t.sol"; | ||
import {CapabilityRegistry} from "../CapabilityRegistry.sol"; | ||
|
||
contract CapabilityRegistry_GetCapabilitiesTest is BaseTest { | ||
function setUp() public override { | ||
BaseTest.setUp(); | ||
|
||
s_capabilityRegistry.addCapability(s_basicCapability); | ||
s_capabilityRegistry.addCapability(s_capabilityWithConfigurationContract); | ||
} | ||
|
||
function test_ReturnsCapabilities() public view { | ||
CapabilityRegistry.Capability[] memory capabilities = s_capabilityRegistry.getCapabilities(); | ||
|
||
assertEq(capabilities.length, 2); | ||
|
||
assertEq(capabilities[0].capabilityType, "data-streams-reports"); | ||
assertEq(capabilities[0].version, "1.0.0"); | ||
assertEq(uint256(capabilities[0].responseType), uint256(CapabilityRegistry.CapabilityResponseType.REPORT)); | ||
assertEq(capabilities[0].configurationContract, address(0)); | ||
|
||
assertEq(capabilities[1].capabilityType, "read-ethereum-mainnet-gas-price"); | ||
assertEq(capabilities[1].version, "1.0.2"); | ||
assertEq( | ||
uint256(capabilities[1].responseType), | ||
uint256(CapabilityRegistry.CapabilityResponseType.OBSERVATION_IDENTICAL) | ||
); | ||
assertEq(capabilities[1].configurationContract, address(s_capabilityConfigurationContract)); | ||
} | ||
|
||
function test_ExcludesDeprecatedCapabilities() public { | ||
bytes32 capabilityId = s_capabilityRegistry.getCapabilityID( | ||
s_basicCapability.capabilityType, | ||
s_basicCapability.version | ||
); | ||
s_capabilityRegistry.deprecateCapability(capabilityId); | ||
|
||
CapabilityRegistry.Capability[] memory capabilities = s_capabilityRegistry.getCapabilities(); | ||
assertEq(capabilities.length, 1); | ||
|
||
assertEq(capabilities[0].capabilityType, "read-ethereum-mainnet-gas-price"); | ||
assertEq(capabilities[0].version, "1.0.2"); | ||
assertEq( | ||
uint256(capabilities[0].responseType), | ||
uint256(CapabilityRegistry.CapabilityResponseType.OBSERVATION_IDENTICAL) | ||
); | ||
assertEq(capabilities[0].configurationContract, address(s_capabilityConfigurationContract)); | ||
} | ||
} |
181 changes: 179 additions & 2 deletions
181
...hwrappers/keystone/generated/keystone_capability_registry/keystone_capability_registry.go
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
core/gethwrappers/keystone/generation/generated-wrapper-dependency-versions-do-not-edit.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
GETH_VERSION: 1.13.8 | ||
forwarder: ../../../contracts/solc/v0.8.19/KeystoneForwarder/KeystoneForwarder.abi ../../../contracts/solc/v0.8.19/KeystoneForwarder/KeystoneForwarder.bin b4c900aae9e022f01abbac7993d41f93912247613ac6270b0c4da4ef6f2016e3 | ||
keystone_capability_registry: ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.abi ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.bin ae9e077854854fa066746eaa354324c7dac2a13bc38b81a66c856fddfc3b79bf | ||
keystone_capability_registry: ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.abi ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.bin 28fb0e1c437b97271d999f3b028f7bd44558352ec83f89501aabf501fcc915f1 | ||
ocr3_capability: ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.abi ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.bin 9dcbdf55bd5729ba266148da3f17733eb592c871c2108ccca546618628fd9ad2 |