MCPcopy Create free account
hub / github.com/block/buzz / createMockChannel

Function createMockChannel

desktop/src/testing/e2eBridge.ts:898–932  ·  view source on GitHub ↗
(
  seed: Omit<
    MockChannel,
    | "created_at"
    | "member_count"
    | "members"
    | "updated_at"
    | "participant_pubkeys"
    | "participants"
    | "ttl_seconds"
    | "ttl_deadline"
  > & {
    created_minutes_ago: number;
    members: RawChannelMember[];
    participant_pubkeys?: string[];
    participants?: string[];
    ttl_seconds?: number | null;
    ttl_deadline?: string | null;
    updated_minutes_ago?: number;
  },
)

Source from the content-addressed store, hash-verified

896}
897
898function createMockChannel(
899 seed: Omit<
900 MockChannel,
901 | "created_at"
902 | "member_count"
903 | "members"
904 | "updated_at"
905 | "participant_pubkeys"
906 | "participants"
907 | "ttl_seconds"
908 | "ttl_deadline"
909 > & {
910 created_minutes_ago: number;
911 members: RawChannelMember[];
912 participant_pubkeys?: string[];
913 participants?: string[];
914 ttl_seconds?: number | null;
915 ttl_deadline?: string | null;
916 updated_minutes_ago?: number;
917 },
918): MockChannel {
919 return {
920 ...seed,
921 created_at: isoMinutesAgo(seed.created_minutes_ago),
922 member_count: seed.members.length,
923 members: cloneMembers(seed.members),
924 participant_pubkeys: [...(seed.participant_pubkeys ?? [])],
925 participants: [...(seed.participants ?? [])],
926 ttl_seconds: seed.ttl_seconds ?? null,
927 ttl_deadline: seed.ttl_deadline ?? null,
928 updated_at: isoMinutesAgo(
929 seed.updated_minutes_ago ?? seed.created_minutes_ago,
930 ),
931 };
932}
933
934function syncMockChannel(channel: MockChannel) {
935 channel.member_count = channel.members.length;

Callers 3

e2eBridge.tsFile · 0.85
handleCreateChannelFunction · 0.85
handleOpenDmFunction · 0.85

Calls 2

isoMinutesAgoFunction · 0.85
cloneMembersFunction · 0.85

Tested by

no test coverage detected