Skip to content

Commit caf164f

Browse files
Tomas-Silva2187RafaelAPB
authored andcommitted
fix(satp): fix for errorType in api tests
Signed-off-by: Tomás Silva <[email protected]> Signed-off-by: Rafael Belchior <[email protected]>
1 parent 76aef41 commit caf164f

File tree

4 files changed

+81
-62
lines changed

4 files changed

+81
-62
lines changed

packages/cactus-plugin-satp-hermes/src/main/typescript/core/session-utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,13 @@ export function setErrorChecking(
762762
return;
763763
}
764764

765+
const errorReformat = new SATPInternalError(
766+
error.message,
767+
error.cause,
768+
error.code,
769+
);
765770
sessionData.state = State.ERROR;
766-
sessionData.errorCode = error.getSATPErrorType();
771+
sessionData.errorCode = errorReformat.getSATPErrorType();
767772
sessionData.phaseError = stageMessage;
768773
}
769774

packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage1-handler.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -523,23 +523,25 @@ export class Stage1SATPHandler implements SATPHandler {
523523
setError(session, MessageType.TRANSFER_COMMENCE_REQUEST, error);
524524

525525
attributes.senderNetworkId =
526-
session?.getServerSessionData().senderAsset?.networkId?.id ||
526+
session?.getClientSessionData()?.senderAsset?.networkId?.id ||
527527
undefined;
528528
attributes.receiverNetworkId =
529-
session?.getServerSessionData().receiverAsset?.networkId?.id ||
529+
session?.getClientSessionData()?.receiverAsset?.networkId?.id ||
530530
undefined;
531531
attributes.senderGatewayNetworkId =
532-
session?.getServerSessionData().senderGatewayNetworkId || undefined;
532+
session?.getClientSessionData()?.senderGatewayNetworkId ||
533+
undefined;
533534
attributes.receiverGatewayNetworkId =
534-
session?.getServerSessionData().recipientGatewayNetworkId ||
535+
session?.getClientSessionData()?.recipientGatewayNetworkId ||
535536
undefined;
536537
attributes.assetProfileId =
537-
session?.getServerSessionData().assetProfileId || undefined;
538+
session?.getClientSessionData()?.assetProfileId || undefined;
538539
attributes.sessionId = session?.getSessionId() || undefined;
539540
attributes.sourceLedgerAssetId =
540-
session?.getServerSessionData().sourceLedgerAssetId || undefined;
541+
session?.getClientSessionData()?.sourceLedgerAssetId || undefined;
541542
attributes.recipientLedgerAssetId =
542-
session?.getServerSessionData().recipientLedgerAssetId || undefined;
543+
session?.getClientSessionData()?.recipientLedgerAssetId ||
544+
undefined;
543545
attributes.satp_phase = 1;
544546

545547
this.monitorService.updateCounter(

packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage2-handler.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,23 +276,25 @@ export class Stage2SATPHandler implements SATPHandler {
276276
setError(session, MessageType.LOCK_ASSERT, error);
277277

278278
attributes.senderNetworkId =
279-
session?.getServerSessionData().senderAsset?.networkId?.id ||
279+
session?.getClientSessionData()?.senderAsset?.networkId?.id ||
280280
undefined;
281281
attributes.receiverNetworkId =
282-
session?.getServerSessionData().receiverAsset?.networkId?.id ||
282+
session?.getClientSessionData()?.receiverAsset?.networkId?.id ||
283283
undefined;
284284
attributes.senderGatewayNetworkId =
285-
session?.getServerSessionData().senderGatewayNetworkId || undefined;
285+
session?.getClientSessionData()?.senderGatewayNetworkId ||
286+
undefined;
286287
attributes.receiverGatewayNetworkId =
287-
session?.getServerSessionData().recipientGatewayNetworkId ||
288+
session?.getClientSessionData()?.recipientGatewayNetworkId ||
288289
undefined;
289290
attributes.assetProfileId =
290-
session?.getServerSessionData().assetProfileId || undefined;
291+
session?.getClientSessionData()?.assetProfileId || undefined;
291292
attributes.sessionId = session?.getSessionId() || undefined;
292293
attributes.sourceLedgerAssetId =
293-
session?.getServerSessionData().sourceLedgerAssetId || undefined;
294+
session?.getClientSessionData()?.sourceLedgerAssetId || undefined;
294295
attributes.recipientLedgerAssetId =
295-
session?.getServerSessionData().recipientLedgerAssetId || undefined;
296+
session?.getClientSessionData()?.recipientLedgerAssetId ||
297+
undefined;
296298
attributes.satp_phase = 2;
297299

298300
this.monitorService.updateCounter(

packages/cactus-plugin-satp-hermes/src/main/typescript/core/stage-handlers/stage3-handler.ts

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -539,23 +539,25 @@ export class Stage3SATPHandler implements SATPHandler {
539539
setError(session, MessageType.COMMIT_PREPARE, error);
540540

541541
attributes.senderNetworkId =
542-
session?.getServerSessionData().senderAsset?.networkId?.id ||
542+
session?.getClientSessionData()?.senderAsset?.networkId?.id ||
543543
undefined;
544544
attributes.receiverNetworkId =
545-
session?.getServerSessionData().receiverAsset?.networkId?.id ||
545+
session?.getClientSessionData()?.receiverAsset?.networkId?.id ||
546546
undefined;
547547
attributes.senderGatewayNetworkId =
548-
session?.getServerSessionData().senderGatewayNetworkId || undefined;
548+
session?.getClientSessionData()?.senderGatewayNetworkId ||
549+
undefined;
549550
attributes.receiverGatewayNetworkId =
550-
session?.getServerSessionData().recipientGatewayNetworkId ||
551+
session?.getClientSessionData()?.recipientGatewayNetworkId ||
551552
undefined;
552553
attributes.assetProfileId =
553-
session?.getServerSessionData().assetProfileId || undefined;
554+
session?.getClientSessionData()?.assetProfileId || undefined;
554555
attributes.sessionId = session?.getSessionId() || undefined;
555556
attributes.sourceLedgerAssetId =
556-
session?.getServerSessionData().sourceLedgerAssetId || undefined;
557+
session?.getClientSessionData()?.sourceLedgerAssetId || undefined;
557558
attributes.recipientLedgerAssetId =
558-
session?.getServerSessionData().recipientLedgerAssetId || undefined;
559+
session?.getClientSessionData()?.recipientLedgerAssetId ||
560+
undefined;
559561
attributes.satp_phase = 3;
560562

561563
this.monitorService.updateCounter(
@@ -644,23 +646,25 @@ export class Stage3SATPHandler implements SATPHandler {
644646
setError(session, MessageType.COMMIT_FINAL, error);
645647

646648
attributes.senderNetworkId =
647-
session?.getServerSessionData().senderAsset?.networkId?.id ||
649+
session?.getClientSessionData()?.senderAsset?.networkId?.id ||
648650
undefined;
649651
attributes.receiverNetworkId =
650-
session?.getServerSessionData().receiverAsset?.networkId?.id ||
652+
session?.getClientSessionData()?.receiverAsset?.networkId?.id ||
651653
undefined;
652654
attributes.senderGatewayNetworkId =
653-
session?.getServerSessionData().senderGatewayNetworkId || undefined;
655+
session?.getClientSessionData()?.senderGatewayNetworkId ||
656+
undefined;
654657
attributes.receiverGatewayNetworkId =
655-
session?.getServerSessionData().recipientGatewayNetworkId ||
658+
session?.getClientSessionData()?.recipientGatewayNetworkId ||
656659
undefined;
657660
attributes.assetProfileId =
658-
session?.getServerSessionData().assetProfileId || undefined;
661+
session?.getClientSessionData()?.assetProfileId || undefined;
659662
attributes.sessionId = session?.getSessionId() || undefined;
660663
attributes.sourceLedgerAssetId =
661-
session?.getServerSessionData().sourceLedgerAssetId || undefined;
664+
session?.getClientSessionData()?.sourceLedgerAssetId || undefined;
662665
attributes.recipientLedgerAssetId =
663-
session?.getServerSessionData().recipientLedgerAssetId || undefined;
666+
session?.getClientSessionData()?.recipientLedgerAssetId ||
667+
undefined;
664668
attributes.satp_phase = 3;
665669

666670
this.monitorService.updateCounter(
@@ -747,23 +751,25 @@ export class Stage3SATPHandler implements SATPHandler {
747751
setError(session, MessageType.ACK_COMMIT_FINAL, error);
748752

749753
attributes.senderNetworkId =
750-
session?.getServerSessionData().senderAsset?.networkId?.id ||
754+
session?.getClientSessionData()?.senderAsset?.networkId?.id ||
751755
undefined;
752756
attributes.receiverNetworkId =
753-
session?.getServerSessionData().receiverAsset?.networkId?.id ||
757+
session?.getClientSessionData()?.receiverAsset?.networkId?.id ||
754758
undefined;
755759
attributes.senderGatewayNetworkId =
756-
session?.getServerSessionData().senderGatewayNetworkId || undefined;
760+
session?.getClientSessionData()?.senderGatewayNetworkId ||
761+
undefined;
757762
attributes.receiverGatewayNetworkId =
758-
session?.getServerSessionData().recipientGatewayNetworkId ||
763+
session?.getClientSessionData()?.recipientGatewayNetworkId ||
759764
undefined;
760765
attributes.assetProfileId =
761-
session?.getServerSessionData().assetProfileId || undefined;
766+
session?.getClientSessionData()?.assetProfileId || undefined;
762767
attributes.sessionId = session?.getSessionId() || undefined;
763768
attributes.sourceLedgerAssetId =
764-
session?.getServerSessionData().sourceLedgerAssetId || undefined;
769+
session?.getClientSessionData()?.sourceLedgerAssetId || undefined;
765770
attributes.recipientLedgerAssetId =
766-
session?.getServerSessionData().recipientLedgerAssetId || undefined;
771+
session?.getClientSessionData()?.recipientLedgerAssetId ||
772+
undefined;
767773
attributes.satp_phase = 3;
768774

769775
this.monitorService.updateCounter(
@@ -824,28 +830,30 @@ export class Stage3SATPHandler implements SATPHandler {
824830

825831
attributes.sessionId = session.getSessionId() || undefined;
826832
attributes.senderNetworkId =
827-
session.getServerSessionData().senderAsset?.networkId?.id ||
833+
session?.getClientSessionData()?.senderAsset?.networkId?.id ||
828834
undefined;
829835
attributes.receiverNetworkId =
830-
session.getServerSessionData().receiverAsset?.networkId?.id ||
836+
session?.getClientSessionData()?.receiverAsset?.networkId?.id ||
831837
undefined;
832838
attributes.senderGatewayNetworkId =
833-
session.getServerSessionData().senderGatewayNetworkId || undefined;
839+
session?.getClientSessionData()?.senderGatewayNetworkId ||
840+
undefined;
834841
attributes.receiverGatewayNetworkId =
835-
session.getServerSessionData().recipientGatewayNetworkId ||
842+
session?.getClientSessionData()?.recipientGatewayNetworkId ||
836843
undefined;
837844
attributes.assetProfileId =
838-
session.getServerSessionData().assetProfileId || undefined;
845+
session?.getClientSessionData()?.assetProfileId || undefined;
839846
attributes.sourceLedgerAssetId =
840-
session.getServerSessionData().sourceLedgerAssetId || undefined;
847+
session?.getClientSessionData()?.sourceLedgerAssetId || undefined;
841848
attributes.recipientLedgerAssetId =
842-
session.getServerSessionData().recipientLedgerAssetId || undefined;
849+
session?.getClientSessionData()?.recipientLedgerAssetId ||
850+
undefined;
843851

844852
const stage0Str =
845-
session.getServerSessionData().receivedTimestamps?.stage0
853+
session?.getClientSessionData()?.processedTimestamps?.stage0
846854
?.newSessionRequestMessageTimestamp;
847855
const stage3Str =
848-
session.getServerSessionData().processedTimestamps?.stage3
856+
session?.getClientSessionData()?.receivedTimestamps?.stage3
849857
?.transferCompleteResponseMessageTimestamp;
850858

851859
if (stage0Str && stage3Str) {
@@ -860,20 +868,20 @@ export class Stage3SATPHandler implements SATPHandler {
860868
"transaction_gas_used",
861869
Number(
862870
JSON.parse(
863-
session.getServerSessionData().senderWrapAssertionClaim
871+
session?.getClientSessionData()?.senderWrapAssertionClaim
864872
?.receipt ?? "{}",
865873
).gas ?? 0,
866874
) +
867875
Number(
868876
JSON.parse(
869-
session.getServerSessionData().lockAssertionClaim?.receipt ??
870-
"{}",
877+
session?.getClientSessionData()?.lockAssertionClaim
878+
?.receipt ?? "{}",
871879
).gas ?? 0,
872880
) +
873881
Number(
874882
JSON.parse(
875-
session.getServerSessionData().burnAssertionClaim?.receipt ??
876-
"{}",
883+
session?.getClientSessionData()?.burnAssertionClaim
884+
?.receipt ?? "{}",
877885
).gas ?? 0,
878886
),
879887
{ ...attributes, side: "client" },
@@ -882,14 +890,14 @@ export class Stage3SATPHandler implements SATPHandler {
882890
"transaction_gas_used",
883891
Number(
884892
JSON.parse(
885-
session.getServerSessionData().receiverWrapAssertionClaim
893+
session?.getClientSessionData()?.receiverWrapAssertionClaim
886894
?.receipt ?? "{}",
887895
).gas ?? 0,
888896
) +
889897
Number(
890898
JSON.parse(
891-
session.getServerSessionData().mintAssertionClaim?.receipt ??
892-
"{}",
899+
session?.getClientSessionData()?.mintAssertionClaim
900+
?.receipt ?? "{}",
893901
).gas ?? 0,
894902
),
895903
{ ...attributes, side: "server" },
@@ -906,12 +914,12 @@ export class Stage3SATPHandler implements SATPHandler {
906914
);
907915
this.monitorService.updateCounter(
908916
"total_value_exchanged",
909-
Number(session.getServerSessionData().senderAsset?.amount),
917+
Number(session?.getClientSessionData()?.senderAsset?.amount),
910918
{ ...attributes, transaction_direction: "sent" },
911919
);
912920
this.monitorService.updateCounter(
913921
"total_value_exchanged",
914-
Number(session.getServerSessionData().receiverAsset?.amount),
922+
Number(session?.getClientSessionData()?.receiverAsset?.amount),
915923
{ ...attributes, transaction_direction: "received" },
916924
);
917925

@@ -934,23 +942,25 @@ export class Stage3SATPHandler implements SATPHandler {
934942
);
935943

936944
attributes.senderNetworkId =
937-
session?.getServerSessionData().senderAsset?.networkId?.id ||
945+
session?.getClientSessionData()?.senderAsset?.networkId?.id ||
938946
undefined;
939947
attributes.receiverNetworkId =
940-
session?.getServerSessionData().receiverAsset?.networkId?.id ||
948+
session?.getClientSessionData()?.receiverAsset?.networkId?.id ||
941949
undefined;
942950
attributes.senderGatewayNetworkId =
943-
session?.getServerSessionData().senderGatewayNetworkId || undefined;
951+
session?.getClientSessionData()?.senderGatewayNetworkId ||
952+
undefined;
944953
attributes.receiverGatewayNetworkId =
945-
session?.getServerSessionData().recipientGatewayNetworkId ||
954+
session?.getClientSessionData()?.recipientGatewayNetworkId ||
946955
undefined;
947956
attributes.assetProfileId =
948-
session?.getServerSessionData().assetProfileId || undefined;
957+
session?.getClientSessionData()?.assetProfileId || undefined;
949958
attributes.sessionId = session?.getSessionId() || undefined;
950959
attributes.sourceLedgerAssetId =
951-
session?.getServerSessionData().sourceLedgerAssetId || undefined;
960+
session?.getClientSessionData()?.sourceLedgerAssetId || undefined;
952961
attributes.recipientLedgerAssetId =
953-
session?.getServerSessionData().recipientLedgerAssetId || undefined;
962+
session?.getClientSessionData()?.recipientLedgerAssetId ||
963+
undefined;
954964
attributes.satp_phase = 3;
955965

956966
this.monitorService.updateCounter(

0 commit comments

Comments
 (0)