def test_listener(self):
        harness = self.getHarness(inMemory=True)
        try:
            v1 = harness.newView()
            v2 = harness.newView()

            l = SharedState.Listener(v2)

            space = SharedState.Keyspace("ComparisonKeyType", NativeJson.Json("TestSpace"), 1)
            rng = SharedState.KeyRange(space, 0, None, None, True, False)

            v1.subscribe(rng)
            v2.subscribe(rng)

            keysToWrite = [JsonNative.Json(str(x)) for x in range(40)]

            def writer():
                with SharedState.Transaction(v1):
                    for keyName in keysToWrite:
                        key = SharedState.Key(space, (keyName,))
                        v1[key] = JsonNative.Json("value")

            changedKeys = []
            def reader():
                while len(changedKeys) < len(keysToWrite):
                    updates = l.get()
                    for updateType, update in updates:
                        if updateType == "KeyUpdates":
                            for key in update:
                                changedKeys.append(key[0])

            writerThread = threading.Thread(target=writer)
            readerThread = threading.Thread(target=reader)

            writerThread.start()
            readerThread.start()

            writerThread.join()
            readerThread.join()

            self.assertEqual(set(keysToWrite), set(changedKeys))

        finally:
            time.sleep(0.01)
            harness.teardown()
dataset/ETHPy150Open ufora/ufora/ufora/distributed/SharedState/SharedState_test.py/TestSharedState.test_listener/original