Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 62c87e4

Browse files
test: move precompile interfaces out of test directory (#1913)
1 parent 716e848 commit 62c87e4

File tree

15 files changed

+117
-107
lines changed

15 files changed

+117
-107
lines changed

precompile/allowlist/allowlisttest/bindings/IAllowList.sol renamed to precompile/allowlist/IAllowList.sol

File renamed without changes.

precompile/allowlist/allowlisttest/bindings/AllowList.sol

Lines changed: 0 additions & 89 deletions
This file was deleted.

precompile/allowlist/allowlisttest/bindings/AllowListTest.sol

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,60 @@
11
//SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.24;
33

4-
import "./IAllowList.sol";
5-
import "./AllowList.sol";
4+
import "precompile/allowlist/IAllowList.sol";
65

7-
contract AllowListTest is AllowList {
8-
// Precompiled Allow List Contract Address
9-
constructor(address precompileAddr) AllowList(precompileAddr) {}
6+
contract AllowListTest {
7+
IAllowList private allowList;
108

9+
uint256 constant STATUS_NONE = 0;
10+
uint256 constant STATUS_ENABLED = 1;
11+
uint256 constant STATUS_ADMIN = 2;
12+
uint256 constant STATUS_MANAGER = 3;
13+
14+
constructor(address precompileAddr) {
15+
allowList = IAllowList(precompileAddr);
16+
}
17+
18+
function setAdmin(address addr) external {
19+
allowList.setAdmin(addr);
20+
}
21+
22+
function setEnabled(address addr) external {
23+
allowList.setEnabled(addr);
24+
}
25+
26+
function setManager(address addr) external {
27+
allowList.setManager(addr);
28+
}
29+
30+
function setNone(address addr) external {
31+
allowList.setNone(addr);
32+
}
33+
34+
function readAllowList(address addr) external view returns (uint256) {
35+
return allowList.readAllowList(addr);
36+
}
37+
38+
// Helper functions used by tests
39+
function isAdmin(address addr) public view returns (bool) {
40+
return allowList.readAllowList(addr) == STATUS_ADMIN;
41+
}
42+
43+
function isManager(address addr) public view returns (bool) {
44+
return allowList.readAllowList(addr) == STATUS_MANAGER;
45+
}
46+
47+
function isEnabled(address addr) public view returns (bool) {
48+
// Returns true if address has any role (not NONE)
49+
return allowList.readAllowList(addr) != STATUS_NONE;
50+
}
51+
52+
function revoke(address addr) public {
53+
require(msg.sender != addr, "cannot revoke own role");
54+
allowList.setNone(addr);
55+
}
56+
57+
// Used by deployerallowlist tests to verify contract deployment permissions
1158
function deployContract() public {
1259
new Example();
1360
}

precompile/allowlist/allowlisttest/bindings/compile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package bindings
55

66
// Step 1: Compile Solidity contracts to generate ABI and bin files
7-
//go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path . precompile/=../../ --evm-version cancun AllowListTest.sol
7+
//go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path . precompile/=../../../ --evm-version cancun AllowListTest.sol
88
// Step 2: Generate Go bindings from the compiled artifacts
99
//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type IAllowList --abi artifacts/IAllowList.abi --bin artifacts/IAllowList.bin --out gen_allowlist_binding.go
1010
//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type AllowListTest --abi artifacts/AllowListTest.abi --bin artifacts/AllowListTest.bin --out gen_allowlisttest_binding.go

0 commit comments

Comments
 (0)