Список каналов возвращает - хотя сырое всё как то - но всё работает :)
This commit is contained in:
AidarKC
2026-01-09 00:56:05 +03:00
parent aba86fc687
commit 9d0da4b39f
5 changed files with 91 additions and 41 deletions
@@ -37,15 +37,24 @@ public class IT_03_AddBlock_NoAuth {
String u1 = TestConfig.LOGIN();
String u2 = TestConfig.LOGIN2();
String u3 = TestConfig.LOGIN3();
String bch1 = TestConfig.getBlockchainName(u1);
String bch2 = TestConfig.getBlockchainName(u2);
String bch3 = TestConfig.getBlockchainName(u3);
Duration t = Duration.ofSeconds(1);
try (WsSession ws = WsSession.open()) {
if (TestConfig.DEBUG()) TestLog.titleBlock("IT_03: USER1=" + u1 + " bch=" + bch1 + " | USER2=" + u2 + " bch=" + bch2);
if (TestConfig.DEBUG()) {
TestLog.titleBlock(
"IT_03:\n" +
" USER1=" + u1 + " bch=" + bch1 + "\n" +
" USER2=" + u2 + " bch=" + bch2 + "\n" +
" USER3=" + u3 + " bch=" + bch3
);
}
// USER1
ChainState st1 = new ChainState();
@@ -88,11 +97,33 @@ public class IT_03_AddBlock_NoAuth {
sender2.send(new UserParamBody("Anya", "Amsterdam, Example street 10"), t);
// USER3 (нужен, чтобы u1 мог подписаться на существующий блокчейн)
ChainState st3 = new ChainState();
AddBlockSender sender3 = new AddBlockSender(ws, st3, u3, bch3, TestConfig.getBlockchainPrivatKey(u3));
sender3.send(new HeaderBody(u3), t);
assertTrue(st3.hasHeader());
// -----------------------------------------------------------------
// Подписки (как ты просил):
// - u1 follows u2 и u3
// - u2 follows только u1
// -----------------------------------------------------------------
// u1 -> follow u2
sender1.send(new ConnectionBody(ConnectionBody.SUB_FOLLOW, u2, bch2, 0, new byte[32]), t);
// u1 -> follow u3
sender1.send(new ConnectionBody(ConnectionBody.SUB_FOLLOW, u3, bch3, 0, new byte[32]), t);
// u2 -> follow u1
sender2.send(new ConnectionBody(ConnectionBody.SUB_FOLLOW, u1, bch1, 0, new byte[32]), t);
// (оставил твои friend/unfriend как было — но они уже не обязательны для подписок)
sender2.send(new ConnectionBody(ConnectionBody.SUB_FRIEND, u1, bch1, 0, new byte[32]), t);
sender1.send(new UserParamBody("Anna", "Gareeva"), t);
sender1.send(new ConnectionBody(ConnectionBody.SUB_FRIEND, u2, bch2, 0, new byte[32]), t);
sender1.send(new ConnectionBody(ConnectionBody.SUB_FOLLOW, u2, bch2, 0, new byte[32]), t);
sender2.send(new ConnectionBody(ConnectionBody.SUB_UNFRIEND, u1, bch1, 0, new byte[32]), t);
@@ -4,6 +4,7 @@ import test.it.cases.IT_01_AddUser;
import test.it.cases.IT_02_Sessions;
import test.it.cases.IT_03_AddBlock_NoAuth;
import test.it.cases.IT_04_UserParams_NoAuth;
import test.it.cases.IT_05_ListSubscribedChannels_200;
import test.it.utils.log.TestLog;
import java.util.ArrayList;
@@ -17,7 +18,6 @@ public class IT_RunAllMain {
public static void main(String[] args) {
int failed = runAll();
System.exit(failed);
}
public static int runAll() {
@@ -31,6 +31,7 @@ public class IT_RunAllMain {
String s2 = IT_02_Sessions.run(); summaries.add(s2); if (s2.contains("FAIL:")) failed++;
String s3 = IT_03_AddBlock_NoAuth.run(); summaries.add(s3); if (s3.contains("FAIL:")) failed++;
String s4 = IT_04_UserParams_NoAuth.run(); summaries.add(s4); if (s4.contains("FAIL:")) failed++;
String s5 = IT_05_ListSubscribedChannels_200.run(); summaries.add(s5); if (s5.contains("FAIL:")) failed++;
TestLog.title("IT RUN RESULT (per test)");
for (String s : summaries) System.out.println(s);
@@ -132,6 +132,20 @@ public final class JsonBuilders {
""".formatted(requestId, sessionId, timeMs, signatureB64);
}
// ---------------- ListSubscribedChannels ----------------
public static String listSubscribedChannels(String login) {
String requestId = TestIds.next("subs");
return """
{
"op": "ListSubscribedChannels",
"requestId": "%s",
"payload": { "login": "%s" }
}
""".formatted(requestId, login);
}
/**
* Подпись для режима AUTH_IN_PROGRESS:
* preimage = "AUTHORIFICATED:" + timeMs + authNonce