52 lines
1.6 KiB
Solidity
52 lines
1.6 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.19;
|
|
|
|
import "forge-std/Test.sol";
|
|
import {MultiSigWallet} from "../src/MultiSig.sol";
|
|
|
|
contract MultiSigWalletTest is Test {
|
|
MultiSigWallet multiSigWallet;
|
|
address user = address(0x123);
|
|
address user2 = address(0x456);
|
|
|
|
function setUp() public {
|
|
multiSigWallet = new MultiSigWallet(user, user2);
|
|
|
|
vm.deal(address(multiSigWallet), 10 ether);
|
|
vm.deal(user, 10 ether);
|
|
vm.deal(user2, 10 ether);
|
|
}
|
|
|
|
function testSetup() public {
|
|
address owner1 = multiSigWallet.owner1();
|
|
address owner2 = multiSigWallet.owner2();
|
|
|
|
assertEq(owner1, user);
|
|
assertEq(owner2, user2);
|
|
assertEq(address(multiSigWallet).balance, 10 ether);
|
|
}
|
|
|
|
function testUserInRelationshipWithBlockedProfileUnableToWithdraw() public {
|
|
uint256 initialMultiSigWalletBalance = address(multiSigWallet).balance;
|
|
uint256 initialUserBalance = address(user).balance;
|
|
uint256 withdrawBalance = initialMultiSigWalletBalance / 2;
|
|
|
|
vm.startPrank(user);
|
|
// submit tx
|
|
multiSigWallet.submitTransaction(address(user), withdrawBalance);
|
|
|
|
// approve tx
|
|
multiSigWallet.approveTransaction(0);
|
|
|
|
// execute
|
|
vm.expectRevert();
|
|
multiSigWallet.executeTransaction(0);
|
|
vm.stopPrank();
|
|
|
|
(address to, uint256 value, bool approvedByOwner1, bool approvedByOwner2, bool executed) = multiSigWallet.transactions(0);
|
|
assertEq(executed, false); // unable to execute because need both of approval, despite the other user is already blocked
|
|
assertEq(address(user).balance, initialUserBalance + withdrawBalance); // user should be able to withdraw their fund from multiSigWallet from a blocked profile
|
|
}
|
|
}
|
|
|