This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Remove/obviate boilerplate files #1382
Labels
Comments
P.S. Here is the minimal project I can create that works with Truffle test.
|
Thank you for raising this issue! It has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you would like to keep this issue open, please respond with information about the current state of this problem. |
Thank you, this issue is resolved now. Boilerplate is no longer necessary as of Truffle 5.0.1. Only a single Here is a minimal test case which demonstrates the new version works. mkdir -p tmp/test tmp/contracts tmp/migrations
cat > tmp/truffle.js <<EOL
// Boilerplate required, https://github.com/trufflesuite/truffle/issues/1382
EOL
cat > tmp/test/TestMetacoin.sol <<EOL
pragma solidity ^0.5.0;
import "truffle/Assert.sol";
import "../contracts/MetaCoin.sol";
contract TestMetacoin {
function testBal() public {
MetaCoin meta = new MetaCoin();
uint expected = 5;
Assert.equal(meta.getBalance(tx.origin), expected, "Owner should have 10000 MetaCoin iitially");
}
}
EOL
cat > tmp/contracts/MetaCoin.sol <<EOL
pragma solidity ^0.5.0;
contract MetaCoin {
function getBalance(address) public pure returns(uint) {
return 5;
}
}
EOL
(cd tmp && npx truffle test)
rm -rf tmp |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I loathed getting started with Truffle because there are so many files necessary to get hello world running. Then while I am learning it, I find out that these files deliver no value and are simply boilerplate.
Truffle should learn to work well without these files. Copy-pasting these files into my project do not make me a better programmer, they do not help me learn anything, and they are a distraction from writing tests or doing whatever else I want to do. Sure, maybe I will want to customize some Truffle behavior in the future, but the time to do that is not when just getting started.
truffle.js
Fix this error by placing the following file in truffle.js:
Clearly this file is not adding any value.
Perhaps the reason this file is needed is because otherwise Truffle doesn't know which folder to search for contracts. But of course the obvious default is to search the current folder and subdirectories for contracts.
migrations/1*.js
If you put this file into
migrations/1-boilerplate.js
the error goes away:I don't know what this file does and I don't care. It is the same file every project uses. I didn't wake up today wanting to write Javascript, I want to write Solidity.
If this file is missing, Truffle should gracefully default to not doing any migrations.
contracts/Migrations.sol
Obviously this is required because the boilerplate migration js file referenced it. So I won't bother to post the error message you get if the file is missing.
You need to put this file into
contracts/Migrations.sol
.At least this is written in Solidity. But it doesn't look like anything I care about. Most projects are just copy-pasting this.
updated
,setCompleted
andrestricted
don't look like functions I will call from any of my tests. So this is clearly a file I don't care about.Since my test cases do not depend on the those functions, Truffle should gracefully proceed if I do not provide this file.
The text was updated successfully, but these errors were encountered: