|
|
@ -33,6 +33,8 @@ const owner = `// SPDX-License-Identifier: GPL-3.0 |
|
|
|
|
|
|
|
|
|
|
|
pragma solidity >=0.7.0 <0.9.0; |
|
|
|
pragma solidity >=0.7.0 <0.9.0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import "hardhat/console.sol"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @title Owner |
|
|
|
* @title Owner |
|
|
|
* @dev Set & change owner |
|
|
|
* @dev Set & change owner |
|
|
@ -59,6 +61,7 @@ contract Owner { |
|
|
|
* @dev Set contract deployer as owner |
|
|
|
* @dev Set contract deployer as owner |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
|
|
|
|
|
console.log("Owner contract deployed by:", msg.sender); |
|
|
|
owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
|
|
|
|
owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
|
|
|
|
emit OwnerSet(address(0), owner); |
|
|
|
emit OwnerSet(address(0), owner); |
|
|
|
} |
|
|
|
} |
|
|
@ -225,6 +228,7 @@ const ballotTest = `// SPDX-License-Identifier: GPL-3.0 |
|
|
|
|
|
|
|
|
|
|
|
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 "../contracts/3_Ballot.sol"; |
|
|
|
import "../contracts/3_Ballot.sol"; |
|
|
|
|
|
|
|
|
|
|
|
contract BallotTest { |
|
|
|
contract BallotTest { |
|
|
@ -238,6 +242,7 @@ contract BallotTest { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function checkWinningProposal () public { |
|
|
|
function checkWinningProposal () public { |
|
|
|
|
|
|
|
console.log("Running checkWinningProposal"); |
|
|
|
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"); |
|
|
|
Assert.equal(ballotToTest.winnerName(), bytes32("candidate1"), "candidate1 should be the winner name"); |
|
|
|
Assert.equal(ballotToTest.winnerName(), bytes32("candidate1"), "candidate1 should be the winner name"); |
|
|
|