Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/lib/mocks/ActivationRegistryFeatureList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ library ActivationRegistryFeatureList {

/// @dev keccak256("base.policy_registry")
bytes32 internal constant POLICY_REGISTRY = 0xb582ebae03f16fee49a6763f78df482fb11ae73f103ed0d330bbe556aa90a43f;

/// @dev keccak256("base.b20_stablecoin")
bytes32 internal constant B20_STABLECOIN = 0xecfa0def2c10020caaf65e6155aa69c84b24892aaef76eeac52e0e2b3a0b8601;
}
64 changes: 64 additions & 0 deletions test/unit/ActivationRegistry/featureList.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Test} from "forge-std/Test.sol";

import {ActivationRegistryFeatureList} from "test/lib/mocks/ActivationRegistryFeatureList.sol";

/// @notice Pins each feature id constant in `ActivationRegistryFeatureList` to
/// its canonical `keccak256("base.<feature>")` preimage.
///
/// @dev These constants are the cross-language contract between the
/// Solidity mock surface and the Rust precompile's `ActivationFeature`
/// enum (`crates/common/precompiles/src/activation/storage.rs` in
/// base/base): both sides must hash the same string and arrive at the
/// same id. The pinning tests below catch silent drift in either
/// direction — a typo in the hex literal or in the string preimage
/// surfaces here before it can desync against the Rust source of
/// truth.
contract ActivationRegistryFeatureListTest is Test {
/// @notice `B20_SECURITY` equals `keccak256("base.b20_security")`.
function test_B20_SECURITY_pinnedToKeccak() public pure {
assertEq(
ActivationRegistryFeatureList.B20_SECURITY,
keccak256("base.b20_security"),
"B20_SECURITY must equal keccak256(\"base.b20_security\")"
);
}

/// @notice `B20_TOKEN` equals `keccak256("base.b20_token")`.
function test_B20_TOKEN_pinnedToKeccak() public pure {
assertEq(
ActivationRegistryFeatureList.B20_TOKEN,
keccak256("base.b20_token"),
"B20_TOKEN must equal keccak256(\"base.b20_token\")"
);
}

/// @notice `B20_FACTORY` equals `keccak256("base.b20_factory")`.
function test_B20_FACTORY_pinnedToKeccak() public pure {
assertEq(
ActivationRegistryFeatureList.B20_FACTORY,
keccak256("base.b20_factory"),
"B20_FACTORY must equal keccak256(\"base.b20_factory\")"
);
}

/// @notice `POLICY_REGISTRY` equals `keccak256("base.policy_registry")`.
function test_POLICY_REGISTRY_pinnedToKeccak() public pure {
assertEq(
ActivationRegistryFeatureList.POLICY_REGISTRY,
keccak256("base.policy_registry"),
"POLICY_REGISTRY must equal keccak256(\"base.policy_registry\")"
);
}

/// @notice `B20_STABLECOIN` equals `keccak256("base.b20_stablecoin")`.
function test_B20_STABLECOIN_pinnedToKeccak() public pure {
assertEq(
ActivationRegistryFeatureList.B20_STABLECOIN,
keccak256("base.b20_stablecoin"),
"B20_STABLECOIN must equal keccak256(\"base.b20_stablecoin\")"
);
}
}
Loading