Skip to content

Commit

Permalink
refactor: use vm.envOr instead of envBool
Browse files Browse the repository at this point in the history
  • Loading branch information
Zer0dot committed Aug 19, 2024
1 parent e6d51fe commit f7103a6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test/account/ImmutableAppend.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ contract ImmutableAppendTest is AccountTestBase {
/* -------------------------------------------------------------------------- */

function test_success_getData() public {
if (!vm.envBool("SMA_TEST")) {
if (!vm.envOr("SMA_TEST", false)) {
// this test isn't relevant at all for non-SMA, and is temporary.
return;
}
Expand Down
4 changes: 2 additions & 2 deletions test/account/UpgradeableModularAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ contract UpgradeableModularAccountTest is AccountTestBase {
}

function test_basicUserOp_withInitCode() public {
bytes memory callData = vm.envBool("SMA_TEST")
bytes memory callData = vm.envOr("SMA_TEST", false)
? abi.encodeCall(SemiModularAccount(payable(account1)).updateFallbackSigner, (owner2))
: abi.encodeCall(
UpgradeableModularAccount.execute,
Expand Down Expand Up @@ -363,7 +363,7 @@ contract UpgradeableModularAccountTest is AccountTestBase {

// TODO: Consider if this test belongs here or in the tests specific to the SingleSignerValidationModule
function test_transferOwnership() public {
if (vm.envBool("SMA_TEST")) {
if (vm.envOr("SMA_TEST", false)) {
// Note: replaced "owner1" with address(0), this doesn't actually affect the account, but allows the
// test to pass by ensuring the signer can be set in the validation.
assertEq(
Expand Down
8 changes: 4 additions & 4 deletions test/mocks/SingleSignerFactoryFixture.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract SingleSignerFactoryFixture is OptimizedTest {
constructor(IEntryPoint _entryPoint, SingleSignerValidationModule _singleSignerValidationModule) {
entryPoint = _entryPoint;

accountImplementation = vm.envBool("SMA_TEST")
accountImplementation = vm.envOr("SMA_TEST", false)
? _deploySemiModularAccount(_entryPoint)
: _deployUpgradeableModularAccount(_entryPoint);
_PROXY_BYTECODE_HASH = keccak256(
Expand All @@ -50,7 +50,7 @@ contract SingleSignerFactoryFixture is OptimizedTest {
function createAccount(address owner, uint256 salt) public returns (UpgradeableModularAccount) {
// We cast the SemiModularAccount to an UpgradeableModularAccount to facilitate equivalence testing.
// However, we don't do this in the actual factory.
if (vm.envBool("SMA_TEST")) {
if (vm.envOr("SMA_TEST", false)) {
return createSemiModularAccount(owner, salt);
}

Expand Down Expand Up @@ -97,8 +97,8 @@ contract SingleSignerFactoryFixture is OptimizedTest {
/**
* calculate the counterfactual address of this account as it would be returned by createAccount()
*/
function getAddress(address owner, uint256 salt) public view returns (address) {
if (vm.envBool("SMA_TEST")) {
function getAddress(address owner, uint256 salt) public returns (address) {
if (vm.envOr("SMA_TEST", false)) {
return getAddressFallbackSigner(owner, salt);
}
return Create2.computeAddress(getSalt(owner, salt), _PROXY_BYTECODE_HASH);
Expand Down
2 changes: 1 addition & 1 deletion test/utils/AccountTestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ abstract contract AccountTestBase is OptimizedTest {
function _transferOwnershipToTest() internal {
// Transfer ownership to test contract for easier invocation.
vm.prank(owner1);
if (vm.envBool("SMA_TEST")) {
if (vm.envOr("SMA_TEST", false)) {
account1.executeWithAuthorization(
abi.encodeCall(SemiModularAccount(payable(account1)).updateFallbackSigner, (address(this))),
_encodeSignature(_signerValidation, GLOBAL_VALIDATION, "")
Expand Down
2 changes: 1 addition & 1 deletion test/utils/CustomValidationTestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract contract CustomValidationTestBase is AccountTestBase {

account1 = UpgradeableModularAccount(payable(new ERC1967Proxy{salt: 0}(accountImplementation, "")));

if (vm.envBool("SMA_TEST")) {
if (vm.envOr("SMA_TEST", false)) {
vm.prank(address(entryPoint));
// The initializer doesn't work on the SMA
account1.installValidation(
Expand Down

0 comments on commit f7103a6

Please sign in to comment.