|
|
@ -155,6 +155,7 @@ module.exports = { |
|
|
|
.clearValue('*[data-id="uiPathInput"]') |
|
|
|
.clearValue('*[data-id="uiPathInput"]') |
|
|
|
.setValue('*[data-id="uiPathInput"]', 'myTests') |
|
|
|
.setValue('*[data-id="uiPathInput"]', 'myTests') |
|
|
|
.click('*[data-id="testTabGenerateTestFolder"]') |
|
|
|
.click('*[data-id="testTabGenerateTestFolder"]') |
|
|
|
|
|
|
|
.saveScreenshot('./reports/screenshots/changeCurrentPathg3.png') |
|
|
|
.clickElementAtPosition('.singleTest', 0, { forceSelectIfUnselected: true }) |
|
|
|
.clickElementAtPosition('.singleTest', 0, { forceSelectIfUnselected: true }) |
|
|
|
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]') |
|
|
|
.scrollAndClick('*[data-id="testTabRunTestsTabRunAction"]') |
|
|
|
.waitForElementPresent('*[data-id="testTabSolidityUnitTestsOutputheader"]', 60000) |
|
|
|
.waitForElementPresent('*[data-id="testTabSolidityUnitTestsOutputheader"]', 60000) |
|
|
@ -359,15 +360,15 @@ const sources = [ |
|
|
|
|
|
|
|
|
|
|
|
contract SimpleStorage { |
|
|
|
contract SimpleStorage { |
|
|
|
uint public storedData; |
|
|
|
uint public storedData; |
|
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
|
storedData = 100; |
|
|
|
storedData = 100; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function set(uint x) public { |
|
|
|
function set(uint x) public { |
|
|
|
storedData = x; |
|
|
|
storedData = x; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function get() public view returns (uint retVal) { |
|
|
|
function get() public view returns (uint retVal) { |
|
|
|
return storedData; |
|
|
|
return storedData; |
|
|
|
} |
|
|
|
} |
|
|
@ -408,7 +409,7 @@ const sources = [ |
|
|
|
pragma solidity >=0.4.22 <0.9.0; |
|
|
|
pragma solidity >=0.4.22 <0.9.0; |
|
|
|
contract Kickstarter { |
|
|
|
contract Kickstarter { |
|
|
|
enum State { Started, Completed } |
|
|
|
enum State { Started, Completed } |
|
|
|
|
|
|
|
|
|
|
|
struct Project { |
|
|
|
struct Project { |
|
|
|
address owner; |
|
|
|
address owner; |
|
|
|
string name; |
|
|
|
string name; |
|
|
@ -420,10 +421,10 @@ const sources = [ |
|
|
|
} |
|
|
|
} |
|
|
|
uint numProjects; |
|
|
|
uint numProjects; |
|
|
|
Project[] public projects; |
|
|
|
Project[] public projects; |
|
|
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function createProject(string memory name, uint goal) public { |
|
|
|
function createProject(string memory name, uint goal) public { |
|
|
|
projects.push(); // new line
|
|
|
|
projects.push(); // new line
|
|
|
|
Project storage project = projects[projects.length - 1]; |
|
|
|
Project storage project = projects[projects.length - 1]; |
|
|
@ -432,28 +433,28 @@ const sources = [ |
|
|
|
project.owner = msg.sender; |
|
|
|
project.owner = msg.sender; |
|
|
|
project.state = State.Started; |
|
|
|
project.state = State.Started; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function fundProject(uint projectId) payable public { |
|
|
|
function fundProject(uint projectId) payable public { |
|
|
|
Project storage project = projects[projectId]; |
|
|
|
Project storage project = projects[projectId]; |
|
|
|
// require project exists
|
|
|
|
// require project exists
|
|
|
|
// PLEASE CHECK / or erase
|
|
|
|
// PLEASE CHECK / or erase
|
|
|
|
// not this: require(projects[projectId].exists, "the project must exist to be funded");
|
|
|
|
// not this: require(projects[projectId].exists, "the project must exist to be funded");
|
|
|
|
|
|
|
|
|
|
|
|
// require for... underflow/overflow protection
|
|
|
|
// require for... underflow/overflow protection
|
|
|
|
project.funders[msg.sender] += msg.value; |
|
|
|
project.funders[msg.sender] += msg.value; |
|
|
|
project.amountContributed += msg.value; |
|
|
|
project.amountContributed += msg.value; |
|
|
|
project.fundsAvailable += msg.value; |
|
|
|
project.fundsAvailable += msg.value; |
|
|
|
|
|
|
|
|
|
|
|
if (project.amountContributed >= project.goal) { |
|
|
|
if (project.amountContributed >= project.goal) { |
|
|
|
project.state = State.Completed; |
|
|
|
project.state = State.Completed; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// this function is here because we can't use web3 when using the VM
|
|
|
|
// this function is here because we can't use web3 when using the VM
|
|
|
|
function getContractBalance() public view returns(uint balance) { |
|
|
|
function getContractBalance() public view returns(uint balance) { |
|
|
|
return address(this).balance; |
|
|
|
return address(this).balance; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
` |
|
|
|
` |
|
|
|
}, |
|
|
|
}, |
|
|
@ -470,13 +471,13 @@ const sources = [ |
|
|
|
enum State { Started, Completed } |
|
|
|
enum State { Started, Completed } |
|
|
|
|
|
|
|
|
|
|
|
Kickstarter kickstarter; |
|
|
|
Kickstarter kickstarter; |
|
|
|
|
|
|
|
|
|
|
|
function beforeAll () public { |
|
|
|
function beforeAll () public { |
|
|
|
kickstarter = new Kickstarter(); |
|
|
|
kickstarter = new Kickstarter(); |
|
|
|
kickstarter.createProject("ProjectA", 123000); |
|
|
|
kickstarter.createProject("ProjectA", 123000); |
|
|
|
kickstarter.createProject("ProjectB", 100); |
|
|
|
kickstarter.createProject("ProjectB", 100); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// #sender: account-1
|
|
|
|
/// #sender: account-1
|
|
|
|
/// #value: 10000000
|
|
|
|
/// #value: 10000000
|
|
|
|
function checkProjectExists () public payable { |
|
|
|
function checkProjectExists () public payable { |
|
|
@ -512,14 +513,14 @@ const sources = [ |
|
|
|
(address owner, string memory name, uint goal, uint fundsAvailable, uint amountContributed, Kickstarter.State state) = kickstarter.projects(0); |
|
|
|
(address owner, string memory name, uint goal, uint fundsAvailable, uint amountContributed, Kickstarter.State state) = kickstarter.projects(0); |
|
|
|
Assert.equal(amountContributed, 120000, "contributed amount is incorrect"); |
|
|
|
Assert.equal(amountContributed, 120000, "contributed amount is incorrect"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
` |
|
|
|
` |
|
|
|
}, |
|
|
|
}, |
|
|
|
'compilationError_test.sol': { |
|
|
|
'compilationError_test.sol': { |
|
|
|
content: ` |
|
|
|
content: ` |
|
|
|
pragma solidity ^0.8.0; |
|
|
|
pragma solidity ^0.8.0; |
|
|
|
|
|
|
|
|
|
|
|
contract failOnCompilation { |
|
|
|
contract failOnCompilation { |
|
|
|
fallback() { |
|
|
|
fallback() { |
|
|
|
|
|
|
|
|
|
|
@ -547,7 +548,7 @@ const sources = [ |
|
|
|
uint c = a+b; |
|
|
|
uint c = a+b; |
|
|
|
Assert.equal(a+b, c, "wrong value"); |
|
|
|
Assert.equal(a+b, c, "wrong value"); |
|
|
|
} |
|
|
|
} |
|
|
|
}
|
|
|
|
} |
|
|
|
` |
|
|
|
` |
|
|
|
}, |
|
|
|
}, |
|
|
|
'tests/ballotFailedDebug_test.sol': { |
|
|
|
'tests/ballotFailedDebug_test.sol': { |
|
|
@ -556,31 +557,31 @@ const sources = [ |
|
|
|
pragma solidity >=0.7.0 <0.9.0; |
|
|
|
pragma solidity >=0.7.0 <0.9.0; |
|
|
|
import "remix_tests.sol"; // this import is automatically injected by Remix.
|
|
|
|
import "remix_tests.sol"; // this import is automatically injected by Remix.
|
|
|
|
import "../contracts/3_Ballot.sol"; |
|
|
|
import "../contracts/3_Ballot.sol"; |
|
|
|
|
|
|
|
|
|
|
|
contract BallotTest { |
|
|
|
contract BallotTest { |
|
|
|
|
|
|
|
|
|
|
|
bytes32[] proposalNames; |
|
|
|
bytes32[] proposalNames; |
|
|
|
|
|
|
|
|
|
|
|
Ballot ballotToTest; |
|
|
|
Ballot ballotToTest; |
|
|
|
function beforeAll () public { |
|
|
|
function beforeAll () public { |
|
|
|
proposalNames.push(bytes32("candidate1")); |
|
|
|
proposalNames.push(bytes32("candidate1")); |
|
|
|
ballotToTest = new Ballot(proposalNames); |
|
|
|
ballotToTest = new Ballot(proposalNames); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function checkWinningProposalFailed () public { |
|
|
|
function checkWinningProposalFailed () public { |
|
|
|
ballotToTest.vote(1); |
|
|
|
ballotToTest.vote(1); |
|
|
|
Assert.equal(ballotToTest.winningProposal(), uint(0), "proposal at index 0 should be the winning proposal"); |
|
|
|
Assert.equal(ballotToTest.winningProposal(), uint(0), "proposal at index 0 should be the winning proposal"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function checkWinningProposalPassed () public { |
|
|
|
function checkWinningProposalPassed () public { |
|
|
|
ballotToTest.vote(0); |
|
|
|
ballotToTest.vote(0); |
|
|
|
Assert.equal(ballotToTest.winningProposal(), uint(0), "proposal at index 0 should be the winning proposal"); |
|
|
|
Assert.equal(ballotToTest.winningProposal(), uint(0), "proposal at index 0 should be the winning proposal"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function checkWinningProposalAgain () public { |
|
|
|
function checkWinningProposalAgain () public { |
|
|
|
Assert.equal(ballotToTest.winningProposal(), uint(1), "proposal at index 0 should be the winning proposal"); |
|
|
|
Assert.equal(ballotToTest.winningProposal(), uint(1), "proposal at index 0 should be the winning proposal"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function checkWinninProposalWithReturnValue () public view returns (bool) { |
|
|
|
function checkWinninProposalWithReturnValue () public view returns (bool) { |
|
|
|
return ballotToTest.winningProposal() == 0; |
|
|
|
return ballotToTest.winningProposal() == 0; |
|
|
|
} |
|
|
|
} |
|
|
@ -594,17 +595,17 @@ const sources = [ |
|
|
|
import "../contracts/3_Ballot.sol"; |
|
|
|
import "../contracts/3_Ballot.sol"; |
|
|
|
|
|
|
|
|
|
|
|
import "hardhat/console.sol"; |
|
|
|
import "hardhat/console.sol"; |
|
|
|
|
|
|
|
|
|
|
|
contract BallotTest { |
|
|
|
contract BallotTest { |
|
|
|
|
|
|
|
|
|
|
|
bytes32[] proposalNames; |
|
|
|
bytes32[] proposalNames; |
|
|
|
|
|
|
|
|
|
|
|
Ballot ballotToTest; |
|
|
|
Ballot ballotToTest; |
|
|
|
function beforeAll () public { |
|
|
|
function beforeAll () public { |
|
|
|
proposalNames.push(bytes32("candidate1")); |
|
|
|
proposalNames.push(bytes32("candidate1")); |
|
|
|
ballotToTest = new Ballot(proposalNames); |
|
|
|
ballotToTest = new Ballot(proposalNames); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function checkWinningProposal () public { |
|
|
|
function checkWinningProposal () public { |
|
|
|
console.log("Inside checkWinningProposal"); |
|
|
|
console.log("Inside checkWinningProposal"); |
|
|
|
ballotToTest.vote(1); // This will revert the transaction
|
|
|
|
ballotToTest.vote(1); // This will revert the transaction
|
|
|
@ -617,13 +618,13 @@ const sources = [ |
|
|
|
pragma solidity >=0.7.0 <0.9.0; |
|
|
|
pragma solidity >=0.7.0 <0.9.0; |
|
|
|
import "remix_tests.sol"; // this import is automatically injected by Remix.
|
|
|
|
import "remix_tests.sol"; // this import is automatically injected by Remix.
|
|
|
|
import "hardhat/console.sol"; |
|
|
|
import "hardhat/console.sol"; |
|
|
|
|
|
|
|
|
|
|
|
contract hhLogs { |
|
|
|
contract hhLogs { |
|
|
|
|
|
|
|
|
|
|
|
function beforeAll () public { |
|
|
|
function beforeAll () public { |
|
|
|
console.log('Inside beforeAll'); |
|
|
|
console.log('Inside beforeAll'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function checkSender () public { |
|
|
|
function checkSender () public { |
|
|
|
console.log('msg.sender is %s', msg.sender); |
|
|
|
console.log('msg.sender is %s', msg.sender); |
|
|
|
Assert.ok(true, "should be true"); |
|
|
|
Assert.ok(true, "should be true"); |
|
|
|