aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-03-17 14:18:14 +0100
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:25:46 +0200
commit53a1850ce2a253c574113684ac38c8ed31b1d0ae (patch)
tree00d73cd00217e2c64b08377f146862d644cef55c /tests
parent89d9a70f8bc284970138d0fb824b5fcbf13d0b3c (diff)
Add callback functions for operations
Diffstat (limited to 'tests')
-rw-r--r--tests/main.cpp24
1 files changed, 20 insertions, 4 deletions
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<string>("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();