Skip to content

Commit

Permalink
fix single owner plugin events tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fangting-alchemy committed Jun 22, 2024
1 parent ae7bacb commit 085bc78
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions test/plugin/SingleOwnerPlugin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract SingleOwnerPluginTest is OptimizedTest {
ContractOwner public contractOwner;

// Event declarations (needed for vm.expectEmit)
event OwnershipTransferred(address indexed account, Signer indexed previousOwner, Signer indexed newOwner);
event OwnershipTransferred(address indexed account, Signer previousOwner, Signer newOwner);

function setUp() public {
plugin = _deploySingleOwnerPlugin();
Expand Down Expand Up @@ -74,17 +74,17 @@ contract SingleOwnerPluginTest is OptimizedTest {
assertEq(owner1, _getAccountOwnerAddress(plugin, address(a)));
}

// function test_ownerInitializationEvent() public {
// vm.startPrank(a);
// assertEq(address(0), _getAccountOwnerAddress(plugin, address(a)));
function test_ownerInitializationEvent() public {
vm.startPrank(a);
assertEq(address(0), _getAccountOwnerAddress(plugin, address(a)));

// vm.expectEmit(true, true, true, true);
// emit OwnershipTransferred(a, Signer(IStatelessValidator(address(0)), ""),
// signer1);
Signer memory emptySigner;
vm.expectEmit(true, true, true, true);
emit OwnershipTransferred(a, emptySigner, signer1);

// plugin.transferOwnership(signer1);
// assertEq(owner1, _getAccountOwnerAddress(plugin, address(a)));
// }
plugin.transferOwnership(signer1);
assertEq(owner1, _getAccountOwnerAddress(plugin, address(a)));
}

function test_ownerMigration() public {
vm.startPrank(a);
Expand All @@ -95,22 +95,23 @@ contract SingleOwnerPluginTest is OptimizedTest {
assertEq(owner2, _getAccountOwnerAddress(plugin, address(a)));
}

// function test_ownerMigrationEvents() public {
// vm.startPrank(a);
// assertEq(address(0), _getAccountOwnerAddress(plugin, address(a)));
function test_ownerMigrationEvents() public {
vm.startPrank(a);
assertEq(address(0), _getAccountOwnerAddress(plugin, address(a)));
Signer memory emptySigner;

// vm.expectEmit(true, true, true, true);
// emit OwnershipTransferred(a, Signer(IStatelessValidator(address(0)), abi.encode(address(0))), signer1);
vm.expectEmit(true, true, true, true);
emit OwnershipTransferred(a, emptySigner, signer1);

// plugin.transferOwnership(signer1);
// assertEq(owner1, _getAccountOwnerAddress(plugin, address(a)));
plugin.transferOwnership(signer1);
assertEq(owner1, _getAccountOwnerAddress(plugin, address(a)));

// vm.expectEmit(true, true, true, true);
// emit OwnershipTransferred(a, signer1, signer2);
vm.expectEmit(true, true, true, true);
emit OwnershipTransferred(a, signer1, signer2);

// plugin.transferOwnership(signer2);
// assertEq(owner2, _getAccountOwnerAddress(plugin, address(a)));
// }
plugin.transferOwnership(signer2);
assertEq(owner2, _getAccountOwnerAddress(plugin, address(a)));
}

function test_ownerForSender() public {
vm.startPrank(a);
Expand Down

0 comments on commit 085bc78

Please sign in to comment.