Handle duplicate tx attempts
This commit is contained in:
@@ -12,6 +12,7 @@ from chainqueue.store.fs import (
|
||||
IndexStore,
|
||||
CounterStore,
|
||||
)
|
||||
from chainqueue.error import DuplicateTxError
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
@@ -48,5 +49,14 @@ class TestStoreImplementations(unittest.TestCase):
|
||||
self.assertEqual(v, 2)
|
||||
|
||||
|
||||
def test_duplicate(self):
|
||||
store = IndexStore(self.path)
|
||||
hx = os.urandom(32).hex()
|
||||
data = 'foo_bar_baz'
|
||||
store.put(hx, data)
|
||||
with self.assertRaises(DuplicateTxError):
|
||||
store.put(hx, data)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user