Test.DhtOpTester.Test13 C# (CSharp) Méthode

Test13() public méthode

public Test13 ( int &op ) : void
op int
Résultat void
    public void Test13(ref int op) {
      Console.WriteLine("Test 13: Testing 10 parallel puts and 1 get with the" +
          " same key, we should get none back as they are meant to expire " +
          "before the get.");
      RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
      byte[] key = new byte[10];
      byte[] value = new byte[value_size];
      byte[][] keys = new byte[10][];
      byte[][] values = new byte[10][];
      int[] ttls = new int[10];
      bool[] put_results = new bool[10];

      key = new byte[10];
      rng.GetBytes(key);

      for(int i = 0; i < 10; i++) {
        keys[i] = key;
        value = new byte[value_size];
        rng.GetBytes(value);
        values[i] = value;
        if(i > 7) {
          ttls[i] = 15;
        }
        else {
          ttls[i] = 500;
        }
        put_results[i] = true;
      }
      this.ParallelPut(keys, values, ttls, put_results, ref op);
      Console.WriteLine("Insertion done...");
      Thread.Sleep(5000);
      this.SerialGet(key, values, op++);
      Console.WriteLine("Next get 2 should fail!");
      Thread.Sleep(20000);
      this.SerialGet(key, values, op++);
      Console.WriteLine("If no error messages successful up to: " + (op - 1));
      Console.WriteLine("Every entry should be deleted by now...");
    }