Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.23;
- contract Lottery {
- uint lotteryFee = 0.1 ether;
- uint8 counter = 0;
- mapping (uint8 => address) participants;
- function participate() external payable returns(address) {
- require(msg.value == lotteryFee);
- counter = counter + 1;
- participants[counter] = msg.sender;
- return(participants[counter]);
- }
- function getBalance() public returns (uint) {
- uint contractBalance = address(this).balance;
- return(contractBalance);
- }
- }
- pragma solidity ^0.4.23;
- import "truffle/Assert.sol";
- import "truffle/DeployedAddresses.sol";
- import "../contracts/Lottery.sol";
- contract TestLottery1 {
- Lottery lottery = Lottery(DeployedAddresses.Lottery());
- //Testing the participate() function
- function testUserCanParticipate() public {
- address returnedId = lottery.participate();
- address expected = msg.sender;
- Assert.equal(returnedId, expected, "You are participating");
- }
- }
Add Comment
Please, Sign In to add comment