2015-07-20 21:50:19 +00:00
|
|
|
#!/usr/bin/env python
|
2015-07-20 21:13:12 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from ethereum import tester
|
|
|
|
import os
|
|
|
|
|
|
|
|
from matchmaker import Matchmaker
|
2015-07-25 12:37:02 +00:00
|
|
|
from trader import Trader
|
2015-07-20 21:13:12 +00:00
|
|
|
|
|
|
|
state = tester.state()
|
|
|
|
|
|
|
|
# Create Market Contract
|
|
|
|
# TODO: remove gas
|
|
|
|
market = state.abi_contract('contracts/market.se', gas=10000000)
|
|
|
|
|
2015-07-25 12:37:02 +00:00
|
|
|
# Create Actors
|
|
|
|
match_maker = Matchmaker(state, market, name='MatchMaker')
|
|
|
|
buyer = Trader(state, market, name='Buyer')
|
|
|
|
seller = Trader(state, market, name='Seller')
|
2015-07-20 21:13:12 +00:00
|
|
|
|
2015-07-25 12:37:02 +00:00
|
|
|
# Setup our simple Buy and Sell tickets
|
|
|
|
buyer.new_ticket(5)
|
|
|
|
seller.new_ticket(-5)
|
2015-07-20 21:13:12 +00:00
|
|
|
|
2015-07-25 12:37:02 +00:00
|
|
|
# Run the Network!
|
2015-07-26 13:12:48 +00:00
|
|
|
state.mine(n=5)
|
|
|
|
|
|
|
|
# TODO:
|
|
|
|
# Traders Accept (or Decline )
|
|
|
|
# Matchmaker waits until accept window is over and collects fees?
|
|
|
|
# do they collect fees or do they get the option to add new sealed bids using the freed storage?
|
|
|
|
# depends if buyer or seller commit a fee for listing?
|
|
|
|
|
|
|
|
# What happens exactly on Accept
|
|
|
|
# - where does trade contract come from?
|
|
|
|
# - the market maker generates the trade (and collects their fee)
|