mirror of
https://github.com/placeholder-soft/tokenbound.git
synced 2026-05-28 23:21:31 +08:00
* [H-3]: Added max lock time (#8) * Added max lock time of 1 year * Fixed tests + covered max unlock exceeded scenario * Removed payable castings (#9) * [L-2]: Added event coverage (#10) * [Q-1]: Added onlyUnlocked modifier (#11) * [Q-2] Removed unused imports (#12) * [Q-3]: Added ERC165 support (#14) * [G-3] Made vaultImplementation immutable (#15) * Added chainid to vault salt + context (#16) * Added chainid to vault salt + context to mitigate cross-chain attacks * Added support for deploying cross-chain vaults to VaultRegistry * Updated natspec docs * Added cross-chain executor (#17) * Added support for cross-chain executors and increased test coverage * added natspec coverage * Apply EIP naming conventions (#18) * migrated vault to account in accordance with eip naming * renamed VaultRegistry to AccountRegistry, updated naming in tests * split registry and cross chain executor list, renamed methods * finished migrating to eip naming conventions, split out tests, removed proxy size test * removed chainid from interface * remove console * removed unused imports * fix spelling * fixed registry interface to match eip * fix event * fixed event test * added event indexing
107 lines
2.8 KiB
Solidity
107 lines
2.8 KiB
Solidity
// SPDX-License-Identifier: UNLICENSED
|
|
pragma solidity ^0.8.13;
|
|
|
|
import "forge-std/Test.sol";
|
|
|
|
import "../src/lib/MinimalProxyStore.sol";
|
|
|
|
contract TestContract {
|
|
error Failed();
|
|
|
|
function test() public pure returns (uint256) {
|
|
return 123;
|
|
}
|
|
|
|
function fails() public pure {
|
|
revert Failed();
|
|
}
|
|
}
|
|
|
|
contract MinimalProxyStoreTest is Test {
|
|
function testDeploymentSucceeds() public {
|
|
TestContract testContract = new TestContract();
|
|
|
|
address clone = MinimalProxyStore.clone(
|
|
address(testContract),
|
|
abi.encode("hello")
|
|
);
|
|
|
|
assertTrue(clone != address(0));
|
|
assertEq(TestContract(clone).test(), 123);
|
|
}
|
|
|
|
function testReverts() public {
|
|
TestContract testContract = new TestContract();
|
|
|
|
address clone = MinimalProxyStore.clone(
|
|
address(testContract),
|
|
abi.encode("hello")
|
|
);
|
|
|
|
assertTrue(clone != address(0));
|
|
vm.expectRevert(TestContract.Failed.selector);
|
|
TestContract(clone).fails();
|
|
}
|
|
|
|
function testGetContext() public {
|
|
TestContract testContract = new TestContract();
|
|
|
|
bytes memory context = abi.encode("hello");
|
|
|
|
address clone = MinimalProxyStore.clone(address(testContract), context);
|
|
|
|
assertTrue(clone != address(0));
|
|
assertEq(TestContract(clone).test(), 123);
|
|
|
|
bytes memory recoveredContext = MinimalProxyStore.getContext(clone);
|
|
|
|
assertEq(recoveredContext, context);
|
|
}
|
|
|
|
function testCreate2() public {
|
|
TestContract testContract = new TestContract();
|
|
|
|
bytes memory context = abi.encode("hello");
|
|
|
|
address clone = MinimalProxyStore.cloneDeterministic(
|
|
address(testContract),
|
|
context,
|
|
keccak256("hello")
|
|
);
|
|
|
|
assertTrue(clone != address(0));
|
|
assertEq(TestContract(clone).test(), 123);
|
|
|
|
bytes memory recoveredContext = MinimalProxyStore.getContext(clone);
|
|
|
|
assertEq(recoveredContext, context);
|
|
|
|
address predictedAddress = MinimalProxyStore
|
|
.predictDeterministicAddress(
|
|
address(testContract),
|
|
context,
|
|
keccak256("hello")
|
|
);
|
|
|
|
assertEq(clone, predictedAddress);
|
|
}
|
|
|
|
function testRedeploymentFails() public {
|
|
TestContract testContract = new TestContract();
|
|
|
|
bytes memory context = abi.encode("hello");
|
|
|
|
MinimalProxyStore.cloneDeterministic(
|
|
address(testContract),
|
|
context,
|
|
keccak256("hello")
|
|
);
|
|
vm.expectRevert(MinimalProxyStore.CreateError.selector);
|
|
MinimalProxyStore.cloneDeterministic(
|
|
address(testContract),
|
|
context,
|
|
keccak256("hello")
|
|
);
|
|
}
|
|
}
|