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
(* Escrow contract *) | |
import ListUtils | |
(***************************************************) | |
(* Associated library *) | |
(***************************************************) | |
library Escrow | |
let one_msg = |
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
pragma solidity ^0.4.19; | |
/// @title Survey - A survey instant created by SurveyFactory to randomize the winning process of the fees | |
/// @author Amr Gawish | |
contract Survey { | |
/* Events */ | |
event SurveyInitialized(address indexed owner, uint indexed surveyReward); | |
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
describe('Create New Survey Test Cases', () => { | |
// ## Example #1 | |
it(`1. Given that I’m the Survey Maker | |
2. When I try to create a new Survey and included the survey creation costs and survey reward | |
3. Then I should be able to get the created survey reference number and address`, () => { | |
return surveyFactory.createSurvey.call({ value: _surveyRewardAndCreationCost, from: _surveyMaker }) | |
.then(([surveyId, surveyAddress]) => { | |
return surveyId; | |
}).should.eventually.be.bignumber.equals(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
/* Loading all libraries from common */ | |
const { | |
SurveyFactory, //Survey Factor Contract | |
Survey, //Survey Contract | |
BigNumber, //BigNumber from web3 (for ease to use) | |
CommonVariables, //Multiple common variables | |
expectRevert, //Check if the Solidity returns "revert" exception (usually result from require failed) | |
} = require('./helpers/common'); | |
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
/* Loading all imports */ | |
const _ = require('lodash'); | |
const expectRevert = require('./expectRevert'); | |
const Survey = artifacts.require("./Survey.sol"); | |
const SurveyFactory = artifacts.require("./SurveyFactory.sol"); | |
const BigNumber = web3.BigNumber; | |
require('chai') | |
.use(require('chai-bignumber')(BigNumber)) | |
.use(require('chai-as-promised')) |
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
// Inspired By: | |
// https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/test/helpers/assertRevert.js | |
const expect = require('chai').expect; | |
module.exports = async (promise) => { | |
try { | |
await promise; | |
assert.fail('Expected revert not received'); | |
} catch (error) { | |
expect(error.message, `Expected "revert", got ${error} instead`).to.contain('revert'); |
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
contract('Survey', _accounts => { | |
/* Initialization code here */ | |
beforeEach(async () => { | |
/* Before Each Test here */ | |
}); | |
describe('[TEST_CASES_LOGICAL_GROUP_HERE]', () => { | |
it(`1. Given that I'm the ____ |
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
module.exports = { | |
networks: { | |
// Test RPC environment | |
development: { | |
host: "localhost", | |
port: 8545, | |
network_id: "*" //Listen to all networks | |
} |
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
# Create DApp Directory | |
mkdir survey-reward-dapp | |
# Open DApp Directory | |
cd survey-reward-dapp | |
# Initialize the application using NPM (Follow through, or if you're happy with default just go with npm init -y | |
npm init | |
# Start by downloading Truffle (You can also install it globally by npm install -g truffle |
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
//Express | |
let express = require('express'); | |
let app = express(); | |
app.use(express.static('public')) | |
app.get('/', function(req, res){ | |
res.sendFile('public/index.html', { root : __dirname}); | |
}); |
NewerOlder