MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestProcessLineageFromOutbox

Function TestProcessLineageFromOutbox

lineage_test.go:1248–1323  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1246}
1247
1248func TestProcessLineageFromOutbox(t *testing.T) {
1249 ctx := context.Background()
1250
1251 t.Run("Successfully processes outbox entry", func(t *testing.T) {
1252 mockDS := new(mocks.MockDataSource)
1253
1254 txn := &model.Transaction{
1255 TransactionID: "txn_123",
1256 Source: "bln_source",
1257 Destination: "bln_dest",
1258 PreciseAmount: big.NewInt(10000),
1259 Currency: "USD",
1260 MetaData: map[string]interface{}{},
1261 }
1262
1263 sourceBalance := &model.Balance{
1264 BalanceID: "bln_source",
1265 TrackFundLineage: false,
1266 }
1267 destBalance := &model.Balance{
1268 BalanceID: "bln_dest",
1269 TrackFundLineage: false,
1270 }
1271
1272 entry := model.LineageOutbox{
1273 ID: 1,
1274 TransactionID: "txn_123",
1275 SourceBalanceID: "bln_source",
1276 DestinationBalanceID: "bln_dest",
1277 LineageType: "debit",
1278 Payload: []byte(`{"amount":100,"currency":"USD"}`),
1279 }
1280
1281 mockDS.On("GetTransaction", mock.Anything, "txn_123").Return(txn, nil)
1282 mockDS.On("GetBalanceByIDLite", "bln_source").Return(sourceBalance, nil)
1283 mockDS.On("GetBalanceByIDLite", "bln_dest").Return(destBalance, nil)
1284
1285 ledgerforgeInstance := &LedgerForge{datasource: mockDS}
1286
1287 err := ledgerforgeInstance.ProcessLineageFromOutbox(ctx, entry)
1288 assert.NoError(t, err)
1289 })
1290
1291 t.Run("Handles missing source balance gracefully", func(t *testing.T) {
1292 mockDS := new(mocks.MockDataSource)
1293
1294 txn := &model.Transaction{
1295 TransactionID: "txn_123",
1296 PreciseAmount: big.NewInt(10000),
1297 MetaData: map[string]interface{}{},
1298 }
1299
1300 destBalance := &model.Balance{
1301 BalanceID: "bln_dest",
1302 TrackFundLineage: false,
1303 }
1304
1305 entry := model.LineageOutbox{

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected