You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This applies to "General Test Guidance" section 3.1, add something like the following:
Below is an example of this pattern for a factory contract called MyFactory that deploys a child contract called Child. A sample, unimplemented MyFactory contract is below. The actual content of all methods is left out for brevity, and only function signatures and empty function bodies are shown.
// file: src/MyFactory.solcontractMyFactory {
constructor() {}
function deploy(addressowner) external {}
function computeAddress(addressowner) external {}
}
Next we have it's test contract. Aside from the MyFactoryTest setup contract, all contract names match methods in the MyFactory contract in the order they appear, and each test function in the test contracts asserts on a single thing that function should do.
// file: test/MyFactory.t.solcontractMyFactoryTestisTest {
// Setup to deploy contracts, etc. goes in this contract.
}
contractConstructorisMyFactoryTest {
function test_SetsChildContractLogicAddress() public {}
function test_SetsOwnerAddress() public {}
}
contractDeployisMyFactoryTest {
function deployChild() internalreturns (address) {} // helper methodfunction test_RevertsIf_CalledByAccountThatIsNotOwner(addresscaller) public {}
function test_IncrementsChildDeployCountByOne() public {}
function test_DeploysChildAsMinimalProxy() public {}
function test_InitializesChildContract() public {}
function test_SetsChildOwnerAddress() public {}
function test_EmitsChildDeployedEvent() public {}
function test_ReturnsAddressOfTheNewChildContract() public {}
}
contractComputeAddressisMyFactoryTest {
function test_ComputesExpectedAddress() public {}
}
The text was updated successfully, but these errors were encountered:
This applies to "General Test Guidance" section 3.1, add something like the following:
Below is an example of this pattern for a factory contract called
MyFactory
that deploys a child contract calledChild
. A sample, unimplementedMyFactory
contract is below. The actual content of all methods is left out for brevity, and only function signatures and empty function bodies are shown.Next we have it's test contract. Aside from the
MyFactoryTest
setup contract, all contract names match methods in theMyFactory
contract in the order they appear, and each test function in the test contracts asserts on a single thing that function should do.The text was updated successfully, but these errors were encountered: