Skip to content

Instantly share code, notes, and snippets.

@d10r
Created April 16, 2024 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d10r/9c099cadec0b80f120d12d63e9e4fd0b to your computer and use it in GitHub Desktop.
Save d10r/9c099cadec0b80f120d12d63e9e4fd0b to your computer and use it in GitHub Desktop.
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/openzeppelin-contracts@v4.9.3 --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