implement get tx by state
This commit is contained in:
@@ -2,43 +2,21 @@
|
||||
import os
|
||||
import logging
|
||||
import unittest
|
||||
import tempfile
|
||||
|
||||
# external imports
|
||||
from hexathon import add_0x
|
||||
from shep.store.file import SimpleFileStoreFactory
|
||||
from shep.error import StateTransitionInvalid
|
||||
|
||||
# local imports
|
||||
from chainqueue import Status
|
||||
from chainqueue.tx import Tx
|
||||
from chainqueue import QueueEntry
|
||||
|
||||
# test imports
|
||||
from tests.base_shep import TestShepBase
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logg = logging.getLogger()
|
||||
|
||||
|
||||
class MockIndexStore:
|
||||
|
||||
def __init__(self):
|
||||
self.store = {}
|
||||
|
||||
|
||||
def put(self, k, v):
|
||||
self.store[k] = v
|
||||
|
||||
|
||||
def get(self, k):
|
||||
return self.store.get(k)
|
||||
|
||||
|
||||
class TestShepBase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.path = tempfile.mkdtemp()
|
||||
factory = SimpleFileStoreFactory(self.path).add
|
||||
self.state = Status(factory)
|
||||
|
||||
|
||||
class TestShep(TestShepBase):
|
||||
|
||||
def test_shep_setup(self):
|
||||
@@ -49,11 +27,10 @@ class TestShep(TestShepBase):
|
||||
tx_hash = add_0x(os.urandom(20).hex())
|
||||
signed_tx = add_0x(os.urandom(128).hex())
|
||||
nonce = 42
|
||||
mock_store = MockIndexStore()
|
||||
tx = Tx(self.state, mock_store, tx_hash)
|
||||
tx = QueueEntry(self.store, tx_hash)
|
||||
tx.create(nonce, signed_tx)
|
||||
|
||||
tx_retrieved = Tx(self.state, mock_store, tx_hash)
|
||||
tx_retrieved = QueueEntry(self.store, tx_hash)
|
||||
tx_retrieved.load()
|
||||
self.assertEqual(tx_retrieved.signed_tx, signed_tx)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user