22 lines
1.4 KiB
C
22 lines
1.4 KiB
C
/* Проверяемый участник сетевого теста: JOIN эпохи 1, профиль версии 1 и корневая подпись группы. */
|
|
#ifndef TEST_MEMBERSHIP_H
|
|
#define TEST_MEMBERSHIP_H
|
|
#include <openssl/sha.h>
|
|
#include "chat/member_sync.h"
|
|
#include "utun_instance.h"
|
|
#include "routing_layer/topo_node_sqlite.h"
|
|
#include "transport_layer/secure_channel.h"
|
|
|
|
static int test_member_seed(struct UTUN_INSTANCE* inst, const char* channel, const uint8_t x[32], const uint8_t ed[32],
|
|
const uint8_t private[32], const uint8_t group_private[32], const char* info, const char* tags, const uint8_t* tags_sig) {
|
|
uint8_t gx[32], ged[32], body[MS_USERINFO_MAX + 128], join[64], update[64], tree[64];
|
|
uint64_t id = sc_derive_node_id_from_pubkey(x);
|
|
if (topo_node_sqlite_channel_get(inst->topo_sqlite_db, channel, NULL, 0, NULL, gx, ged, NULL)) return -1;
|
|
int size = member_sync_build_join_msg(gx, ged, id, x, 1, body, sizeof(body));
|
|
if (size < 0 || sc_ed25519_sign(private, body, size, join) != SC_OK || member_sync_sign_join(group_private, join, tree)) return -1;
|
|
size = member_sync_build_update_msg(join, 1, info, body, sizeof(body));
|
|
if (size < 0 || sc_ed25519_sign(private, body, size, update) != SC_OK) return -1;
|
|
return member_sync_put(inst, channel, id, x, ed, join, 1, update, 1, info, tags, tags_sig, 0, 0, tree);
|
|
}
|
|
#endif
|