Generating IV from random numbers, not machine ID and local sequence number.
[iotcloud.git] / version2 / src / C / Test.C
index 7b7733ca287a6bbe538548c214f4da302c22dfb9..9393423317092100f0571c50848c3a9303cb094b 100644 (file)
@@ -12,14 +12,19 @@ int main(int numargs, char ** args) {
        Vector<TransactionStatus *> * transStatusList = new Vector<TransactionStatus *>();
 
        // Setup the 2 clients
-       Table * t1 = new Table(new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/"), new IoTString("reallysecret"), 321, -1);
+       IoTString *baseurl = new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/");
+       IoTString * password = new IoTString("reallysecret");
+       Table * t1 = new Table(baseurl, password, 321, -1);
        t1->initTable();
        printf("T1 Ready\n");
 
-       Table * t2 = new Table(new IoTString("http://dc-6.calit2.uci.edu/test.iotcloud/"), new IoTString("reallysecret"), 351, -1);
+       Table * t2 = new Table(baseurl, password, 351, -1);
        t2->update();
        printf("T2 Ready\n");
 
+       baseurl->releaseRef();
+       password->releaseRef();
+       
        // Make the Keys
        printf("Setting up keys\n");
        for (int i = 0; i < NUMBER_OF_TESTS; i++) {
@@ -37,10 +42,10 @@ int main(int numargs, char ** args) {
                t1->createNewKey(ib, 351);
                t2->createNewKey(ic, 321);
                t2->createNewKey(id, 351);
-               delete ia;
-               delete ib;
-               delete ic;
-               delete id;
+               ia->releaseRef();
+               ib->releaseRef();
+               ic->releaseRef();
+               id->releaseRef();
        }
        
        // Do Updates for the keys
@@ -67,22 +72,26 @@ int main(int numargs, char ** args) {
                t1->startTransaction();
                t1->put(iKeyA, iValueA);
                transStatusList->add(t1->commitTransaction());
-               delete iKeyA; delete iValueA;
+               iKeyA->releaseRef();
+               iValueA->releaseRef();
                
                t1->startTransaction();
                t1->put(iKeyB, iValueB);
                transStatusList->add(t1->commitTransaction());
-               delete iKeyB; delete iValueB;
+               iKeyB->releaseRef();
+               iValueB->releaseRef();
                
                t2->startTransaction();
                t2->put(iKeyC, iValueC);
                transStatusList->add(t2->commitTransaction());
-               delete iKeyC; delete iValueC;
+               iKeyC->releaseRef();
+               iValueC->releaseRef();
                
                t2->startTransaction();
                t2->put(iKeyD, iValueD);
                transStatusList->add(t2->commitTransaction());
-               delete iKeyD; delete iValueD;
+               iKeyD->releaseRef();
+               iValueD->releaseRef();
        }
        
        printf("Updating Clients...\n");
@@ -157,14 +166,22 @@ int main(int numargs, char ** args) {
                        printf("Key-Value t2 incorrect: keyD     testValD2\n");
                        foundError = true;
                }
-               delete iKeyA; delete iValueA;
-               delete iKeyB; delete iValueB;
-               delete iKeyC; delete iValueC;
-               delete iKeyD; delete iValueD;
-               delete testValA1; delete testValA2;
-               delete testValB1; delete testValB2;
-               delete testValC1; delete testValC2;
-               delete testValD1; delete testValD2;
+               iKeyA->releaseRef();
+               iValueA->releaseRef();
+               iKeyB->releaseRef();
+               iValueB->releaseRef();
+               iKeyC->releaseRef();
+               iValueC->releaseRef();
+               iKeyD->releaseRef();
+               iValueD->releaseRef();
+               testValA1->releaseRef();
+               testValA2->releaseRef();
+               testValB1->releaseRef();
+               testValB2->releaseRef();
+               testValC1->releaseRef();
+               testValC2->releaseRef();
+               testValD1->releaseRef();
+               testValD2->releaseRef();
        }
 
        for (uint i = 0; i < transStatusList->size(); i++) {
@@ -173,6 +190,7 @@ int main(int numargs, char ** args) {
                        foundError = true;
                        printf("Status error\n");
                }
+               delete status;
        }
        
        if (foundError) {
@@ -183,6 +201,5 @@ int main(int numargs, char ** args) {
 
        delete transStatusList;
        delete t1;
-       delete t2;
 }