Handle duplicate tx attempts

This commit is contained in:
lash
2022-04-12 13:44:29 +00:00
parent c22fafad53
commit 95930ef7de
5 changed files with 33 additions and 3 deletions

View File

@@ -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()