Add dispatch tests
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
# standard imports
|
||||
import logging
|
||||
|
||||
# external imports
|
||||
from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from chainlib.eth.tx import (
|
||||
@@ -8,14 +11,19 @@ from hexathon import (
|
||||
add_0x,
|
||||
strip_0x,
|
||||
)
|
||||
from chainqueue.enum import StatusBits
|
||||
|
||||
# local imports
|
||||
from chainqueue.adapters.base import Adapter
|
||||
|
||||
#logg = logging.getLogger(__name__)
|
||||
logg = logging.getLogger()
|
||||
|
||||
|
||||
class EthAdapter(Adapter):
|
||||
|
||||
def translate(self, chain_spec, bytecode):
|
||||
def translate(self, bytecode, chain_spec):
|
||||
logg.debug('bytecode {}'.format(bytecode))
|
||||
tx = unpack(bytecode, chain_spec)
|
||||
tx['source_token'] = ZERO_ADDRESS
|
||||
tx['destination_token'] = ZERO_ADDRESS
|
||||
@@ -34,8 +42,8 @@ class EthAdapter(Adapter):
|
||||
return self.backend.get(chain_spec, StatusBits.QUEUED, self.translate) # possible maldesign, up-stack should use our session?
|
||||
|
||||
|
||||
def add(self, chain_spec, bytecode, session=None):
|
||||
tx = self.translate(chain_spec, bytecode)
|
||||
def add(self, bytecode, chain_spec, session=None):
|
||||
tx = self.translate(bytecode, chain_spec)
|
||||
r = self.backend.create(chain_spec, tx['nonce'], tx['from'], tx['hash'], add_0x(bytecode.hex()), session=session)
|
||||
if r:
|
||||
session.rollback()
|
||||
|
||||
Reference in New Issue
Block a user