Created
April 16, 2024 12:56
-
-
Save d10r/9c099cadec0b80f120d12d63e9e4fd0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -eux | |
# prerequisites: "forge" installed and in PATH, see https://book.getfoundry.sh/getting-started/installation | |
name=$1 | |
mkdir $name | |
cd $name | |
forge init --no-commit | |
forge install superfluid-protocol-monorepo=https://github.com/superfluid-finance/protocol-monorepo@dev --no-commit | |
forge install https://github.com/OpenZeppelin/[email protected] --no-commit | |
# add mappings | |
cat <<EOT >> foundry.toml | |
remappings = [ | |
'@superfluid-finance/ethereum-contracts=lib/superfluid-protocol-monorepo/packages/ethereum-contracts', | |
'@superfluid-finance/solidity-semantic-money=lib/superfluid-protocol-monorepo/packages/solidity-semantic-money', | |
'@openzeppelin/=lib/openzeppelin-contracts/', | |
] | |
EOT | |
# create Superfluid specific test contract | |
cat <<EOT > test/SFAppTest.t.sol | |
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.13; | |
import "forge-std/Test.sol"; | |
import { ERC1820RegistryCompiled } from "@superfluid-finance/ethereum-contracts/contracts/libs/ERC1820RegistryCompiled.sol"; | |
import { SuperfluidFrameworkDeployer } from "@superfluid-finance/ethereum-contracts/contracts/utils/SuperfluidFrameworkDeployer.sol"; | |
contract SFAppTest is Test { | |
SuperfluidFrameworkDeployer.Framework internal sf; | |
function setUp() public { | |
// deploy SF framework | |
vm.etch(ERC1820RegistryCompiled.at, ERC1820RegistryCompiled.bin); | |
SuperfluidFrameworkDeployer deployer = new SuperfluidFrameworkDeployer(); | |
deployer.deployTestFramework(); | |
sf = deployer.getFramework(); | |
} | |
function testGetHostTimestamp() public { | |
uint256 hostTS = sf.host.getNow(); | |
assertGt(hostTS, 0, "host timestamp is 0"); | |
} | |
} | |
EOT | |
# remove default examples | |
rm src/Counter.sol test/Counter.t.sol script/Counter.s.sol | |
# add TDD script | |
cat <<EOT > dev.sh | |
nodemon -w src/ -w test/ -e sol -x forge test \$@ | |
EOT | |
chmod +x dev.sh | |
echo "*********************************" | |
echo "now run: cd $name; ./dev.sh" | |
echo "and have fun!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment