-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add solc 0.6.x integration mocks (#461)
- Loading branch information
Showing
10 changed files
with
557 additions
and
83 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Testing hooks | ||
const fn = (msg, config) => config.logger.log(msg); | ||
|
||
module.exports = { | ||
skipFiles: ['Migrations.sol'], | ||
silent: process.env.SILENT ? true : false, | ||
istanbulReporter: ['json-summary', 'text'], | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const { loadPluginFile } = require("@nomiclabs/buidler/plugins-testing"); | ||
loadPluginFile(__dirname + "/../plugins/buidler.plugin"); | ||
usePlugin("@nomiclabs/buidler-truffle5"); | ||
|
||
module.exports={ | ||
defaultNetwork: "buidlerevm", | ||
solc: { | ||
version: "0.6.0" | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
import "./ContractB.sol"; | ||
|
||
/** | ||
* New syntaxes in solc 0.6.x | ||
*/ | ||
contract ContractA is ContractB { | ||
uint counter; | ||
uint errorCount; | ||
|
||
modifier overridden() override { | ||
require(true); | ||
_; | ||
} | ||
|
||
constructor() public { | ||
} | ||
|
||
function simpleSet(uint i) | ||
public | ||
override(ContractB) | ||
{ | ||
counter = counter + i; | ||
} | ||
|
||
function simpleView(uint i) | ||
view | ||
overridden | ||
external | ||
returns (uint, bool) | ||
{ | ||
return (counter + i, true); | ||
} | ||
|
||
function tryCatch() public returns (uint, bool) { | ||
try this.simpleView(5) returns (uint, bool) { | ||
return (2, true); | ||
} catch Error(string memory) { | ||
errorCount++; | ||
return (0, false); | ||
} catch (bytes memory) { | ||
errorCount++; | ||
return (0, false); | ||
} | ||
} | ||
|
||
function arraySlice() public pure { | ||
abi.decode(msg.data[4:], (uint, uint)); | ||
} | ||
|
||
function payableFn() public pure { | ||
address x; | ||
address y = payable(x); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
pragma solidity ^0.6.0; | ||
|
||
|
||
contract ContractB { | ||
uint value; | ||
|
||
constructor() public { | ||
} | ||
|
||
modifier overridden() virtual { | ||
require(true); | ||
_; | ||
} | ||
|
||
function simpleSet(uint i) public virtual { | ||
value = 5; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const ContractA = artifacts.require("ContractA"); | ||
|
||
contract("contracta", function(accounts) { | ||
let instance; | ||
|
||
before(async () => instance = await ContractA.new()) | ||
|
||
it('simpleSet (overridden method)', async function(){ | ||
await instance.simpleSet(5); | ||
}); | ||
|
||
it('simpleView (overridden modifier)', async function(){ | ||
await instance.simpleView(5); | ||
}); | ||
|
||
it('tryCatch', async function(){ | ||
await instance.tryCatch(); | ||
}); | ||
|
||
it('arraySlice', async function(){ | ||
await instance.arraySlice(); | ||
}); | ||
|
||
it('payableFn', async function(){ | ||
await instance.payableFn(); | ||
}) | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
networks: {}, | ||
mocha: {}, | ||
compilers: { | ||
solc: { | ||
version: "0.6.0" | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.