commit
95c6bf03ec
@ -0,0 +1,156 @@ |
|||||||
|
pragma solidity ^0.5.0; |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Wrappers over Solidity's arithmetic operations with added overflow |
||||||
|
* checks. |
||||||
|
* |
||||||
|
* Arithmetic operations in Solidity wrap on overflow. This can easily result |
||||||
|
* in bugs, because programmers usually assume that an overflow raises an |
||||||
|
* error, which is the standard behavior in high level programming languages. |
||||||
|
* `SafeMath` restores this intuition by reverting the transaction when an |
||||||
|
* operation overflows. |
||||||
|
* |
||||||
|
* Using this library instead of the unchecked operations eliminates an entire |
||||||
|
* class of bugs, so it's recommended to use it always. |
||||||
|
*/ |
||||||
|
library SafeMath { |
||||||
|
/** |
||||||
|
* @dev Returns the addition of two unsigned integers, reverting on |
||||||
|
* overflow. |
||||||
|
* |
||||||
|
* Counterpart to Solidity's `+` operator. |
||||||
|
* |
||||||
|
* Requirements: |
||||||
|
* - Addition cannot overflow. |
||||||
|
*/ |
||||||
|
function add(uint256 a, uint256 b) internal pure returns (uint256) { |
||||||
|
uint256 c = a + b; |
||||||
|
require(c >= a, "SafeMath: addition overflow"); |
||||||
|
|
||||||
|
return c; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Returns the subtraction of two unsigned integers, reverting on |
||||||
|
* overflow (when the result is negative). |
||||||
|
* |
||||||
|
* Counterpart to Solidity's `-` operator. |
||||||
|
* |
||||||
|
* Requirements: |
||||||
|
* - Subtraction cannot overflow. |
||||||
|
*/ |
||||||
|
function sub(uint256 a, uint256 b) internal pure returns (uint256) { |
||||||
|
return sub(a, b, "SafeMath: subtraction overflow"); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on |
||||||
|
* overflow (when the result is negative). |
||||||
|
* |
||||||
|
* Counterpart to Solidity's `-` operator. |
||||||
|
* |
||||||
|
* Requirements: |
||||||
|
* - Subtraction cannot overflow. |
||||||
|
* |
||||||
|
* _Available since v2.4.0._ |
||||||
|
*/ |
||||||
|
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { |
||||||
|
require(b <= a, errorMessage); |
||||||
|
uint256 c = a - b; |
||||||
|
|
||||||
|
return c; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Returns the multiplication of two unsigned integers, reverting on |
||||||
|
* overflow. |
||||||
|
* |
||||||
|
* Counterpart to Solidity's `*` operator. |
||||||
|
* |
||||||
|
* Requirements: |
||||||
|
* - Multiplication cannot overflow. |
||||||
|
*/ |
||||||
|
function mul(uint256 a, uint256 b) internal pure returns (uint256) { |
||||||
|
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the |
||||||
|
// benefit is lost if 'b' is also tested. |
||||||
|
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 |
||||||
|
if (a == 0) { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
uint256 c = a * b; |
||||||
|
require(c / a == b, "SafeMath: multiplication overflow"); |
||||||
|
|
||||||
|
return c; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Returns the integer division of two unsigned integers. Reverts on |
||||||
|
* division by zero. The result is rounded towards zero. |
||||||
|
* |
||||||
|
* Counterpart to Solidity's `/` operator. Note: this function uses a |
||||||
|
* `revert` opcode (which leaves remaining gas untouched) while Solidity |
||||||
|
* uses an invalid opcode to revert (consuming all remaining gas). |
||||||
|
* |
||||||
|
* Requirements: |
||||||
|
* - The divisor cannot be zero. |
||||||
|
*/ |
||||||
|
function div(uint256 a, uint256 b) internal pure returns (uint256) { |
||||||
|
return div(a, b, "SafeMath: division by zero"); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on |
||||||
|
* division by zero. The result is rounded towards zero. |
||||||
|
* |
||||||
|
* Counterpart to Solidity's `/` operator. Note: this function uses a |
||||||
|
* `revert` opcode (which leaves remaining gas untouched) while Solidity |
||||||
|
* uses an invalid opcode to revert (consuming all remaining gas). |
||||||
|
* |
||||||
|
* Requirements: |
||||||
|
* - The divisor cannot be zero. |
||||||
|
* |
||||||
|
* _Available since v2.4.0._ |
||||||
|
*/ |
||||||
|
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { |
||||||
|
// Solidity only automatically asserts when dividing by 0 |
||||||
|
require(b > 0, errorMessage); |
||||||
|
uint256 c = a / b; |
||||||
|
// assert(a == b * c + a % b); // There is no case in which this doesn't hold |
||||||
|
|
||||||
|
return c; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), |
||||||
|
* Reverts when dividing by zero. |
||||||
|
* |
||||||
|
* Counterpart to Solidity's `%` operator. This function uses a `revert` |
||||||
|
* opcode (which leaves remaining gas untouched) while Solidity uses an |
||||||
|
* invalid opcode to revert (consuming all remaining gas). |
||||||
|
* |
||||||
|
* Requirements: |
||||||
|
* - The divisor cannot be zero. |
||||||
|
*/ |
||||||
|
function mod(uint256 a, uint256 b) internal pure returns (uint256) { |
||||||
|
return mod(a, b, "SafeMath: modulo by zero"); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), |
||||||
|
* Reverts with custom message when dividing by zero. |
||||||
|
* |
||||||
|
* Counterpart to Solidity's `%` operator. This function uses a `revert` |
||||||
|
* opcode (which leaves remaining gas untouched) while Solidity uses an |
||||||
|
* invalid opcode to revert (consuming all remaining gas). |
||||||
|
* |
||||||
|
* Requirements: |
||||||
|
* - The divisor cannot be zero. |
||||||
|
* |
||||||
|
* _Available since v2.4.0._ |
||||||
|
*/ |
||||||
|
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { |
||||||
|
require(b != 0, errorMessage); |
||||||
|
return a % b; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1 @@ |
|||||||
|
import "https://github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; contract test11 {} |
File diff suppressed because it is too large
Load Diff
@ -1,96 +1,249 @@ |
|||||||
'use strict' |
'use strict' |
||||||
|
|
||||||
var ballot = `pragma solidity >=0.4.22 <0.6.0;
|
const storage = `pragma solidity >=0.4.22 <0.7.0;
|
||||||
contract Ballot { |
|
||||||
|
/** |
||||||
|
* @title Storage |
||||||
|
* @dev Store & retreive value in a variable |
||||||
|
*/ |
||||||
|
contract Storage { |
||||||
|
|
||||||
|
uint256 number; |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Store value in variable |
||||||
|
* @param num value to store |
||||||
|
*/ |
||||||
|
function store(uint256 num) public { |
||||||
|
number = num; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Return value
|
||||||
|
* @return value of 'number' |
||||||
|
*/ |
||||||
|
function retreive() public view returns (uint256){ |
||||||
|
return number; |
||||||
|
} |
||||||
|
}` |
||||||
|
|
||||||
|
const owner = `pragma solidity >=0.4.22 <0.7.0;
|
||||||
|
|
||||||
|
/** |
||||||
|
* @title Owner |
||||||
|
* @dev Set & change owner |
||||||
|
*/ |
||||||
|
contract Owner { |
||||||
|
|
||||||
|
address private owner; |
||||||
|
|
||||||
|
// event for EVM logging
|
||||||
|
event OwnerSet(address indexed oldOwner, address indexed newOwner); |
||||||
|
|
||||||
|
// modifier to check if caller is owner
|
||||||
|
modifier isOwner() { |
||||||
|
// If the first argument of 'require' evaluates to 'false', execution terminates and all
|
||||||
|
// changes to the state and to Ether balances are reverted.
|
||||||
|
// This used to consume all gas in old EVM versions, but not anymore.
|
||||||
|
// It is often a good idea to use 'require' to check if functions are called correctly.
|
||||||
|
// As a second argument, you can also provide an explanation about what went wrong.
|
||||||
|
require(msg.sender == owner, "Caller is not owner"); |
||||||
|
_; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Set contract deployer as owner |
||||||
|
*/ |
||||||
|
constructor() public { |
||||||
|
owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
|
||||||
|
emit OwnerSet(address(0), owner); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Change owner |
||||||
|
* @param newOwner address of new owner |
||||||
|
*/ |
||||||
|
function changeOwner(address newOwner) public isOwner { |
||||||
|
emit OwnerSet(owner, newOwner); |
||||||
|
owner = newOwner; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Return owner address
|
||||||
|
* @return address of owner |
||||||
|
*/ |
||||||
|
function getOwner() external view returns (address) { |
||||||
|
return owner; |
||||||
|
} |
||||||
|
}` |
||||||
|
|
||||||
|
const ballot = `pragma solidity >=0.4.22 <0.7.0;
|
||||||
|
|
||||||
|
/** |
||||||
|
* @title Ballot |
||||||
|
* @dev Implements voting process along with vote delegation |
||||||
|
*/ |
||||||
|
contract Ballot { |
||||||
|
|
||||||
struct Voter { |
struct Voter { |
||||||
uint weight; |
uint weight; // weight is accumulated by delegation
|
||||||
bool voted; |
bool voted; // if true, that person already voted
|
||||||
uint8 vote; |
address delegate; // person delegated to
|
||||||
address delegate; |
uint vote; // index of the voted proposal
|
||||||
} |
} |
||||||
|
|
||||||
struct Proposal { |
struct Proposal { |
||||||
uint voteCount; |
// If you can limit the length to a certain number of bytes,
|
||||||
|
// always use one of bytes1 to bytes32 because they are much cheaper
|
||||||
|
bytes32 name; // short name (up to 32 bytes)
|
||||||
|
uint voteCount; // number of accumulated votes
|
||||||
} |
} |
||||||
|
|
||||||
address chairperson; |
address public chairperson; |
||||||
mapping(address => Voter) voters; |
|
||||||
Proposal[] proposals; |
|
||||||
|
|
||||||
/// Create a new ballot with $(_numProposals) different proposals.
|
mapping(address => Voter) public voters; |
||||||
constructor(uint8 _numProposals) public { |
|
||||||
|
Proposal[] public proposals; |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Create a new ballot to choose one of 'proposalNames'. |
||||||
|
* @param proposalNames names of proposals |
||||||
|
*/ |
||||||
|
constructor(bytes32[] memory proposalNames) public { |
||||||
chairperson = msg.sender; |
chairperson = msg.sender; |
||||||
voters[chairperson].weight = 1; |
voters[chairperson].weight = 1; |
||||||
proposals.length = _numProposals; |
|
||||||
} |
|
||||||
|
|
||||||
/// Give $(toVoter) the right to vote on this ballot.
|
for (uint i = 0; i < proposalNames.length; i++) { |
||||||
/// May only be called by $(chairperson).
|
// 'Proposal({...})' creates a temporary
|
||||||
function giveRightToVote(address toVoter) public { |
// Proposal object and 'proposals.push(...)'
|
||||||
if (msg.sender != chairperson || voters[toVoter].voted) return; |
// appends it to the end of 'proposals'.
|
||||||
voters[toVoter].weight = 1; |
proposals.push(Proposal({ |
||||||
|
name: proposalNames[i], |
||||||
|
voteCount: 0 |
||||||
|
})); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Give 'voter' the right to vote on this ballot. May only be called by 'chairperson'. |
||||||
|
* @param voter address of voter |
||||||
|
*/ |
||||||
|
function giveRightToVote(address voter) public { |
||||||
|
require( |
||||||
|
msg.sender == chairperson, |
||||||
|
"Only chairperson can give right to vote." |
||||||
|
); |
||||||
|
require( |
||||||
|
!voters[voter].voted, |
||||||
|
"The voter already voted." |
||||||
|
); |
||||||
|
require(voters[voter].weight == 0); |
||||||
|
voters[voter].weight = 1; |
||||||
} |
} |
||||||
|
|
||||||
/// Delegate your vote to the voter $(to).
|
/** |
||||||
|
* @dev Delegate your vote to the voter 'to'. |
||||||
|
* @param to address to which vote is delegated |
||||||
|
*/ |
||||||
function delegate(address to) public { |
function delegate(address to) public { |
||||||
Voter storage sender = voters[msg.sender]; // assigns reference
|
Voter storage sender = voters[msg.sender]; |
||||||
if (sender.voted) return; |
require(!sender.voted, "You already voted."); |
||||||
while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender) |
require(to != msg.sender, "Self-delegation is disallowed."); |
||||||
|
|
||||||
|
while (voters[to].delegate != address(0)) { |
||||||
to = voters[to].delegate; |
to = voters[to].delegate; |
||||||
if (to == msg.sender) return; |
|
||||||
|
// We found a loop in the delegation, not allowed.
|
||||||
|
require(to != msg.sender, "Found loop in delegation."); |
||||||
|
} |
||||||
sender.voted = true; |
sender.voted = true; |
||||||
sender.delegate = to; |
sender.delegate = to; |
||||||
Voter storage delegateTo = voters[to]; |
Voter storage delegate_ = voters[to]; |
||||||
if (delegateTo.voted) |
if (delegate_.voted) { |
||||||
proposals[delegateTo.vote].voteCount += sender.weight; |
// If the delegate already voted,
|
||||||
else |
// directly add to the number of votes
|
||||||
delegateTo.weight += sender.weight; |
proposals[delegate_.vote].voteCount += sender.weight; |
||||||
|
} else { |
||||||
|
// If the delegate did not vote yet,
|
||||||
|
// add to her weight.
|
||||||
|
delegate_.weight += sender.weight; |
||||||
|
} |
||||||
} |
} |
||||||
|
|
||||||
/// Give a single vote to proposal $(toProposal).
|
/** |
||||||
function vote(uint8 toProposal) public { |
* @dev Give your vote (including votes delegated to you) to proposal 'proposals[proposal].name'. |
||||||
|
* @param proposal index of proposal in the proposals array |
||||||
|
*/ |
||||||
|
function vote(uint proposal) public { |
||||||
Voter storage sender = voters[msg.sender]; |
Voter storage sender = voters[msg.sender]; |
||||||
if (sender.voted || toProposal >= proposals.length) return; |
require(sender.weight != 0, "Has no right to vote"); |
||||||
|
require(!sender.voted, "Already voted."); |
||||||
sender.voted = true; |
sender.voted = true; |
||||||
sender.vote = toProposal; |
sender.vote = proposal; |
||||||
proposals[toProposal].voteCount += sender.weight; |
|
||||||
|
// If 'proposal' is out of the range of the array,
|
||||||
|
// this will throw automatically and revert all
|
||||||
|
// changes.
|
||||||
|
proposals[proposal].voteCount += sender.weight; |
||||||
} |
} |
||||||
|
|
||||||
function winningProposal() public view returns (uint8 _winningProposal) { |
/** |
||||||
uint256 winningVoteCount = 0; |
* @dev Computes the winning proposal taking all previous votes into account. |
||||||
for (uint8 prop = 0; prop < proposals.length; prop++) |
* @return winningProposal_ index of winning proposal in the proposals array |
||||||
if (proposals[prop].voteCount > winningVoteCount) { |
*/ |
||||||
winningVoteCount = proposals[prop].voteCount; |
function winningProposal() public view |
||||||
_winningProposal = prop; |
returns (uint winningProposal_) |
||||||
|
{ |
||||||
|
uint winningVoteCount = 0; |
||||||
|
for (uint p = 0; p < proposals.length; p++) { |
||||||
|
if (proposals[p].voteCount > winningVoteCount) { |
||||||
|
winningVoteCount = proposals[p].voteCount; |
||||||
|
winningProposal_ = p; |
||||||
} |
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @dev Calls winningProposal() function to get the index of the winner contained in the proposals array and then |
||||||
|
* @return winnerName_ the name of the winner |
||||||
|
*/ |
||||||
|
function winnerName() public view |
||||||
|
returns (bytes32 winnerName_) |
||||||
|
{ |
||||||
|
winnerName_ = proposals[winningProposal()].name; |
||||||
} |
} |
||||||
} |
} |
||||||
` |
` |
||||||
|
|
||||||
var ballotTest = ` |
var ballotTest = `pragma solidity >=0.4.22 <0.7.0;
|
||||||
pragma solidity >=0.4.22 <0.6.0; |
|
||||||
import "remix_tests.sol"; // this import is automatically injected by Remix.
|
import "remix_tests.sol"; // this import is automatically injected by Remix.
|
||||||
import "./ballot.sol"; |
import "./3_Ballot.sol"; |
||||||
|
|
||||||
contract test3 { |
contract BallotTest { |
||||||
|
|
||||||
|
bytes32[] proposalNames; |
||||||
|
|
||||||
Ballot ballotToTest; |
Ballot ballotToTest; |
||||||
function beforeAll () public { |
function beforeAll () public { |
||||||
ballotToTest = new Ballot(2); |
proposalNames.push(bytes32("candidate1")); |
||||||
|
ballotToTest = new Ballot(proposalNames); |
||||||
} |
} |
||||||
|
|
||||||
function checkWinningProposal () public { |
function checkWinningProposal () public { |
||||||
ballotToTest.vote(1); |
ballotToTest.vote(0); |
||||||
Assert.equal(ballotToTest.winningProposal(), uint(1), "1 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"); |
||||||
} |
} |
||||||
|
|
||||||
function checkWinninProposalWithReturnValue () public view returns (bool) { |
function checkWinninProposalWithReturnValue () public view returns (bool) { |
||||||
return ballotToTest.winningProposal() == 1; |
return ballotToTest.winningProposal() == 0; |
||||||
} |
} |
||||||
} |
} |
||||||
` |
` |
||||||
|
|
||||||
module.exports = { |
module.exports = { |
||||||
ballot: { name: 'ballot.sol', content: ballot }, |
storage: { name: '1_Storage.sol', content: storage }, |
||||||
ballot_test: { name: 'ballot_test.sol', content: ballotTest } |
owner: { name: '2_Owner.sol', content: owner }, |
||||||
|
ballot: { name: '3_Ballot.sol', content: ballot }, |
||||||
|
ballot_test: { name: '4_Ballot_test.sol', content: ballotTest } |
||||||
} |
} |
||||||
|
@ -0,0 +1,109 @@ |
|||||||
|
const yo = require('yo-yo') |
||||||
|
const remixLib = require('remix-lib') |
||||||
|
const confirmDialog = require('./confirmDialog') |
||||||
|
const modalCustom = require('./modal-dialog-custom') |
||||||
|
const modalDialog = require('./modaldialog') |
||||||
|
const typeConversion = remixLib.execution.typeConversion |
||||||
|
const Web3 = require('web3') |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
getCallBacksWithContext: (udappUI, executionContext) => { |
||||||
|
let callbacks = {} |
||||||
|
callbacks.confirmationCb = confirmationCb |
||||||
|
callbacks.continueCb = continueCb |
||||||
|
callbacks.promptCb = promptCb |
||||||
|
callbacks.udappUI = udappUI |
||||||
|
callbacks.executionContext = executionContext |
||||||
|
return callbacks |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
const continueCb = function (error, continueTxExecution, cancelCb) { |
||||||
|
if (error) { |
||||||
|
const msg = typeof error !== 'string' ? error.message : error |
||||||
|
modalDialog( |
||||||
|
'Gas estimation failed', |
||||||
|
yo` |
||||||
|
<div>Gas estimation errored with the following message (see below). |
||||||
|
The transaction execution will likely fail. Do you want to force sending? <br>${msg}</div> |
||||||
|
`,
|
||||||
|
{ |
||||||
|
label: 'Send Transaction', |
||||||
|
fn: () => continueTxExecution() |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Cancel Transaction', |
||||||
|
fn: () => cancelCb() |
||||||
|
} |
||||||
|
) |
||||||
|
} else { |
||||||
|
continueTxExecution() |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
const promptCb = function (okCb, cancelCb) { |
||||||
|
modalCustom.promptPassphrase('Passphrase requested', 'Personal mode is enabled. Please provide passphrase of account', '', okCb, cancelCb) |
||||||
|
} |
||||||
|
|
||||||
|
const confirmationCb = function (network, tx, gasEstimation, continueTxExecution, cancelCb) { |
||||||
|
let self = this |
||||||
|
if (network.name !== 'Main') { |
||||||
|
return continueTxExecution(null) |
||||||
|
} |
||||||
|
var amount = Web3.utils.fromWei(typeConversion.toInt(tx.value), 'ether') |
||||||
|
var content = confirmDialog(tx, amount, gasEstimation, self.udappUI, |
||||||
|
(gasPrice, cb) => { |
||||||
|
let txFeeText, priceStatus |
||||||
|
// TODO: this try catch feels like an anti pattern, can/should be
|
||||||
|
// removed, but for now keeping the original logic
|
||||||
|
try { |
||||||
|
var fee = Web3.utils.toBN(tx.gas).mul(Web3.utils.toBN(Web3.utils.toWei(gasPrice.toString(10), 'gwei'))) |
||||||
|
txFeeText = ' ' + Web3.utils.fromWei(fee.toString(10), 'ether') + ' Ether' |
||||||
|
priceStatus = true |
||||||
|
} catch (e) { |
||||||
|
txFeeText = ' Please fix this issue before sending any transaction. ' + e.message |
||||||
|
priceStatus = false |
||||||
|
} |
||||||
|
cb(txFeeText, priceStatus) |
||||||
|
}, |
||||||
|
(cb) => { |
||||||
|
self.executionContext.web3().eth.getGasPrice((error, gasPrice) => { |
||||||
|
const warnMessage = ' Please fix this issue before sending any transaction. ' |
||||||
|
if (error) { |
||||||
|
return cb('Unable to retrieve the current network gas price.' + warnMessage + error) |
||||||
|
} |
||||||
|
try { |
||||||
|
var gasPriceValue = Web3.utils.fromWei(gasPrice.toString(10), 'gwei') |
||||||
|
cb(null, gasPriceValue) |
||||||
|
} catch (e) { |
||||||
|
cb(warnMessage + e.message, null, false) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
) |
||||||
|
modalDialog( |
||||||
|
'Confirm transaction', |
||||||
|
content, |
||||||
|
{ label: 'Confirm', |
||||||
|
fn: () => { |
||||||
|
self.udappUI.udapp.config.setUnpersistedProperty( |
||||||
|
'doNotShowTransactionConfirmationAgain', |
||||||
|
content.querySelector('input#confirmsetting').checked |
||||||
|
) |
||||||
|
// TODO: check if this is check is still valid given the refactor
|
||||||
|
if (!content.gasPriceStatus) { |
||||||
|
cancelCb('Given gas price is not correct') |
||||||
|
} else { |
||||||
|
var gasPrice = Web3.utils.toWei(content.querySelector('#gasprice').value, 'gwei') |
||||||
|
continueTxExecution(gasPrice) |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: 'Cancel', |
||||||
|
fn: () => { |
||||||
|
return cancelCb('Transaction canceled by user.') |
||||||
|
} |
||||||
|
} |
||||||
|
) |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
const EventEmitter = require('events') |
||||||
|
|
||||||
|
class GetModalBody extends EventEmitter { |
||||||
|
command (callback) { |
||||||
|
this.api.waitForElementVisible('.modal-body') |
||||||
|
.getText('.modal-body', (result) => { |
||||||
|
console.log(result) |
||||||
|
callback(result.value, () => { |
||||||
|
this.emit('complete') |
||||||
|
}) |
||||||
|
}) |
||||||
|
return this |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = GetModalBody |
@ -0,0 +1,19 @@ |
|||||||
|
const EventEmitter = require('events') |
||||||
|
|
||||||
|
/* |
||||||
|
Check if the last log in the console contains a specific text |
||||||
|
*/ |
||||||
|
class JournalLastChildIncludes extends EventEmitter { |
||||||
|
command (val) { |
||||||
|
this.api |
||||||
|
.waitForElementVisible('#journal > div:last-child', 10000) |
||||||
|
.getText('#journal > div:last-child', (result) => { |
||||||
|
console.log('JournalLastChildIncludes', result.value) |
||||||
|
if (result.value.indexOf(val) === -1) return this.api.assert.fail(`wait for ${val} in ${result.value}`) |
||||||
|
this.emit('complete') |
||||||
|
}) |
||||||
|
return this |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = JournalLastChildIncludes |
@ -0,0 +1,17 @@ |
|||||||
|
const EventEmitter = require('events') |
||||||
|
|
||||||
|
class ModalFooterOKClick extends EventEmitter { |
||||||
|
command () { |
||||||
|
this.api.waitForElementVisible('#modal-footer-cancel').perform((client, done) => { |
||||||
|
this.api.execute(function () { |
||||||
|
document.querySelector('#modal-footer-cancel').click() |
||||||
|
}, [], (result) => { |
||||||
|
done() |
||||||
|
this.emit('complete') |
||||||
|
}) |
||||||
|
}) |
||||||
|
return this |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = ModalFooterOKClick |
@ -0,0 +1,19 @@ |
|||||||
|
const EventEmitter = require('events') |
||||||
|
class sendLowLevelTx extends EventEmitter { |
||||||
|
command (address, value, callData) { |
||||||
|
console.log('low level transact to ', address, value, callData) |
||||||
|
this.api.waitForElementVisible(`#instance${address} #deployAndRunLLTxSendTransaction`, 1000) |
||||||
|
.clearValue(`#instance${address} #deployAndRunLLTxCalldata`) |
||||||
|
.setValue(`#instance${address} #deployAndRunLLTxCalldata`, callData) |
||||||
|
.waitForElementVisible('#value') |
||||||
|
.clearValue('#value') |
||||||
|
.setValue('#value', value) |
||||||
|
.scrollAndClick(`#instance${address} #deployAndRunLLTxSendTransaction`) |
||||||
|
.perform(() => { |
||||||
|
this.emit('complete') |
||||||
|
}) |
||||||
|
return this |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = sendLowLevelTx |
@ -0,0 +1,15 @@ |
|||||||
|
const EventEmitter = require('events') |
||||||
|
|
||||||
|
class SetSolidityCompilerVersion extends EventEmitter { |
||||||
|
command (version) { |
||||||
|
this.api |
||||||
|
.click(`#compileTabView #versionSelector [value="${version}"]`) |
||||||
|
.pause(5000) |
||||||
|
.perform(() => { |
||||||
|
this.emit('complete') |
||||||
|
}) |
||||||
|
return this |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = SetSolidityCompilerVersion |
@ -0,0 +1,43 @@ |
|||||||
|
'use strict' |
||||||
|
const init = require('../helpers/init') |
||||||
|
const sauce = require('./sauce') |
||||||
|
// 99266d6da54cc12f37f11586e8171546c7700d67
|
||||||
|
|
||||||
|
module.exports = { |
||||||
|
before: function (browser, done) { |
||||||
|
init(browser, done) |
||||||
|
}, |
||||||
|
'UploadToGists': function (browser) { |
||||||
|
/* |
||||||
|
- set the access token |
||||||
|
- publish to gist |
||||||
|
- retrieve the gist |
||||||
|
- switch to a file in the new gist |
||||||
|
*/ |
||||||
|
console.log('token', process.env.gist_token) |
||||||
|
browser |
||||||
|
.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.clickLaunchIcon('fileExplorers') |
||||||
|
.click('#publishToGist') |
||||||
|
.modalFooterOKClick() |
||||||
|
.getModalBody((value, done) => { |
||||||
|
const reg = /gist.github.com\/([^.]+)/ |
||||||
|
const id = value.match(reg) |
||||||
|
console.log('gist regex', id) |
||||||
|
if (!id) { |
||||||
|
browser.assert.fail('cannot get the gist id', '', '') |
||||||
|
} else { |
||||||
|
let gistid = id[1] |
||||||
|
browser |
||||||
|
.modalFooterCancelClick() |
||||||
|
.executeScript(`remix.loadgist('${gistid}')`) |
||||||
|
.switchFile('browser/gists') |
||||||
|
.switchFile(`browser/gists/${gistid}`) |
||||||
|
.switchFile(`browser/gists/${gistid}/1_Storage.sol`) |
||||||
|
.perform(done) |
||||||
|
} |
||||||
|
}) |
||||||
|
.end() |
||||||
|
}, |
||||||
|
tearDown: sauce |
||||||
|
} |
@ -0,0 +1,56 @@ |
|||||||
|
'use strict' |
||||||
|
const init = require('../helpers/init') |
||||||
|
const sauce = require('./sauce') |
||||||
|
|
||||||
|
const testData = { |
||||||
|
validGistId: '1859c97c6e1efc91047d725d5225888e', |
||||||
|
invalidGistId: '6368b389f9302v32902msk2402' |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
before: function (browser, done) { |
||||||
|
init(browser, done) |
||||||
|
}, |
||||||
|
'Load Gist Modal': function (browser) { |
||||||
|
browser |
||||||
|
.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.clickLaunchIcon('fileExplorers') |
||||||
|
.scrollAndClick('div.file > div.btn-group > button:nth-child(1)') |
||||||
|
.waitForElementVisible('h6.modal-title') |
||||||
|
.assert.containsText('h6.modal-title', 'Load a Gist') |
||||||
|
.waitForElementVisible('div.modal-body > div') |
||||||
|
.assert.containsText('div.modal-body > div', 'Enter the ID of the Gist or URL you would like to load.') |
||||||
|
.waitForElementVisible('#prompt_text') |
||||||
|
.click('#modal-footer-cancel') |
||||||
|
}, |
||||||
|
|
||||||
|
'Display Error Message For Invalid Gist ID': function (browser) { |
||||||
|
browser |
||||||
|
.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.clickLaunchIcon('fileExplorers') |
||||||
|
.scrollAndClick('div.file > div.btn-group > button:nth-child(1)') |
||||||
|
.waitForElementVisible('#prompt_text') |
||||||
|
.setValue('#prompt_text', testData.invalidGistId) |
||||||
|
.modalFooterOKClick() |
||||||
|
.waitForElementVisible('div.modal-body > div') |
||||||
|
.assert.containsText('div.modal-body > div', 'Gist load error: Not Found') |
||||||
|
.modalFooterOKClick() |
||||||
|
}, |
||||||
|
|
||||||
|
'Import From Gist For Valid Gist ID': function (browser) { |
||||||
|
browser |
||||||
|
.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.clickLaunchIcon('fileExplorers') |
||||||
|
.scrollAndClick('div.file > div.btn-group > button:nth-child(1)') |
||||||
|
.waitForElementVisible('#prompt_text') |
||||||
|
.setValue('#prompt_text', testData.validGistId) |
||||||
|
.modalFooterOKClick() |
||||||
|
.switchFile(`browser/gists/${testData.validGistId}`) |
||||||
|
.switchFile(`browser/gists/${testData.validGistId}/ApplicationRegistry`) |
||||||
|
.waitForElementVisible(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry']`) |
||||||
|
.assert.containsText(`div[title='browser/gists/${testData.validGistId}/ApplicationRegistry'] > span`, 'ApplicationRegistry') |
||||||
|
.end() |
||||||
|
}, |
||||||
|
|
||||||
|
tearDown: sauce |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
'use strict' |
||||||
|
var init = require('../helpers/init') |
||||||
|
var sauce = require('./sauce') |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
before: function (browser, done) { |
||||||
|
init(browser, done) |
||||||
|
}, |
||||||
|
'@sources': function () { |
||||||
|
return [] |
||||||
|
}, |
||||||
|
'Publish on IPFS': function (browser) { |
||||||
|
browser |
||||||
|
.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.clickLaunchIcon('fileExplorers') |
||||||
|
.switchFile('browser/3_Ballot.sol') |
||||||
|
.verifyContracts(['Ballot']) |
||||||
|
.click('#publishOnIpfs') |
||||||
|
.getModalBody((value, done) => { |
||||||
|
if (value.indexOf('Metadata published successfully.') === -1) browser.assert.fail('ipfs deploy failed', '', '') |
||||||
|
if (value.indexOf('dweb:/ipfs') === -1) browser.assert.fail('ipfs deploy failed', '', '') |
||||||
|
done() |
||||||
|
}) |
||||||
|
.modalFooterOKClick() |
||||||
|
}, |
||||||
|
'Publish on Swarm': function (browser) { |
||||||
|
browser |
||||||
|
.click('#publishOnSwarm') |
||||||
|
.getModalBody((value, done) => { |
||||||
|
if (value.indexOf('Metadata published successfully.') === -1) browser.assert.fail('swarm deploy failed', '', '') |
||||||
|
if (value.indexOf('bzz') === -1) browser.assert.fail('swarm deploy failed', '', '') |
||||||
|
done() |
||||||
|
}) |
||||||
|
.end() |
||||||
|
}, |
||||||
|
tearDown: sauce |
||||||
|
} |
@ -0,0 +1,273 @@ |
|||||||
|
'use strict' |
||||||
|
var init = require('../helpers/init') |
||||||
|
var sauce = require('./sauce') |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
before: function (browser, done) { |
||||||
|
init(browser, done) |
||||||
|
}, |
||||||
|
'@sources': function () { |
||||||
|
return sources |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - both are declared, sending data': function (browser) { |
||||||
|
browser.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.testContracts('receiveAndFallback.sol', sources[0]['browser/receiveAndFallback.sol'], ['CheckSpecials']) // compile
|
||||||
|
.clickLaunchIcon('udapp') |
||||||
|
.selectContract('CheckSpecials') |
||||||
|
.createContract('') // deploy
|
||||||
|
.clickInstance(0) |
||||||
|
.perform((done) => { |
||||||
|
browser.getAddressAtPosition(0, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '0', '0xaa') |
||||||
|
.pause(1000) |
||||||
|
.journalLastChildIncludes('to:CheckSpecials.(fallback)') |
||||||
|
.journalLastChildIncludes('value:0 wei') |
||||||
|
.journalLastChildIncludes('data:0xaa') |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - both are declared, failing sending data < 1 byte': function (browser) { |
||||||
|
// don't need to redeploy it, same contract
|
||||||
|
browser.perform((done) => { |
||||||
|
browser.getAddressAtPosition(0, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '0', '0xa') |
||||||
|
.pause(1000) |
||||||
|
.waitForElementVisible(`#instance${address} label[id="deployAndRunLLTxError"]`) |
||||||
|
.assert.containsText(`#instance${address} label[id="deployAndRunLLTxError"]`, `The calldata should be a valid hexadecimal value with size of at least one byte.`) |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - both are declared, failing sending data with odd number of digits': function (browser) { |
||||||
|
// don't need to redeploy it, same contract
|
||||||
|
browser.perform((done) => { |
||||||
|
browser.getAddressAtPosition(0, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '0', '0x1aa') |
||||||
|
.pause(1000) |
||||||
|
.waitForElementVisible(`#instance${address} label[id="deployAndRunLLTxError"]`) |
||||||
|
.assert.containsText(`#instance${address} label[id="deployAndRunLLTxError"]`, `The calldata should be a valid hexadecimal value.`) |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - both are declared - receive called, sending wei': function (browser) { |
||||||
|
// don't need to redeploy it, same contract
|
||||||
|
browser.perform((done) => { |
||||||
|
browser.getAddressAtPosition(0, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '1', '') |
||||||
|
.pause(1000) |
||||||
|
.journalLastChildIncludes('to:CheckSpecials.(receive)') |
||||||
|
.journalLastChildIncludes('value:1 wei') |
||||||
|
.journalLastChildIncludes('data:0x') |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - both are declared - fallback should fail cause not payable, sending data and wei': function (browser) { |
||||||
|
// don't need to redeploy it, same contract
|
||||||
|
browser.perform((done) => { |
||||||
|
browser.getAddressAtPosition(0, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '10', '0xaa') |
||||||
|
.pause(1000) |
||||||
|
.journalLastChildIncludes('to CheckSpecials.(fallback) errored:') |
||||||
|
.journalLastChildIncludes('The called function should be payable if you send value') |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - only receive is declared, sending wei': function (browser) { |
||||||
|
browser.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.testContracts('receiveOnly.sol', sources[1]['browser/receiveOnly.sol'], ['CheckSpecials']) |
||||||
|
.clickLaunchIcon('udapp') |
||||||
|
.selectContract('CheckSpecials') |
||||||
|
.createContract('') |
||||||
|
.clickInstance(1) |
||||||
|
.perform((done) => { |
||||||
|
browser.getAddressAtPosition(1, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '1', '') |
||||||
|
.pause(1000) |
||||||
|
.journalLastChildIncludes('to:CheckSpecials.(receive)') |
||||||
|
.journalLastChildIncludes('value:1 wei') |
||||||
|
.journalLastChildIncludes('data:0x') |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - only receive is declared, failing, fallback is not declared, sending data': function (browser) { |
||||||
|
// don't need to redeploy it, same contract
|
||||||
|
browser.perform((done) => { |
||||||
|
browser.getAddressAtPosition(1, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '0', '0xaa') |
||||||
|
.pause(1000) |
||||||
|
.waitForElementVisible(`#instance${address} label[id="deployAndRunLLTxError"]`) |
||||||
|
.assert.containsText(`#instance${address} label[id="deployAndRunLLTxError"]`, `'Fallback' function is not defined`) |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - only fallback declared and is payable, sending wei': function (browser) { |
||||||
|
browser.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.testContracts('fallbackOnlyPayable.sol', sources[2]['browser/fallbackOnlyPayable.sol'], ['CheckSpecials']) |
||||||
|
.clickLaunchIcon('udapp') |
||||||
|
.selectContract('CheckSpecials') |
||||||
|
.createContract('') |
||||||
|
.clickInstance(2) |
||||||
|
.perform((done) => { |
||||||
|
browser.getAddressAtPosition(2, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '1', '') |
||||||
|
.pause(1000) |
||||||
|
.journalLastChildIncludes('to:CheckSpecials.(fallback)') |
||||||
|
.journalLastChildIncludes('value:1 wei') |
||||||
|
.journalLastChildIncludes('data:0x') |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - only fallback is diclared and is payable, sending data and wei': function (browser) { |
||||||
|
// don't need to redeploy it, same contract
|
||||||
|
browser.perform((done) => { |
||||||
|
browser.getAddressAtPosition(2, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '1', '0xaa') |
||||||
|
.pause(1000) |
||||||
|
.journalLastChildIncludes('to:CheckSpecials.(fallback)') |
||||||
|
.journalLastChildIncludes('value:1 wei') |
||||||
|
.journalLastChildIncludes('data:0xaa') |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - only fallback is declared, fallback should fail cause not payable, sending wei': function (browser) { |
||||||
|
browser.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.testContracts('fallbackOnlyNotPayable.sol', sources[3]['browser/fallbackOnlyNotPayable.sol'], ['CheckSpecials']) |
||||||
|
.clickLaunchIcon('udapp') |
||||||
|
.selectContract('CheckSpecials') |
||||||
|
.createContract('') |
||||||
|
.clickInstance(3) |
||||||
|
.perform((done) => { |
||||||
|
browser.getAddressAtPosition(3, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '1', '') |
||||||
|
.pause(1000) |
||||||
|
.waitForElementVisible(`#instance${address} label[id="deployAndRunLLTxError"]`) |
||||||
|
.assert.containsText(`#instance${address} label[id="deployAndRunLLTxError"]`, `should have either 'receive' or payable 'fallback'`) |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - receive and fallback are declared, sending data and wei': function (browser) { |
||||||
|
browser.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.testContracts('receiveAndFallbackBothPayable.sol', sources[4]['browser/receiveAndFallbackBothPayable.sol'], ['CheckSpecials']) |
||||||
|
.clickLaunchIcon('udapp') |
||||||
|
.selectContract('CheckSpecials') |
||||||
|
.waitForElementVisible('#value') |
||||||
|
.clearValue('#value') |
||||||
|
.setValue('#value', 0) |
||||||
|
.createContract('') |
||||||
|
.clickInstance(4) |
||||||
|
.pause(1000) |
||||||
|
.perform((done) => { |
||||||
|
browser.getAddressAtPosition(4, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '1', '0xaa') |
||||||
|
.pause(1000) |
||||||
|
.journalLastChildIncludes('to:CheckSpecials.(fallback)') |
||||||
|
.journalLastChildIncludes('value:1 wei') |
||||||
|
.journalLastChildIncludes('data:0xaa') |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - receive and fallback are declared and payable, sending wei': function (browser) { |
||||||
|
browser.perform((done) => { |
||||||
|
browser.getAddressAtPosition(4, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '1', '') |
||||||
|
.pause(1000) |
||||||
|
.journalLastChildIncludes('to:CheckSpecials.(receive)') |
||||||
|
.journalLastChildIncludes('value:1 wei') |
||||||
|
.journalLastChildIncludes('data:0x') |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
}, |
||||||
|
'Use special functions receive/fallback - receive and fallback are not declared, sending nothing': function (browser) { |
||||||
|
browser.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.testContracts('notSpecial.sol', sources[5]['browser/notSpecial.sol'], ['CheckSpecials']) |
||||||
|
.clickLaunchIcon('udapp') |
||||||
|
.selectContract('CheckSpecials') |
||||||
|
.waitForElementVisible('#value') |
||||||
|
.clearValue('#value') |
||||||
|
.setValue('#value', 0) |
||||||
|
.createContract('') |
||||||
|
.clickInstance(5) |
||||||
|
.pause(1000) |
||||||
|
.perform((done) => { |
||||||
|
browser.getAddressAtPosition(5, (address) => { |
||||||
|
browser.sendLowLevelTx(address, '0', '') |
||||||
|
.pause(1000) |
||||||
|
.waitForElementVisible(`#instance${address} label[id="deployAndRunLLTxError"]`) |
||||||
|
.assert.containsText(`#instance${address} label[id="deployAndRunLLTxError"]`, `Both 'receive' and 'fallback' functions are not defined`) |
||||||
|
.perform(done) |
||||||
|
}) |
||||||
|
}) |
||||||
|
.end() |
||||||
|
}, |
||||||
|
tearDown: sauce |
||||||
|
} |
||||||
|
|
||||||
|
var sources = [ |
||||||
|
{ |
||||||
|
'browser/receiveAndFallback.sol': { |
||||||
|
content: ` |
||||||
|
contract CheckSpecials { |
||||||
|
receive() payable external{} |
||||||
|
fallback() external {} |
||||||
|
} |
||||||
|
` |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
'browser/receiveOnly.sol': { |
||||||
|
content: ` |
||||||
|
contract CheckSpecials { |
||||||
|
receive() payable external {} |
||||||
|
} |
||||||
|
` |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
'browser/fallbackOnlyPayable.sol': { |
||||||
|
content: ` |
||||||
|
contract CheckSpecials { |
||||||
|
fallback() payable external {} |
||||||
|
} |
||||||
|
` |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
'browser/fallbackOnlyNotPayable.sol': { |
||||||
|
content: ` |
||||||
|
contract CheckSpecials { |
||||||
|
fallback() external {} |
||||||
|
} |
||||||
|
` |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
'browser/receiveAndFallbackBothPayable.sol': { |
||||||
|
content: ` |
||||||
|
contract CheckSpecials { |
||||||
|
receive() payable external {} |
||||||
|
fallback() payable external {} |
||||||
|
} |
||||||
|
` |
||||||
|
} |
||||||
|
}, |
||||||
|
{ |
||||||
|
'browser/notSpecial.sol': { |
||||||
|
content: ` |
||||||
|
contract CheckSpecials { |
||||||
|
function otherFallback() payable external {} |
||||||
|
} |
||||||
|
` |
||||||
|
} |
||||||
|
} |
||||||
|
] |
@ -0,0 +1,17 @@ |
|||||||
|
'use strict' |
||||||
|
const init = require('../helpers/init') |
||||||
|
const sauce = require('./sauce') |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
before: function (browser, done) { |
||||||
|
init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false) |
||||||
|
}, |
||||||
|
'CheckSolidityActivatedAndUDapp': function (browser) { |
||||||
|
browser |
||||||
|
.waitForElementVisible('#icon-panel', 10000) |
||||||
|
.clickLaunchIcon('solidity') |
||||||
|
.clickLaunchIcon('udapp') |
||||||
|
.end() |
||||||
|
}, |
||||||
|
tearDown: sauce |
||||||
|
} |
Loading…
Reference in new issue