예제 #1
0
    def test_nonces_set_to_tx_value(self):
        n = self.nonces.get_latest_nonce(sender='abc', processor='def')
        self.assertEqual(n, 0)

        storage.update_state_with_transaction(tx=tx_1,
                                              driver=self.driver,
                                              nonces=self.nonces)

        n = self.nonces.get_latest_nonce(sender='abc', processor='def')
        self.assertEqual(n, 124)
예제 #2
0
    def test_nonces_deleted_after_all_updates(self):
        self.nonces.set_pending_nonce(sender='abc', processor='def', value=122)

        n = self.nonces.get_pending_nonce(sender='abc', processor='def')

        self.assertEqual(n, 122)

        storage.update_state_with_transaction(tx=tx_1,
                                              driver=self.driver,
                                              nonces=self.nonces)

        n = self.nonces.get_pending_nonce(sender='abc', processor='def')

        self.assertEqual(n, None)
예제 #3
0
    def test_state_updated_to_correct_values_in_tx(self):
        v1 = self.driver.get('hello', mark=False)
        v2 = self.driver.get('name', mark=False)

        self.assertIsNone(v1)
        self.assertIsNone(v2)

        storage.update_state_with_transaction(tx=tx_1,
                                              driver=self.driver,
                                              nonces=self.nonces)

        v1 = self.driver.get('hello', mark=False)
        v2 = self.driver.get('name', mark=False)

        self.assertEqual(v1, 'there')
        self.assertEqual(v2, 'jeff')
예제 #4
0
    def test_multiple_txs_deletes_multiple_nonces(self):
        self.nonces.set_pending_nonce(sender='abc', processor='def', value=122)

        n = self.nonces.get_pending_nonce(sender='abc', processor='def')
        self.assertEqual(n, 122)

        self.nonces.set_pending_nonce(sender='xxx', processor='yyy', value=4)

        n = self.nonces.get_pending_nonce(sender='xxx', processor='yyy')
        self.assertEqual(n, 4)

        storage.update_state_with_transaction(tx=tx_1,
                                              driver=self.driver,
                                              nonces=self.nonces)

        storage.update_state_with_transaction(tx=tx_2,
                                              driver=self.driver,
                                              nonces=self.nonces)

        storage.update_state_with_transaction(tx=tx_3,
                                              driver=self.driver,
                                              nonces=self.nonces)

        n = self.nonces.get_pending_nonce(sender='abc', processor='def')
        self.assertEqual(n, None)

        n = self.nonces.get_pending_nonce(sender='xxx', processor='yyy')
        self.assertEqual(n, None)

        n = self.nonces.get_latest_nonce(sender='abc', processor='def')
        self.assertEqual(n, 125)

        n = self.nonces.get_latest_nonce(sender='xxx', processor='yyy')
        self.assertEqual(n, 43)
예제 #5
0
    def test_multiple_tx_state_updates_correctly(self):
        v1 = self.driver.get('hello', mark=False)
        v2 = self.driver.get('name', mark=False)

        v3 = self.driver.get('name2', mark=False)

        v4 = self.driver.get('another', mark=False)
        v5 = self.driver.get('something', mark=False)

        self.assertIsNone(v1)
        self.assertIsNone(v2)
        self.assertIsNone(v3)
        self.assertIsNone(v4)
        self.assertIsNone(v5)

        storage.update_state_with_transaction(tx=tx_1,
                                              driver=self.driver,
                                              nonces=self.nonces)

        storage.update_state_with_transaction(tx=tx_2,
                                              driver=self.driver,
                                              nonces=self.nonces)

        storage.update_state_with_transaction(tx=tx_3,
                                              driver=self.driver,
                                              nonces=self.nonces)

        v1 = self.driver.get('hello', mark=False)
        v2 = self.driver.get('name', mark=False)

        v3 = self.driver.get('name2', mark=False)

        v4 = self.driver.get('another', mark=False)
        v5 = self.driver.get('something', mark=False)

        self.assertEqual(v1, 'there2')
        self.assertEqual(v2, 'jeff')
        self.assertEqual(v3, 'jeff2')
        self.assertEqual(v4, 'value')
        self.assertEqual(v5, 'else')