Compare commits

..

3 Commits

Author SHA1 Message Date
lash
c22fafad53
Update setup 2022-04-10 15:31:58 +00:00
lash
b5f513b63a
Ignore missing txs, sync store on start 2022-04-10 15:30:08 +00:00
lash
01b674d09e
Add change test for chainqueue entry 2022-04-10 14:00:01 +00:00
6 changed files with 43 additions and 10 deletions

View File

@ -115,7 +115,8 @@ class QueueEntry:
def fail(self, block, tx):
if self.__match_state(self.store.NETWORK_ERROR):
return
self.store.set(self.k, self.store.NETWORK_ERROR)
v = self.store.state(self.k)
self.store.change(self.k, v | self.store.NETWORK_ERROR, self.store.QUEUED)
if self.store.cache:
self.store.cache.set_block(self.tx_hash, block, tx)

View File

@ -1,10 +1,14 @@
# standard imports
import re
import datetime
import logging
# local imports
from chainqueue.cache import CacheTx
from chainqueue.entry import QueueEntry
from chainqueue.error import NotLocalTxError
logg = logging.getLogger(__name__)
def to_key(t, n, k):
@ -39,6 +43,7 @@ class Store:
'modified',
]:
setattr(self, v, getattr(self.state_store, v))
self.state_store.sync()
def put(self, v, cache_adapter=CacheTx):
@ -56,7 +61,10 @@ class Store:
def get(self, k):
s = self.index_store.get(k)
try:
s = self.index_store.get(k)
except FileNotFoundError:
raise NotLocalTxError(k)
v = self.state_store.get(s)
return (s, v,)

View File

@ -4,7 +4,7 @@ version = 0.1.0
description = Generic blockchain transaction queue control
author = Louis Holbrook
author_email = dev@holbrook.no
url = https://gitlab.com/chaintools/chainqueue
url = https://gitlab.com/chaintool/chainqueue
keywords =
cic
cryptocurrency
@ -29,13 +29,11 @@ python_requires = >= 3.6
include_package_data = True
packages =
chainqueue
chainqueue.db
chainqueue.db.models
chainqueue.sql
chainqueue.adapters
chainqueue.cache
chainqueue.unittest
chainqueue.store
chainqueue.runnable
[options.entry_points]
console_scripts =
chainqueue-list = chainqueue.runnable.list:main
#[options.entry_points]
#console_scripts =
# chainqueue-list = chainqueue.runnable.list:main

View File

@ -2,6 +2,7 @@
import tempfile
import unittest
import shutil
import logging
# external imports
from shep.store.file import SimpleFileStoreFactory
@ -19,6 +20,7 @@ from tests.common import (
MockContentStore,
)
logg = logging.getLogger(__name__)
class TestShepBase(unittest.TestCase):
@ -30,6 +32,7 @@ class TestShepBase(unittest.TestCase):
counter = MockCounter()
chain_spec = ChainSpec('foo', 'bar', 42, 'baz')
self.store = Store(chain_spec, self.state, content_store, counter)
logg.debug('using path {}'.format(self.path))
def tearDown(self):

View File

@ -5,6 +5,8 @@ import unittest
# external imports
from hexathon import add_0x
from chainlib.tx import Tx
from chainlib.block import Block
# local imports
from chainqueue import QueueEntry
@ -59,5 +61,25 @@ class TestEntry(TestShepBase):
self.assertEqual(len(txs), 1)
def test_entry_change(self):
signed_tx = add_0x(os.urandom(128).hex())
nonce = 42
entry = QueueEntry(self.store, cache_adapter=MockCacheTokenTx)
tx_hash = entry.create(signed_tx)
block = Block()
block.number = 13
tx = Tx(None)
tx.index = 666
entry.readysend()
entry.reserve()
entry.sendfail()
entry = QueueEntry(self.store, tx_hash, cache_adapter=MockCacheTokenTx)
entry.load()
self.assertEqual(str(entry), tx_hash + ': SENDFAIL')
if __name__ == '__main__':
unittest.main()

View File

@ -55,5 +55,6 @@ class TestShep(TestShepBase):
self.store.put('bar', cache_adapter=MockCacheTokenTx)
if __name__ == '__main__':
unittest.main()