Add higher fee limit in base task
This commit is contained in:
parent
a356585c6a
commit
380550cb84
@ -71,8 +71,9 @@ def balance(tokens, holder_address, chain_spec_dict):
|
|||||||
for t in tokens:
|
for t in tokens:
|
||||||
address = t['address']
|
address = t['address']
|
||||||
logg.debug('address {} {}'.format(address, holder_address))
|
logg.debug('address {} {}'.format(address, holder_address))
|
||||||
|
gas_oracle = self.create_gas_oracle(rpc, min_price=self.min_fee_price)
|
||||||
token = ERC20Token(chain_spec, rpc, add_0x(address))
|
token = ERC20Token(chain_spec, rpc, add_0x(address))
|
||||||
c = ERC20(chain_spec)
|
c = ERC20(chain_spec, gas_oracle=gas_oracle)
|
||||||
o = c.balance_of(address, holder_address, sender_address=caller_address)
|
o = c.balance_of(address, holder_address, sender_address=caller_address)
|
||||||
r = rpc.do(o)
|
r = rpc.do(o)
|
||||||
t['balance_network'] = c.parse_balance(r)
|
t['balance_network'] = c.parse_balance(r)
|
||||||
|
@ -25,12 +25,14 @@ logg = logging.getLogger()
|
|||||||
celery_app = celery.current_app
|
celery_app = celery.current_app
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BaseTask(celery.Task):
|
class BaseTask(celery.Task):
|
||||||
|
|
||||||
session_func = SessionBase.create_session
|
session_func = SessionBase.create_session
|
||||||
call_address = ZERO_ADDRESS
|
call_address = ZERO_ADDRESS
|
||||||
trusted_addresses = []
|
trusted_addresses = []
|
||||||
min_fee_price = 1
|
min_fee_price = 1
|
||||||
|
min_fee_limit = 30000
|
||||||
default_token_address = None
|
default_token_address = None
|
||||||
default_token_symbol = None
|
default_token_symbol = None
|
||||||
default_token_name = None
|
default_token_name = None
|
||||||
@ -42,7 +44,7 @@ class BaseTask(celery.Task):
|
|||||||
if address == None:
|
if address == None:
|
||||||
return RPCGasOracle(
|
return RPCGasOracle(
|
||||||
conn,
|
conn,
|
||||||
code_callback=kwargs.get('code_callback'),
|
code_callback=kwargs.get('code_callback', self.get_min_fee_limit),
|
||||||
min_price=self.min_fee_price,
|
min_price=self.min_fee_price,
|
||||||
id_generator=kwargs.get('id_generator'),
|
id_generator=kwargs.get('id_generator'),
|
||||||
)
|
)
|
||||||
@ -56,6 +58,10 @@ class BaseTask(celery.Task):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_min_fee_limit(self, code):
|
||||||
|
return self.min_fee_limit
|
||||||
|
|
||||||
|
|
||||||
def create_session(self):
|
def create_session(self):
|
||||||
return BaseTask.session_func()
|
return BaseTask.session_func()
|
||||||
|
|
||||||
|
@ -35,10 +35,26 @@ from hexathon import strip_0x
|
|||||||
from cic_eth.eth.gas import cache_gas_data
|
from cic_eth.eth.gas import cache_gas_data
|
||||||
from cic_eth.error import OutOfGasError
|
from cic_eth.error import OutOfGasError
|
||||||
from cic_eth.queue.tx import queue_create
|
from cic_eth.queue.tx import queue_create
|
||||||
|
from cic_eth.task import BaseTask
|
||||||
|
|
||||||
logg = logging.getLogger()
|
logg = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
def test_task_gas_limit(
|
||||||
|
eth_rpc,
|
||||||
|
eth_signer,
|
||||||
|
default_chain_spec,
|
||||||
|
agent_roles,
|
||||||
|
celery_worker,
|
||||||
|
):
|
||||||
|
rpc = RPCConnection.connect(default_chain_spec, 'default')
|
||||||
|
gas_oracle = BaseTask().create_gas_oracle(rpc)
|
||||||
|
c = Gas(default_chain_spec, signer=eth_signer, gas_oracle=gas_oracle)
|
||||||
|
(tx_hash_hex, o) = c.create(agent_roles['ALICE'], agent_roles['BOB'], 10, tx_format=TxFormat.RLP_SIGNED)
|
||||||
|
tx = unpack(bytes.fromhex(strip_0x(o)), default_chain_spec)
|
||||||
|
assert (tx['gas'], BaseTask.min_fee_price)
|
||||||
|
|
||||||
|
|
||||||
def test_task_check_gas_ok(
|
def test_task_check_gas_ok(
|
||||||
default_chain_spec,
|
default_chain_spec,
|
||||||
eth_rpc,
|
eth_rpc,
|
||||||
|
Loading…
Reference in New Issue
Block a user