pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "../src/MultiSigTimelock.sol";
contract MultiSigTimelockTest is Test {
MultiSigTimelock multiSig;
address owner = address(0xA11CE);
address signer1 = address(0xB0B);
address signer2 = address(0xC0C);
address signer3 = address(0xD0D);
address recipient = address(0xE0E);
function setUp() public {
vm.prank(owner);
multiSig = new MultiSigTimelock();
vm.prank(owner);
multiSig.grantSigningRole(signer1);
vm.prank(owner);
multiSig.grantSigningRole(signer2);
vm.prank(owner);
multiSig.grantSigningRole(signer3);
}
function testOwnerCanProposeTransaction() public {
vm.prank(owner);
uint256 txId = multiSig.proposeTransaction(recipient, 1 ether, "");
MultiSigTimelock.Transaction memory txn = multiSig.getTransaction(txId);
assertEq(txn.to, recipient);
assertEq(txn.value, 1 ether);
assertEq(txn.executed, false);
}
function testSignerCannotProposeTransaction() public {
vm.prank(signer1);
vm.expectRevert("Ownable: caller is not the owner");
multiSig.proposeTransaction(recipient, 1 ether, "");
}
function testNonSignerCannotProposeTransaction() public {
address attacker = address(0x999);
vm.prank(attacker);
vm.expectRevert("Ownable: caller is not the owner");
multiSig.proposeTransaction(recipient, 1 ether, "");
}
}