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
38 changes: 38 additions & 0 deletions test/src/abstract/RainDeployVerifyChain.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,44 @@ contract RainDeployVerifyChainTest is ExampleDeploySuites, RainDeployVerifyChain
assertEq(block.chainid, lastChainId);
}

/// The early return for an empty set is about having NOTHING to check, not
/// about the networks: handed ONE derivation, the matrix forks.
///
/// The count is the whole point of the case. Every other test here runs the
/// matrix over this contract's TWO released suites, so a guard keyed
/// anywhere below two — `derived.length < 2` — returns early on every
/// subject in the repo and is caught by none of them:
/// `RainDeployVerifyChainCandidateTest` is the only other contract that
/// reaches the matrix with a subject, at exactly one, and it forks on its own
/// before calling, so a matrix that returned without forking is
/// indistinguishable there. `RegistryDeployChainTest`'s empty case reads as
/// satisfied under that guard, which is what makes one subject the length
/// that discriminates.
///
/// This contract is where it belongs because it already forks every
/// supported network. Asserting it from the empty-set side would hand the
/// contract that exists to need no RPC endpoint the five-endpoint dependency
/// the early return removes from it.
function testChainWithASingleSubjectDoesFork() external {
(bool activeBefore,) = address(vm).call(abi.encodeWithSignature("activeFork()"));
assertFalse(activeBefore, "a fork was selected before the call");

// One subject, and `setUp` left it etched persistently, so it is live
// with its recorded hash on whichever forks the matrix creates and the
// check itself passes on all of them.
DerivedDeploy[] memory derived = new DerivedDeploy[](1);
derived[0] = DerivedDeploy({
suite: "address-registry-0-0-1",
deployedAddress: ADDRESS_REGISTRY_DEPLOYED_ADDRESS,
bytecodeHash: ADDRESS_REGISTRY_BYTECODE_HASH
});

checkDeployedOnSupportedNetworks(derived);

(bool activeAfter,) = address(vm).call(abi.encodeWithSignature("activeFork()"));
assertTrue(activeAfter, "the matrix checked a subject without forking");
}

/// Code on a network that is not the code the version's creation code
/// produces MUST fail hard, naming the network and BOTH hashes.
///
Expand Down
35 changes: 34 additions & 1 deletion test/src/abstract/RegistryDeployChain.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,37 @@ import {RegistryDeploySuites} from "../../../src/abstract/RegistryDeploySuites.s
/// it says this and nothing more: a missing deployment or an unreachable
/// endpoint fails here alone, leaving every snapshot assertion to answer for
/// itself.
contract RegistryDeployChainTest is RegistryDeploySuites, RainDeployVerifyChain {}
contract RegistryDeployChainTest is RegistryDeploySuites, RainDeployVerifyChain {
/// Nothing to check MUST NOT touch an RPC endpoint. This repo has released
/// nothing, so this is the branch every CI run takes: forking five networks
/// to check nothing turns an outage into the failure of an assertion with
/// no subject, which is the one failure this contract exists to stay
/// legible against.
///
/// The ABSENCE of a fork is what is asserted, because the pass is identical
/// either way — the matrix that forks all five and finds nothing to check on
/// each of them passes too, and is the only thing this contract would have
/// done differently. `vm.activeFork()` reverts when nothing is selected, so
/// the low-level call failing IS "no network was reached".
///
/// It runs the whole inherited entry point rather than handing the matrix an
/// empty array, so the derivation is inside what is asserted: a fork opened
/// while deriving would touch the same five endpoints for the same nothing.
///
/// The empty released set is asserted rather than assumed, because it is the
/// premise and not the property. The first release gives this contract a
/// subject and the matrix will fork for it — correctly — so this fails at
/// that release naming what actually changed, instead of reporting that a
/// matrix with nothing to check forked, which would by then be false.
function testChainWithNothingToCheckForksNothing() external {
assertEq(releasedSuites().length, 0, "this repo has released something, so the matrix has a subject");

(bool activeBefore,) = address(vm).call(abi.encodeWithSignature("activeFork()"));
assertFalse(activeBefore, "a fork was selected before the call");

this.testSuitesLiveOnEverySupportedNetwork();

(bool activeAfter,) = address(vm).call(abi.encodeWithSignature("activeFork()"));
assertFalse(activeAfter, "the matrix forked a network with nothing to check");
}
}
Loading