2021-04-02 14:02:22 +02:00
|
|
|
# standard imports
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
# local imports
|
|
|
|
from chainqueue.db.models.otx import Otx
|
2021-05-28 11:13:01 +02:00
|
|
|
from chainqueue.sql.state import *
|
2021-04-02 14:02:22 +02:00
|
|
|
|
|
|
|
# test imports
|
2021-08-26 10:05:56 +02:00
|
|
|
from tests.chainqueue_base import TestOtxBase
|
2021-04-02 14:02:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TestOtxState(TestOtxBase):
|
|
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(TestOtxState, self).setUp()
|
|
|
|
Otx.tracing = True
|
|
|
|
logg.debug('state trace')
|
|
|
|
|
|
|
|
|
|
|
|
def test_state_log(self):
|
2021-05-28 11:13:01 +02:00
|
|
|
set_ready(self.chain_spec, self.tx_hash, session=self.session)
|
|
|
|
set_reserved(self.chain_spec, self.tx_hash, session=self.session)
|
|
|
|
set_sent(self.chain_spec, self.tx_hash, session=self.session)
|
|
|
|
set_final(self.chain_spec, self.tx_hash, block=1042, session=self.session)
|
2021-04-02 14:02:22 +02:00
|
|
|
|
2021-04-03 00:17:05 +02:00
|
|
|
state_log = get_state_log(self.chain_spec, self.tx_hash)
|
2021-04-02 14:02:22 +02:00
|
|
|
self.assertEqual(state_log[0][1], StatusEnum.READYSEND)
|
|
|
|
self.assertEqual(state_log[1][1], StatusEnum.RESERVED)
|
|
|
|
self.assertEqual(state_log[2][1], StatusEnum.SENT)
|
|
|
|
self.assertEqual(state_log[3][1], StatusEnum.SUCCESS)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|