11 #include "meshlink-tiny.h"
17 full_meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_cb);
18 meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_cb);
20 meshlink_handle_t *mesh1;
21 meshlink_handle_t *mesh2;
25 assert(full_meshlink_destroy("storage-policy_conf.1"));
26 assert(meshlink_destroy("storage-policy_conf.2"));
28 mesh1 = full_meshlink_open("storage-policy_conf.1", "foo", "storage-policy", DEV_CLASS_BACKBONE);
29 mesh2 = meshlink_open("storage-policy_conf.2", "bar", "storage-policy", DEV_CLASS_BACKBONE);
32 full_meshlink_set_storage_policy(mesh1, MESHLINK_STORAGE_DISABLED);
33 meshlink_set_storage_policy(mesh2, MESHLINK_STORAGE_DISABLED);
37 char *export1 = full_meshlink_export(mesh1);
38 char *export2 = meshlink_export(mesh2);
43 assert(full_meshlink_import(mesh1, export2));
44 assert(meshlink_import(mesh2, export1));
46 // Check that they know each other
48 assert(full_meshlink_get_node(mesh1, "bar"));
49 assert(meshlink_get_node(mesh2, "foo"));
51 start_full_tiny_pair(mesh1, mesh2);
53 // Close the instances and reopen them.
55 close_full_tiny_pair(mesh1, mesh2);
57 mesh1 = full_meshlink_open("storage-policy_conf.1", "foo", "storage-policy", DEV_CLASS_BACKBONE);
58 mesh2 = meshlink_open("storage-policy_conf.2", "bar", "storage-policy", DEV_CLASS_BACKBONE);
61 full_meshlink_set_storage_policy(mesh1, MESHLINK_STORAGE_KEYS_ONLY);
62 meshlink_set_storage_policy(mesh2, MESHLINK_STORAGE_KEYS_ONLY);
64 // Check that the nodes no longer know each other
66 assert(!full_meshlink_get_node(mesh1, "bar"));
67 assert(!meshlink_get_node(mesh2, "foo"));
69 // Exchange data again
71 assert(full_meshlink_import(mesh1, export2));
72 assert(meshlink_import(mesh2, export1));
77 // Close the instances and reopen them.
79 close_full_tiny_pair(mesh1, mesh2);
81 mesh1 = full_meshlink_open("storage-policy_conf.1", "foo", "storage-policy", DEV_CLASS_BACKBONE);
82 mesh2 = meshlink_open("storage-policy_conf.2", "bar", "storage-policy", DEV_CLASS_BACKBONE);
85 full_meshlink_set_storage_policy(mesh1, MESHLINK_STORAGE_KEYS_ONLY);
86 meshlink_set_storage_policy(mesh2, MESHLINK_STORAGE_KEYS_ONLY);
88 // Check that the nodes know each other
90 assert(full_meshlink_get_node(mesh1, "bar"));
91 assert(meshlink_get_node(mesh2, "foo"));
93 // Check that if we change back to STORAGE_ENABLED right before closing, pending changes are still saved
95 start_full_tiny_pair(mesh1, mesh2);
96 stop_full_tiny_pair(mesh1, mesh2);
98 full_meshlink_set_storage_policy(mesh1, MESHLINK_STORAGE_ENABLED);
99 meshlink_set_storage_policy(mesh2, MESHLINK_STORAGE_ENABLED);
101 close_full_tiny_pair(mesh1, mesh2);
103 mesh1 = full_meshlink_open("storage-policy_conf.1", "foo", "storage-policy", DEV_CLASS_BACKBONE);
104 mesh2 = meshlink_open("storage-policy_conf.2", "bar", "storage-policy", DEV_CLASS_BACKBONE);
108 // Close the instances and reopen them.
110 close_full_tiny_pair(mesh1, mesh2);
112 mesh1 = full_meshlink_open("storage-policy_conf.1", "foo", "storage-policy", DEV_CLASS_BACKBONE);
113 mesh2 = meshlink_open("storage-policy_conf.2", "bar", "storage-policy", DEV_CLASS_BACKBONE);
116 full_meshlink_set_storage_policy(mesh1, MESHLINK_STORAGE_KEYS_ONLY);
117 meshlink_set_storage_policy(mesh2, MESHLINK_STORAGE_KEYS_ONLY);
119 // Check that the nodes know each other
121 assert(full_meshlink_get_node(mesh1, "bar"));
122 assert(meshlink_get_node(mesh2, "foo"));
126 close_full_tiny_pair(mesh1, mesh2);