aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAleksi Lindeman <0xdec05eba@gmail.com>2018-03-17 14:18:14 +0100
committerAleksi Lindeman <0xdec05eba@gmail.com>2018-03-17 14:18:21 +0100
commit9c22be3516d5067b98b06271e2f3545713ff6099 (patch)
treed733bf5988321a34cc5a564a7fb2ed152b75ee9f /tests
parent05bcf662835aefe4b63439860825345afbc911f4 (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();