@@ -3,6 +3,7 @@ pragma solidity ^0.8.20;
3
3
4
4
import { EnsoWalletV2Factory } from "../../../../../src/wallet/EnsoWalletV2Factory.sol " ;
5
5
import { EnsoWalletV2_Unit_Concrete_Test } from "../ensowalletv2/EnsoWalletV2.t.sol " ;
6
+ import { Vm } from "forge-std/Test.sol " ;
6
7
7
8
contract EnsoWalletV2Factory_GetAddress_Unit_Concrete_Test is EnsoWalletV2_Unit_Concrete_Test {
8
9
function test_WhenCalled () external {
@@ -35,4 +36,29 @@ contract EnsoWalletV2Factory_GetAddress_Unit_Concrete_Test is EnsoWalletV2_Unit_
35
36
36
37
assertTrue (predictedAddress1 != predictedAddress2);
37
38
}
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