erc20-transfer-authorization

Simple approval escrow for ERC20 spending
Log | Files | Refs

base.py (1261B)


      1 # standard imports
      2 import os
      3 import unittest
      4 import json
      5 import logging
      6 
      7 # external imports
      8 from chainlib.eth.unittest.ethtester import EthTesterCase
      9 from chainlib.eth.nonce import RPCNonceOracle
     10 from chainlib.eth.tx import receipt
     11 from giftable_erc20_token import GiftableToken
     12 
     13 # local imports
     14 from erc20_transfer_authorization import TransferAuthorization
     15 
     16 logg = logging.getLogger()
     17 
     18 testdir = os.path.dirname(__file__)
     19 
     20 
     21 class TestBase(EthTesterCase):
     22 
     23     def setUp(self):
     24         super(TestBase, self).setUp()
     25         nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
     26         c = TransferAuthorization(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
     27         (tx_hash_hex, o) = c.constructor(self.accounts[0])
     28 
     29         self.rpc.do(o)
     30 
     31         o = receipt(tx_hash_hex)
     32         r = self.rpc.do(o)
     33         self.assertEqual(r['status'], 1)
     34 
     35         self.address = r['contract_address']
     36 
     37         c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
     38         (tx_hash_hex, o) = c.constructor(self.accounts[0], 'FooToken', 'FOO', 6)
     39         self.rpc.do(o)
     40 
     41         o = receipt(tx_hash_hex)
     42         r = self.rpc.do(o)
     43         self.assertEqual(r['status'], 1)
     44 
     45         self.token_address = r['contract_address']