2023-06-06 16:27:41 +02:00
|
|
|
# standard imports
|
|
|
|
import os
|
|
|
|
import logging
|
|
|
|
import datetime
|
|
|
|
|
|
|
|
# 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.tx import TxFactory
|
|
|
|
from chainlib.eth.tx import TxFormat
|
|
|
|
from chainlib.eth.contract import ABIContractEncoder
|
|
|
|
from chainlib.eth.contract import ABIContractType
|
2023-06-08 15:00:23 +02:00
|
|
|
from cic_contracts.unittest import bytecode
|
2023-06-09 10:44:03 +02:00
|
|
|
from cic_contracts import Name
|
2023-06-06 16:27:41 +02:00
|
|
|
|
|
|
|
# local imports
|
|
|
|
from eth_burner import EthBurner
|
|
|
|
|
|
|
|
logg = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class TestEthBurner(EthTesterCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(TestEthBurner, self).setUp()
|
|
|
|
|
|
|
|
self.conn = RPCConnection.connect(self.chain_spec, 'default')
|
|
|
|
nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
|
|
|
|
|
2023-06-09 10:44:03 +02:00
|
|
|
code = bytecode(Name.BURNER)
|
2023-06-06 16:27:41 +02:00
|
|
|
|
|
|
|
txf = TxFactory(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
|
|
|
|
tx = txf.template(self.accounts[0], None, use_nonce=True)
|
|
|
|
|
|
|
|
self.initial_supply = 1024
|
|
|
|
enc = ABIContractEncoder()
|
|
|
|
enc = ABIContractEncoder()
|
|
|
|
enc.uint256(self.initial_supply)
|
|
|
|
args = enc.get()
|
|
|
|
|
|
|
|
tx = txf.set_code(tx, code + args)
|
|
|
|
(tx_hash_hex, o) = txf.build(tx)
|
|
|
|
self.conn.do(o)
|
|
|
|
o = receipt(tx_hash_hex)
|
|
|
|
r = self.conn.do(o)
|
|
|
|
self.assertEqual(r['status'], 1)
|
|
|
|
self.address = r['contract_address']
|
|
|
|
logg.debug('published burner test contract with hash {}'.format(r))
|