2021-10-04 09:14:51 +02:00
|
|
|
# standard imports
|
|
|
|
import unittest
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
# external imports
|
|
|
|
from hexathon import add_0x
|
|
|
|
from chainlib.eth.unittest.ethtester import EthTesterCase
|
|
|
|
from chainlib.eth.nonce import RPCNonceOracle
|
|
|
|
from chainlib.eth.tx import receipt
|
|
|
|
from giftable_erc20_token import GiftableToken
|
|
|
|
|
|
|
|
# local imports
|
|
|
|
from eth_address_declarator.declarator import AddressDeclarator
|
2023-03-24 11:38:00 +01:00
|
|
|
#from eth_address_declarator.kv import AddressDeclaratorKV
|
2021-10-04 09:14:51 +02:00
|
|
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
logg = logging.getLogger()
|
|
|
|
|
|
|
|
|
2021-10-04 12:35:10 +02:00
|
|
|
class TestAddressDeclaratorBase(EthTesterCase):
|
2021-10-04 09:14:51 +02:00
|
|
|
|
|
|
|
def setUp(self):
|
2021-10-04 12:35:10 +02:00
|
|
|
super(TestAddressDeclaratorBase, self).setUp()
|
2021-10-04 09:14:51 +02:00
|
|
|
self.description = add_0x(os.urandom(32).hex())
|
|
|
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.rpc)
|
|
|
|
c = AddressDeclarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
|
|
|
(tx_hash_hex, o) = c.constructor(self.accounts[0], self.description)
|
|
|
|
self.rpc.do(o)
|
|
|
|
|
|
|
|
o = receipt(tx_hash_hex)
|
|
|
|
r = self.rpc.do(o)
|
|
|
|
self.assertEqual(r['status'], 1)
|
|
|
|
|
|
|
|
self.address = r['contract_address']
|
2023-03-24 09:55:59 +01:00
|
|
|
logg.debug('address declarator published with address {}'.format(self.address))
|
2021-10-04 09:14:51 +02:00
|
|
|
|
|
|
|
c = GiftableToken(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
|
|
|
(tx_hash_hex, o) = c.constructor(self.accounts[0], 'FooToken', 'FOO', 6)
|
|
|
|
self.rpc.do(o)
|
|
|
|
|
|
|
|
o = receipt(tx_hash_hex)
|
|
|
|
r = self.rpc.do(o)
|
|
|
|
self.assertEqual(r['status'], 1)
|
|
|
|
|
|
|
|
self.foo_token_address = r['contract_address']
|
2023-03-24 09:55:59 +01:00
|
|
|
logg.debug('foo token published with address {}'.format(self.foo_token_address))
|