(t *testing.T)
| 1038 | } |
| 1039 | |
| 1040 | func TestLineageE2E_GetTransactionLineage_API(t *testing.T) { |
| 1041 | ctx := context.Background() |
| 1042 | mockDS := new(mocks.MockDataSource) |
| 1043 | |
| 1044 | mainTxn := &model.Transaction{ |
| 1045 | TransactionID: "txn_main_123", |
| 1046 | Source: "bln_alice_main", |
| 1047 | Destination: "bln_merchant", |
| 1048 | Amount: 70, |
| 1049 | Currency: "USD", |
| 1050 | Status: "APPLIED", |
| 1051 | MetaData: map[string]interface{}{ |
| 1052 | "LEDGERFORGE_FUND_ALLOCATION": []interface{}{ |
| 1053 | map[string]interface{}{"provider": "stripe", "amount": float64(50)}, |
| 1054 | map[string]interface{}{"provider": "paypal", "amount": float64(20)}, |
| 1055 | }, |
| 1056 | }, |
| 1057 | } |
| 1058 | |
| 1059 | shadowTxns := []model.Transaction{ |
| 1060 | { |
| 1061 | TransactionID: "txn_shadow_1", |
| 1062 | Source: "bln_alice_aggregate", |
| 1063 | Destination: "bln_stripe_shadow", |
| 1064 | Amount: 50, |
| 1065 | MetaData: map[string]interface{}{ |
| 1066 | "_shadow_for": "txn_main_123", |
| 1067 | "_provider": "stripe", |
| 1068 | "_lineage_type": "release", |
| 1069 | }, |
| 1070 | }, |
| 1071 | { |
| 1072 | TransactionID: "txn_shadow_2", |
| 1073 | Source: "bln_alice_aggregate", |
| 1074 | Destination: "bln_paypal_shadow", |
| 1075 | Amount: 20, |
| 1076 | MetaData: map[string]interface{}{ |
| 1077 | "_shadow_for": "txn_main_123", |
| 1078 | "_provider": "paypal", |
| 1079 | "_lineage_type": "release", |
| 1080 | }, |
| 1081 | }, |
| 1082 | } |
| 1083 | |
| 1084 | mockDS.On("GetTransaction", mock.Anything, "txn_main_123").Return(mainTxn, nil) |
| 1085 | mockDS.On("GetTransactionsByShadowFor", mock.Anything, "txn_main_123").Return(shadowTxns, nil) |
| 1086 | |
| 1087 | ledgerforgeInstance := &LedgerForge{datasource: mockDS} |
| 1088 | |
| 1089 | t.Run("Get transaction lineage returns fund allocation and shadow txns", func(t *testing.T) { |
| 1090 | lineage, err := ledgerforgeInstance.GetTransactionLineage(ctx, "txn_main_123") |
| 1091 | assert.NoError(t, err) |
| 1092 | assert.NotNil(t, lineage) |
| 1093 | |
| 1094 | assert.Equal(t, "txn_main_123", lineage.TransactionID) |
| 1095 | |
| 1096 | assert.Len(t, lineage.FundAllocation, 2) |
| 1097 | assert.Equal(t, "stripe", lineage.FundAllocation[0]["provider"]) |
nothing calls this directly
no test coverage detected