code: def test_composite_validator(validators_for_app):
      validator = CompositeValidator(validators_for_app["A"])
      assert [type(item) for item in validator._validators] == [
          SchemaValidator,
          RSASignatureValidator,
      ]
  
      validator.extend(validators_for_app["B"])
      assert [type(item) for item in validator._validators] == [
          SchemaValidator,
          RSASignatureValidator,
      ]
      assert len(validator._validators[0]._schemas) == 2
  
      local_public_key = validators_for_app["A"][0].local_public_key
      record = DHTRecord(
          key=DHTID.generate(source="field_b").to_bytes(),
          subkey=DHTProtocol.serializer.dumps(local_public_key),
          value=DHTProtocol.serializer.dumps(777),
          expiration_time=hivemind.get_dht_time() + 10,
      )
  
      signed_record = dataclasses.replace(
          record, value=validator.sign_value(record)
      )
      # Expect only one signature since two RSASignatureValidatos have been merged
      assert signed_record.value.count(b"[signature:") == 1
      # Expect successful validation since the second SchemaValidator has been merged to the first
      assert validator.validate(signed_record)
      assert validator.strip_value(signed_record) == record.value
  
      record = DHTRecord(
          key=DHTID.generate(source="unknown_key").to_bytes(),
          subkey=DHTProtocol.IS_REGULAR_VALUE,
          value=DHTProtocol.serializer.dumps(777),
          expiration_time=hivemind.get_dht_time() + 10,
      )
  
      signed_record = dataclasses.replace(
          record, value=validator.sign_value(record)
      )
      assert signed_record.value.count(b"[signature:") == 0
      # Expect failed validation since `unknown_key` is not a part of any schema
      assert not validator.validate(signed_record)
  
file_path: hivemind/tests/test_dht_validation.py
imports: import dataclasses
  from typing import Dict
  import pytest
  from pydantic import BaseModel, StrictInt
  import hivemind
  from hivemind.dht.crypto import RSASignatureValidator
  from hivemind.dht.protocol import DHTProtocol
  from hivemind.dht.routing import DHTID
  from hivemind.dht.schema import BytesWithPublicKey, SchemaValidator
  from hivemind.dht.validation import CompositeValidator, DHTRecord
label_desc: Use image node_id 2 for calling a global function with example usage: test_composite_validator(validators_for_app) without return types