From 9c22be3516d5067b98b06271e2f3545713ff6099 Mon Sep 17 00:00:00 2001 From: Aleksi Lindeman <0xdec05eba@gmail.com> Date: Sat, 17 Mar 2018 14:18:14 +0100 Subject: Add callback functions for operations --- tests/main.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/main.cpp b/tests/main.cpp index 30703ea..bd7d75c 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -17,16 +17,16 @@ void testHash() { Hash hash("odhtdb", 6); assertEquals("a7b30ec8ab92de60e551b26bb8f78d315697f84dd7f5549a143477e095ec934f", hash.toString()); - Log::debug("hash of 'odhtdb' is: a7b30ec8ab92de60e551b26bb8f78d315697f84dd7f5549a143477e095ec934f\n"); + Log::debug("hash of 'odhtdb' is: a7b30ec8ab92de60e551b26bb8f78d315697f84dd7f5549a143477e095ec934f"); } void testSignData(LocalUser *localUser) { std::string publicKeyStr = localUser->getPublicKey().toString(); - Log::debug("Local user public key: %s\n", publicKeyStr.c_str()); + Log::debug("Local user public key: %s", publicKeyStr.c_str()); std::string privateKeyStr = localUser->getPrivateKey().toString(); - Log::debug("Local user private key: %s\n", privateKeyStr.c_str()); + Log::debug("Local user private key: %s", privateKeyStr.c_str()); string expectedUnsignedData = "hello, world!"; string signedData = localUser->getPrivateKey().sign(DataView((void*)expectedUnsignedData.data(), expectedUnsignedData.size())); @@ -83,7 +83,7 @@ void testEncryption() int main() { - Log::debug("Starting tests...\n"); + Log::debug("Starting tests..."); LocalUser *localUser = LocalUser::create(Signature::KeyPair(), "dec05eba", nullptr); testSignData(localUser); testEncryption(); @@ -91,6 +91,22 @@ int main() // TODO: Setup local bootstrap node for tests Database database("bootstrap.ring.cx", 4222, "storage"); + + database.setOnCreateNodeCallback([](const DatabaseCreateNodeRequest &request) + { + Log::debug("Create node callback"); + }); + + database.setOnAddNodeCallback([](const DatabaseAddNodeRequest &request) + { + Log::debug("Add node callback"); + }); + + database.setOnAddUserCallback([](const DatabaseAddUserRequest &request) + { + Log::debug("Add user callback"); + }); + auto databaseCreateResponse = database.create("adminUserName", "latenight"); DatabaseNode databaseNode(databaseCreateResponse->getNodeEncryptionKey(), databaseCreateResponse->getRequestHash()); auto adminUser = (LocalUser*)databaseCreateResponse->getNodeAdminUser(); -- cgit v1.2.3