2023-05-30 18:42:53 +02:00
|
|
|
|
# standard imports
|
|
|
|
|
import logging
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
# external imports
|
|
|
|
|
from chainlib.eth.unittest.ethtester import EthTesterCase
|
|
|
|
|
from chainlib.connection import RPCConnection
|
|
|
|
|
from chainlib.eth.nonce import RPCNonceOracle
|
|
|
|
|
from chainlib.eth.tx import receipt
|
|
|
|
|
from chainlib.eth.address import to_checksum_address
|
|
|
|
|
|
|
|
|
|
# local imports
|
|
|
|
|
from ge_capped_token import CappedToken
|
|
|
|
|
|
|
|
|
|
logg = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestCappedToken(EthTesterCase):
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
super(TestCappedToken, self).setUp()
|
2023-06-08 15:35:37 +02:00
|
|
|
|
self.publish()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def publish(self):
|
2023-05-30 18:42:53 +02:00
|
|
|
|
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
|
|
|
|
nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn)
|
|
|
|
|
c = CappedToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
|
|
|
|
self.symbol = 'FOO'
|
|
|
|
|
self.name = 'Foo Token'
|
|
|
|
|
self.decimals = 16
|
2023-05-31 17:28:38 +02:00
|
|
|
|
(tx_hash, o) = c.constructor(self.accounts[0], self.name, self.symbol, self.decimals)
|
2023-05-30 18:42:53 +02:00
|
|
|
|
self.rpc.do(o)
|
|
|
|
|
o = receipt(tx_hash)
|
|
|
|
|
r = self.rpc.do(o)
|
|
|
|
|
self.assertEqual(r['status'], 1)
|
|
|
|
|
self.address = to_checksum_address(r['contract_address'])
|
|
|
|
|
logg.debug('published on address {} with hash {}'.format(self.address, tx_hash))
|
|
|
|
|
|
|
|
|
|
self.initial_supply = 1 << 40
|
|
|
|
|
(tx_hash, o) = c.mint_to(self.address, self.accounts[0], self.accounts[0], self.initial_supply)
|
2023-05-31 17:28:38 +02:00
|
|
|
|
self.conn.do(o)
|
2023-05-30 18:42:53 +02:00
|
|
|
|
o = receipt(tx_hash)
|
|
|
|
|
r = self.conn.do(o)
|
|
|
|
|
self.assertEqual(r['status'], 1)
|