Skip to content
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

chore: conform test naming to style guide #433

Merged
merged 6 commits into from
Aug 22, 2023
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
170 changes: 93 additions & 77 deletions test/StdAssertions.t.sol

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions test/StdChains.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract StdChainsMock is Test {
}

contract StdChainsTest is Test {
function testChainRpcInitialization() public {
function test_ChainRpcInitialization() public {
// RPCs specified in `foundry.toml` should be updated.
assertEq(getChain(1).rpcUrl, "https://mainnet.infura.io/v3/b1d3925804e74152b316ca7da97060d3");
assertEq(getChain("optimism_goerli").rpcUrl, "https://goerli.optimism.io/");
Expand All @@ -43,7 +43,7 @@ contract StdChainsTest is Test {
assertEq(getChain("sepolia").rpcUrl, "https://sepolia.infura.io/v3/b9794ad1ddf84dfb8c34d6bb5dca2001");
}

function testRpc(string memory rpcAlias) internal {
function testFuzz_Rpc(string memory rpcAlias) internal {
string memory rpcUrl = getChain(rpcAlias).rpcUrl;
vm.createSelectFork(rpcUrl);
}
Expand All @@ -67,23 +67,23 @@ contract StdChainsTest is Test {
// testRpc("gnosis_chain");
// }

function testChainNoDefault() public {
function test_ChainNoDefault() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

vm.expectRevert("StdChains getChain(string): Chain with alias \"does_not_exist\" not found.");
stdChainsMock.exposed_getChain("does_not_exist");
}

function testSetChainFirstFails() public {
function test_SetChainFirstFails() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

vm.expectRevert("StdChains setChain(string,ChainData): Chain ID 31337 already used by \"anvil\".");
stdChainsMock.exposed_setChain("anvil2", ChainData("Anvil", 31337, "URL"));
}

function testChainBubbleUp() public {
function test_ChainBubbleUp() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

Expand All @@ -94,7 +94,7 @@ contract StdChainsTest is Test {
stdChainsMock.exposed_getChain("needs_undefined_env_var");
}

function testCannotSetChain_ChainIdExists() public {
function test_CannotSetChain_ChainIdExists() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

Expand All @@ -105,7 +105,7 @@ contract StdChainsTest is Test {
stdChainsMock.exposed_setChain("another_custom_chain", ChainData("", 123456789, ""));
}

function testSetChain() public {
function test_SetChain() public {
setChain("custom_chain", ChainData("Custom Chain", 123456789, "https://custom.chain/"));
Chain memory customChain = getChain("custom_chain");
assertEq(customChain.name, "Custom Chain");
Expand All @@ -131,47 +131,47 @@ contract StdChainsTest is Test {
assertEq(chainById.chainId, 123456789);
}

function testSetNoEmptyAlias() public {
function test_SetNoEmptyAlias() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

vm.expectRevert("StdChains setChain(string,ChainData): Chain alias cannot be the empty string.");
stdChainsMock.exposed_setChain("", ChainData("", 123456789, ""));
}

function testSetNoChainId0() public {
function test_SetNoChainId0() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

vm.expectRevert("StdChains setChain(string,ChainData): Chain ID cannot be 0.");
stdChainsMock.exposed_setChain("alias", ChainData("", 0, ""));
}

function testGetNoChainId0() public {
function test_GetNoChainId0() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

vm.expectRevert("StdChains getChain(uint256): Chain ID cannot be 0.");
stdChainsMock.exposed_getChain(0);
}

function testGetNoEmptyAlias() public {
function test_GetNoEmptyAlias() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

vm.expectRevert("StdChains getChain(string): Chain alias cannot be the empty string.");
stdChainsMock.exposed_getChain("");
}

function testChainIdNotFound() public {
function test_ChainIdNotFound() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

vm.expectRevert("StdChains getChain(string): Chain with alias \"no_such_alias\" not found.");
stdChainsMock.exposed_getChain("no_such_alias");
}

function testChainAliasNotFound() public {
function test_ChainAliasNotFound() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

Expand All @@ -180,7 +180,7 @@ contract StdChainsTest is Test {
stdChainsMock.exposed_getChain(321);
}

function testSetChain_ExistingOne() public {
function test_SetChain_ExistingOne() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

Expand All @@ -197,7 +197,7 @@ contract StdChainsTest is Test {
assertEq(modifiedChain.rpcUrl, "https://modified.chain/");
}

function testDontUseDefaultRpcUrl() public {
function test_DontUseDefaultRpcUrl() public {
// We deploy a mock to properly test the revert.
StdChainsMock stdChainsMock = new StdChainsMock();

Expand Down
Loading