-
Notifications
You must be signed in to change notification settings - Fork 268
test: Add ENS support to functional tests and implement ENS registration test #7358
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5bbd72b
test: add ENS support to functional tests
ad2279a
Merge branch 'develop' into test/Write-Ens-Registration-Test
at0m1x19 335b30b
test: add ENS registry syncing to functional tests
dc7ca86
test: update ENS registry syncing and add Anvil network support
d40cce7
test: refactor ENS tests to improve backend fixture usage and ensure …
0252a3c
test: simplify Dockerfile by consolidating shell script COPY commands
8017de7
Merge branch 'develop' into test/Write-Ens-Registration-Test
at0m1x19 b68a62b
test: add token overrides to ENS backend fixture
8365473
Merge branch 'develop' into test/Write-Ens-Registration-Test
at0m1x19 7a07133
test: add retry logic to contract JSON loading in fixtures
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,45 @@ | ||
| from clients.foundry import Foundry | ||
| from resources.constants import DEPLOYER_ACCOUNT | ||
|
|
||
|
|
||
| class ENSDeployer: | ||
|
|
||
| def __init__(self, foundry: Foundry): | ||
| self.deploy_output = foundry.clone_and_run( | ||
| github_org="status-im", | ||
| github_repo="ens-usernames", | ||
| smart_contract_dir="script", | ||
| smart_contract_filename="Deploy.s.sol", | ||
| private_key=DEPLOYER_ACCOUNT.private_key, | ||
| sender_address=DEPLOYER_ACCOUNT.address, | ||
| ) | ||
|
|
||
| self.registry_address = self._find_contract("ENSRegistry") | ||
| self.resolver_address = self._find_contract("PublicResolver") | ||
| self.token_address = self._find_contract("MiniMeToken") | ||
| self.registrar_address = self._find_contract("UsernameRegistrar") | ||
|
|
||
| @classmethod | ||
| def from_file(cls, foundry: Foundry, container_file_path: str): | ||
| """Load ENS addresses from a JSON file in the foundry container.""" | ||
| import json | ||
|
|
||
| instance = cls.__new__(cls) | ||
| instance.deploy_output = None | ||
|
|
||
| host_file_path = foundry.get_archive(container_file_path) | ||
| with open(host_file_path, "r") as f: | ||
| addresses = json.load(f) | ||
|
|
||
| instance.registry_address = addresses["registry"] | ||
| instance.resolver_address = addresses["resolver"] | ||
| instance.token_address = addresses["token"] | ||
| instance.registrar_address = addresses["registrar"] | ||
|
|
||
| return instance | ||
|
|
||
| def _find_contract(self, contract_name): | ||
| for deployment in self.deploy_output.values(): | ||
| if f"contract {contract_name}" in deployment.get("internal_type", ""): | ||
| return deployment["value"] | ||
| raise Exception(f"{contract_name} contract not found in deploy output") |
This file contains hidden or 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,36 @@ | ||
| from clients.services.service import Service | ||
|
|
||
|
|
||
| class EnsService(Service): | ||
| def __init__(self, client): | ||
| super().__init__(client, "ens") | ||
|
|
||
| def add(self, chain_id, username): | ||
| return self.rpc_request("add", [chain_id, username]) | ||
|
|
||
| def remove(self, chain_id, username): | ||
| return self.rpc_request("remove", [chain_id, username]) | ||
|
|
||
| def get_ens_usernames(self): | ||
| return self.rpc_request("getEnsUsernames") | ||
|
|
||
| def get_registrar_address(self, chain_id): | ||
| return self.rpc_request("getRegistrarAddress", [chain_id]) | ||
|
|
||
| def resolver(self, chain_id, username): | ||
| return self.rpc_request("resolver", [chain_id, username]) | ||
|
|
||
| def owner_of(self, chain_id, username): | ||
| return self.rpc_request("ownerOf", [chain_id, username]) | ||
|
|
||
| def public_key_of(self, chain_id, username): | ||
| return self.rpc_request("publicKeyOf", [chain_id, username]) | ||
|
|
||
| def address_of(self, chain_id, username): | ||
| return self.rpc_request("addressOf", [chain_id, username]) | ||
|
|
||
| def expire_at(self, chain_id, username): | ||
| return self.rpc_request("expireAt", [chain_id, username]) | ||
|
|
||
| def price(self, chain_id): | ||
| return self.rpc_request("price", [chain_id]) |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -23,4 +23,5 @@ markers = | |
| activity | ||
| assets | ||
| benchmark | ||
| connector | ||
| connector | ||
| ens | ||
This file contains hidden or 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
|
Collaborator
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. I'd rename it to
Contributor
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. renamed to sync_ens_registry.sh and updated all references |
This file contains hidden or 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,35 @@ | ||
| #!/bin/sh | ||
| # Sync ENS registry storage from source to destination address. | ||
| # Usage: sync_ens_registry.sh <source_addr> <dest_addr> <rpc_url> [node1 node2 ...] | ||
| # If no nodes specified, syncs root, eth, and stateofus.eth nodes. | ||
|
|
||
| set -e | ||
|
|
||
| SOURCE=$1 | ||
| DEST=$2 | ||
| RPC_URL=$3 | ||
| shift 3 | ||
|
|
||
| # Default nodes to sync | ||
| if [ $# -eq 0 ]; then | ||
| set -- \ | ||
| "0x0000000000000000000000000000000000000000000000000000000000000000" \ | ||
| "$(cast namehash 'eth')" \ | ||
| "$(cast namehash 'stateofus.eth')" | ||
| fi | ||
|
|
||
| # Copy bytecode | ||
| CODE=$(cast code $SOURCE --rpc-url $RPC_URL) | ||
| cast rpc anvil_setCode $DEST $CODE --rpc-url $RPC_URL > /dev/null | ||
|
|
||
| # Copy storage for each node: owner (base+0), resolver (base+1), ttl (base+2) | ||
| for NODE in "$@"; do | ||
| BASE_SLOT=$(cast index bytes32 $NODE 0) | ||
| for OFFSET in 0 1 2; do | ||
| SLOT=$(perl -e "use Math::BigInt; print '0x', Math::BigInt->new('$BASE_SLOT')->badd($OFFSET)->as_hex() =~ s/^0x//r;") | ||
| # Pad to 66 chars (0x + 64 hex) | ||
| SLOT=$(printf "0x%064s" "$(echo $SLOT | sed 's/0x//')") | ||
| VALUE=$(cast storage $SOURCE $SLOT --rpc-url $RPC_URL) | ||
| cast rpc anvil_setStorageAt $DEST $SLOT $VALUE --rpc-url $RPC_URL > /dev/null | ||
| done | ||
| done |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm not sure of the consequences of this change.
@saledjenic is this safe?