test chat messages by configuration

This commit is contained in:
woodser 2024-04-26 15:00:01 -04:00
parent 897d43dfba
commit 7046924f40

View File

@ -143,6 +143,7 @@ const defaultTradeConfig: Partial<TradeContext> = {
disputeSummary: "Seller is winner",
walletSyncPeriodMs: 5000,
maxTimePeerNoticeMs: 5000,
testChatMessages: true,
stopOnFailure: true,
testPayoutConfirmed: true,
testPayoutUnlocked: false,
@ -218,6 +219,7 @@ class TradeContext {
sellerOpenedDispute?: boolean;
walletSyncPeriodMs: number;
maxTimePeerNoticeMs: number;
testChatMessages: boolean;
stopOnFailure?: boolean;
buyerAppName?: string;
sellerAppName?: string;
@ -2924,6 +2926,9 @@ async function testOpenDispute(ctxP: Partial<TradeContext>) {
await ctx.getDisputePeer()!.havenod!.addNotificationListener(notification => { HavenoUtils.log(3, "Dispute peer received notification " + notification.getType() + " " + (notification.getChatMessage() ? notification.getChatMessage()?.getMessage() : "")); disputePeerNotifications.push(notification); });
await arbitrator.addNotificationListener(notification => { HavenoUtils.log(3, "Arbitrator received notification " + notification.getType() + " " + (notification.getChatMessage() ? notification.getChatMessage()?.getMessage() : "")); arbitratorNotifications.push(notification); });
// test chat messages
if (ctx.testChatMessages) {
// arbitrator sends chat messages to traders
HavenoUtils.log(1, "Arbitrator sending chat messages to traders. tradeId=" + ctx.offerId + ", disputeId=" + openerDispute.getId());
await ctx.arbitrator.havenod!.sendDisputeChatMessage(arbDisputeOpener!.getId(), "Arbitrator chat message to dispute opener", []);
@ -2984,6 +2989,7 @@ async function testOpenDispute(ctxP: Partial<TradeContext>) {
expect(attachments[1].getBytes()).toEqual(bytes2);
expect(chatNotifications[1].getChatMessage()?.getMessage()).toEqual("Dispute peer chat message");
}
}
async function resolveDispute(ctxP: Partial<TradeContext>) {
let ctx = TradeContext.init(ctxP);