-
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 functions to add a node operator (#12906)
* add functions to add node operator * update gethwrapper
- Loading branch information
Showing
10 changed files
with
361 additions
and
47 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 | ||
--- | ||
|
||
update keystone gethwrapper #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 | ||
--- | ||
|
||
Implement function to add node operators to the capability registry' |
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
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,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {Test} from "forge-std/Test.sol"; | ||
import {Constants} from "./Constants.t.sol"; | ||
import {CapabilityRegistry} from "../CapabilityRegistry.sol"; | ||
|
||
contract BaseTest is Test, Constants { | ||
CapabilityRegistry internal s_capabilityRegistry; | ||
|
||
function setUp() public virtual { | ||
vm.startPrank(ADMIN); | ||
s_capabilityRegistry = new CapabilityRegistry(); | ||
} | ||
|
||
function _getNodeOperators() internal view returns (CapabilityRegistry.NodeOperator[] memory) { | ||
CapabilityRegistry.NodeOperator[] memory nodeOperators = new CapabilityRegistry.NodeOperator[](2); | ||
nodeOperators[0] = CapabilityRegistry.NodeOperator({admin: NODE_OPERATOR_ONE_ADMIN, name: NODE_OPERATOR_ONE_NAME}); | ||
nodeOperators[1] = CapabilityRegistry.NodeOperator({admin: NODE_OPERATOR_TWO_ADMIN, name: NODE_OPERATOR_TWO_NAME}); | ||
return nodeOperators; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
contracts/src/v0.8/keystone/test/CapabilityRegistry_AddCapabilityTest.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,17 @@ | ||
// 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 { | ||
function test_AddCapability() public { | ||
s_capabilityRegistry.addCapability(CapabilityRegistry.Capability("data-streams-reports", "1.0.0")); | ||
|
||
bytes32 capabilityId = s_capabilityRegistry.getCapabilityID(bytes32("data-streams-reports"), bytes32("1.0.0")); | ||
CapabilityRegistry.Capability memory capability = s_capabilityRegistry.getCapability(capabilityId); | ||
|
||
assertEq(capability.capabilityType, "data-streams-reports"); | ||
assertEq(capability.version, "1.0.0"); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
contracts/src/v0.8/keystone/test/CapabilityRegistry_AddNodeOperatorsTest.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,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {BaseTest} from "./BaseTest.t.sol"; | ||
import {CapabilityRegistry} from "../CapabilityRegistry.sol"; | ||
|
||
contract CapabilityRegistry_AddNodeOperatorsTest is BaseTest { | ||
event NodeOperatorAdded(uint256 nodeOperatorId, address indexed admin, string name); | ||
|
||
function test_RevertWhen_CalledByNonAdmin() public { | ||
changePrank(STRANGER); | ||
vm.expectRevert("Only callable by owner"); | ||
s_capabilityRegistry.addNodeOperators(_getNodeOperators()); | ||
} | ||
|
||
function test_RevertWhen_NodeOperatorAdminAddressZero() public { | ||
changePrank(ADMIN); | ||
CapabilityRegistry.NodeOperator[] memory nodeOperators = _getNodeOperators(); | ||
nodeOperators[0].admin = address(0); | ||
vm.expectRevert(CapabilityRegistry.InvalidNodeOperatorAdmin.selector); | ||
s_capabilityRegistry.addNodeOperators(nodeOperators); | ||
} | ||
|
||
function test_AddNodeOperators() public { | ||
changePrank(ADMIN); | ||
|
||
vm.expectEmit(true, true, true, true, address(s_capabilityRegistry)); | ||
emit NodeOperatorAdded(0, NODE_OPERATOR_ONE_ADMIN, NODE_OPERATOR_ONE_NAME); | ||
vm.expectEmit(true, true, true, true, address(s_capabilityRegistry)); | ||
emit NodeOperatorAdded(1, NODE_OPERATOR_TWO_ADMIN, NODE_OPERATOR_TWO_NAME); | ||
s_capabilityRegistry.addNodeOperators(_getNodeOperators()); | ||
|
||
CapabilityRegistry.NodeOperator memory nodeOperatorOne = s_capabilityRegistry.getNodeOperator(0); | ||
assertEq(nodeOperatorOne.admin, NODE_OPERATOR_ONE_ADMIN); | ||
assertEq(nodeOperatorOne.name, NODE_OPERATOR_ONE_NAME); | ||
|
||
CapabilityRegistry.NodeOperator memory nodeOperatorTwo = s_capabilityRegistry.getNodeOperator(1); | ||
assertEq(nodeOperatorTwo.admin, NODE_OPERATOR_TWO_ADMIN); | ||
assertEq(nodeOperatorTwo.name, NODE_OPERATOR_TWO_NAME); | ||
} | ||
} |
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,13 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import {Test} from "forge-std/Test.sol"; | ||
|
||
contract Constants { | ||
address internal ADMIN = address(1); | ||
address internal STRANGER = address(2); | ||
address internal NODE_OPERATOR_ONE_ADMIN = address(3); | ||
string internal NODE_OPERATOR_ONE_NAME = "node-operator-one"; | ||
address internal NODE_OPERATOR_TWO_ADMIN = address(4); | ||
string internal NODE_OPERATOR_TWO_NAME = "node-operator-two"; | ||
} |
210 changes: 197 additions & 13 deletions
210
...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 fbaf8eceb929494bdfe0028921a0742da525cb4ec1b6d57a1382eda46fa32c64 | ||
keystone_capability_registry: ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.abi ../../../contracts/solc/v0.8.19/CapabilityRegistry/CapabilityRegistry.bin 579334dfcb59da4221823735dc815116745b488ddde327199367e04457aac808 | ||
ocr3_capability: ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.abi ../../../contracts/solc/v0.8.19/OCR3Capability/OCR3Capability.bin 9dcbdf55bd5729ba266148da3f17733eb592c871c2108ccca546618628fd9ad2 |