Skip to content

Commit 39884f9

Browse files
committed
EnsoWalletV2 deployement test
1 parent a87a68f commit 39884f9

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

test/unit/concrete/wallet/ensowalletv2factory/getAddress.t.sol

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pragma solidity ^0.8.20;
33

44
import { EnsoWalletV2Factory } from "../../../../../src/wallet/EnsoWalletV2Factory.sol";
55
import { EnsoWalletV2_Unit_Concrete_Test } from "../ensowalletv2/EnsoWalletV2.t.sol";
6+
import { Vm } from "forge-std/Test.sol";
67

78
contract EnsoWalletV2Factory_GetAddress_Unit_Concrete_Test is EnsoWalletV2_Unit_Concrete_Test {
89
function test_WhenCalled() external {
@@ -35,4 +36,29 @@ contract EnsoWalletV2Factory_GetAddress_Unit_Concrete_Test is EnsoWalletV2_Unit_
3536

3637
assertTrue(predictedAddress1 != predictedAddress2);
3738
}
38-
}
39+
40+
function test_WhenDeployedTwice() external {
41+
// it should emit event only on first deployment
42+
address predictedAddress = s_walletFactory.getAddress(s_account1);
43+
44+
vm.startPrank(s_user);
45+
46+
// First deployment - should emit event
47+
vm.expectEmit(true, true, true, true, address(s_walletFactory));
48+
emit EnsoWalletV2Factory.EnsoWalletV2Deployed(predictedAddress, s_account1);
49+
address walletAddress1 = s_walletFactory.deploy(s_account1);
50+
51+
// Second deployment - should not emit event (same address)
52+
vm.recordLogs();
53+
address walletAddress2 = s_walletFactory.deploy(s_account1);
54+
55+
// Verify same address returned
56+
assertEq(walletAddress1, walletAddress2);
57+
assertEq(walletAddress1, predictedAddress);
58+
59+
// Verify no events were emitted on second deployment
60+
Vm.Log[] memory logs = vm.getRecordedLogs();
61+
assertEq(logs.length, 0);
62+
}
63+
}
64+

0 commit comments

Comments
 (0)