Skip to content

Instantly share code, notes, and snippets.

View LefterisJP's full-sized avatar

Lefteris Karapetsas LefterisJP

View GitHub Profile
@LefterisJP
LefterisJP / snapcraft.yaml
Created January 25, 2016 09:18
snapcraft.yaml - example snap binaries and services
services:
node-webserver:
description: A test node webserver
start: bin/node_server
caps:
- networking
- ethereum_ipc
binaries:
@LefterisJP
LefterisJP / ipc.apparmor
Created January 25, 2016 09:20
Ethereum IPC framework capability apparmor profile
# Description: AppArmor security policy for clients using the ethereum framework via IPC
# Usage: reserved
#
# read and write to the unix socket opened by the client
/var/lib/apps/ethereum/*/.ethereum/geth.ipc rw,
@LefterisJP
LefterisJP / fundfail1.js
Created March 24, 2016 15:04
Buy tokens
var amounts = $amounts;
var dao = web3.eth.contract($dao_abi).at('$dao_address');
console.log("Buying DAO tokens");
for (i = 0; i < eth.accounts.length; i++) {
web3.eth.sendTransaction({
from:eth.accounts[i],
to: dao.address,
gas:200000,
value:web3.toWei(amounts[i], "ether")
@LefterisJP
LefterisJP / fundfail2.js
Created March 24, 2016 15:06
Once funding fails, ask for a refund
// since funding failed let's get a refund
var eth_balance_before_refund = [];
for (i = 0; i < eth.accounts.length; i++) {
eth_balance_before_refund.push(web3.fromWei(eth.getBalance(eth.accounts[i])));
}
addToTest('eth_balance_before_refund', eth_balance_before_refund);
for (i = 0; i < eth.accounts.length; i++) {
dao.refund.sendTransaction({
from:eth.accounts[i],
@LefterisJP
LefterisJP / fundfail3.js
Created March 24, 2016 15:08
Checking refund balance
var eth_balance_after_refund = [];
for (i = 0; i < eth.accounts.length; i++) {
eth_balance_after_refund.push(web3.fromWei(eth.getBalance(eth.accounts[i])));
}
addToTest('eth_balance_after_refund', eth_balance_after_refund);
var refund = [];
for (i = 0; i < eth.accounts.length; i++) {
refund.push((bigDiffRound(
testMap['eth_balance_after_refund'][i],
@LefterisJP
LefterisJP / run1.py
Created March 24, 2016 15:11
Run dependent scenarios
def run(ctx):
ctx.assert_scenario_ran('deploy')
@LefterisJP
LefterisJP / run2.py
Last active March 24, 2016 15:15
Calculate arguments and provide to the javascript side
accounts_num = len(ctx.accounts)
sale_secs = ctx.remaining_time()
ctx.total_supply = random.randint(5, ctx.args.deploy_min_value - 4)
ctx.token_amounts = constrained_sum_sample_pos(
accounts_num, ctx.total_supply
)
ctx.create_js_file(substitutions={
"dao_abi": ctx.dao_abi,
"dao_address": ctx.dao_addr,
"wait_ms": (sale_secs-3)*1000,
@LefterisJP
LefterisJP / run3.py
Created March 24, 2016 15:21
Run and evaluate test results
ctx.execute(expected={
"dao_funded": False,
"total_supply": ctx.total_supply,
"refund": ctx.token_amounts
})
@LefterisJP
LefterisJP / .conkyrc
Created June 13, 2016 17:43
Lefteris' conkyrc
out_to_x no
own_window no
out_to_console yes
background no
max_text_width 0
# Update interval in seconds
update_interval 2.0
# This is the number of times Conky will update before quitting.
@LefterisJP
LefterisJP / min_quorum.py
Created July 7, 2016 10:51
min_quorum.py
#!/usr/bin/python2
import argparse
def min_quorum(args):
total_supply = args.supply
div = args.div
actual_balance = args.balance
value = args.val