code: def test_localstorage_nested():
      time = get_dht_time()
      d1 = DHTLocalStorage()
      d2 = DictionaryDHTValue()
      d2.store("subkey1", b"value1", time + 2)
      d2.store("subkey2", b"value2", time + 3)
      d2.store("subkey3", b"value3", time + 1)
  
      assert d2.latest_expiration_time == time + 3
      for subkey, (subvalue, subexpiration) in d2.items():
          assert d1.store_subkey(
              DHTID.generate("foo"), subkey, subvalue, subexpiration
          )
      assert d1.store(DHTID.generate("bar"), b"456", time + 2)
      assert d1.get(DHTID.generate("foo"))[0].data == d2.data
      assert (
          d1.get(DHTID.generate("foo"))[1] == d2.latest_expiration_time
      )
      assert d1.get(DHTID.generate("foo"))[0].get("subkey1") == (
          b"value1",
          time + 2,
      )
      assert len(d1.get(DHTID.generate("foo"))[0]) == 3
      assert d1.store_subkey(
          DHTID.generate("foo"), "subkey4", b"value4", time + 4
      )
      assert len(d1.get(DHTID.generate("foo"))[0]) == 4
  
      assert (
          d1.store_subkey(
              DHTID.generate("bar"), "subkeyA", b"valueA", time + 1
          )
          is False
      )  # prev has better expiration
      assert d1.store_subkey(
          DHTID.generate("bar"), "subkeyA", b"valueA", time + 3
      )  # new value has better expiration
      assert d1.store_subkey(
          DHTID.generate("bar"), "subkeyB", b"valueB", time + 4
      )  # new value has better expiration
      assert d1.store_subkey(
          DHTID.generate("bar"), "subkeyA", b"valueA+", time + 5
      )  # overwrite subkeyA under key bar
      assert all(
          subkey in d1.get(DHTID.generate("bar"))[0]
          for subkey in ("subkeyA", "subkeyB")
      )
      assert (
          len(d1.get(DHTID.generate("bar"))[0]) == 2
          and d1.get(DHTID.generate("bar"))[1] == time + 5
      )
  
      assert (
          d1.store(DHTID.generate("foo"), b"nothing", time + 3.5)
          is False
      )  # previous value has better expiration
      assert d1.get(DHTID.generate("foo"))[0].get("subkey2") == (
          b"value2",
          time + 3,
      )
      assert (
          d1.store(DHTID.generate("foo"), b"nothing", time + 5) is True
      )  # new value has better expiraiton
      assert d1.get(DHTID.generate("foo")) == (b"nothing", time + 5)
  
file_path: hivemind/tests/test_dht_storage.py
imports: import time
  from hivemind.dht.storage import DHTID, DHTLocalStorage, DictionaryDHTValue
  from hivemind.utils.serializer import MSGPackSerializer
  from hivemind.utils.timed_storage import get_dht_time
label_desc: Use image node_id 7 for calling a global function with example usage: test_localstorage_nested() without return types