2017-07-28 20:45:46 -07:00
|
|
|
import unittest
|
|
|
|
import xcat.cli as cli
|
2017-09-12 22:28:36 -07:00
|
|
|
from xcat.db import DB
|
2017-09-12 21:52:21 -07:00
|
|
|
from xcat.protocol import Protocol
|
|
|
|
from xcat.tests.utils import mktrade
|
|
|
|
from xcat.trades import Trade # , Contract
|
2017-07-28 20:45:46 -07:00
|
|
|
|
2017-09-04 10:00:59 -07:00
|
|
|
|
2017-09-12 21:52:21 -07:00
|
|
|
class SimpleTestCase(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.trade = mktrade()
|
2017-07-28 20:45:46 -07:00
|
|
|
|
2017-09-12 21:52:21 -07:00
|
|
|
def test_exporttrade(self):
|
|
|
|
self.__class__.hexstr = cli.exporttrade('test')
|
|
|
|
self.assertTrue(int(self.hexstr, 16))
|
2017-07-28 20:45:46 -07:00
|
|
|
|
2017-07-31 17:06:58 -07:00
|
|
|
def test_importtrade(self):
|
2017-09-12 21:52:21 -07:00
|
|
|
# trade = cli.importtrade('test', self.__class__.hexstr)
|
2017-09-04 16:03:17 -07:00
|
|
|
pass
|
|
|
|
|
2017-09-04 09:06:30 -07:00
|
|
|
|
2017-09-12 21:52:21 -07:00
|
|
|
class CliTest(SimpleTestCase):
|
2017-07-31 19:13:46 -07:00
|
|
|
def test_findtrade(self):
|
2017-09-12 21:52:21 -07:00
|
|
|
# trade = cli.findtrade('test')
|
2017-09-04 16:03:17 -07:00
|
|
|
pass
|
2017-07-31 13:32:51 -07:00
|
|
|
|
2017-07-31 19:13:46 -07:00
|
|
|
def test_newtrade(self):
|
2017-09-12 21:52:21 -07:00
|
|
|
trade = cli.newtrade('new', conf='regtest')
|
|
|
|
self.assertTrue(isinstance(trade, Trade))
|
2017-08-06 23:19:21 -07:00
|
|
|
|
|
|
|
def test_fundsell(self):
|
2017-09-12 22:28:36 -07:00
|
|
|
db = DB()
|
2017-09-12 21:52:21 -07:00
|
|
|
protocol = Protocol()
|
|
|
|
|
|
|
|
trade = db.get('new')
|
|
|
|
status = cli.seller_check_status(trade)
|
|
|
|
print("Trade status: {0}\n".format(status))
|
|
|
|
self.assertEqual(status, 'init')
|
|
|
|
|
|
|
|
fund_tx = protocol.fund_sell_contract(trade)
|
|
|
|
print("Sent fund_tx", fund_tx)
|
|
|
|
|
|
|
|
# def test_fundbuy(self):
|
|
|
|
# trade = db.get('new')
|
|
|
|
# status = cli.buyer_check_status(trade)
|
|
|
|
# self.assertEqual(status, 'sellerFunded')
|
|
|
|
# fund_tx = cli.fund_contract(trade.buy)
|
|
|
|
#
|
|
|
|
# def test_seller_redeem(self):
|
|
|
|
# trade = db.get('new')
|
|
|
|
# status = cli.seller_check_status(trade)
|
|
|
|
# self.assertEqual(status, 'buyerFunded')
|
|
|
|
#
|
|
|
|
# def test_buyer_redeem(self):
|
|
|
|
# trade = db.get('new')
|
|
|
|
# status = cli.buyer_check_status(trade)
|
|
|
|
# self.assertEqual(status, 'sellerFunded')
|
2017-09-04 10:00:59 -07:00
|
|
|
|
2017-09-12 22:28:36 -07:00
|
|
|
|
2017-07-28 20:45:46 -07:00
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|