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

Function TestApplyTransaction_Credit

database/balance_test.go:2065–2088  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2063}
2064
2065func TestApplyTransaction_Credit(t *testing.T) {
2066 balanceID := "bln_test123"
2067 creditBalance := big.NewInt(1000)
2068 debitBalance := big.NewInt(500)
2069
2070 txn := struct {
2071 PreciseAmount string
2072 Source string
2073 Destination string
2074 CreatedAt time.Time
2075 EffectiveDate time.Time
2076 }{
2077 PreciseAmount: "200",
2078 Source: "other_balance",
2079 Destination: balanceID,
2080 CreatedAt: time.Now(),
2081 EffectiveDate: time.Now(),
2082 }
2083
2084 newCredit, newDebit, err := applyTransaction(txn, balanceID, creditBalance, debitBalance)
2085 assert.NoError(t, err)
2086 assert.Equal(t, int64(1200), newCredit.Int64())
2087 assert.Equal(t, int64(500), newDebit.Int64())
2088}
2089
2090func TestApplyTransaction_InvalidAmount(t *testing.T) {
2091 balanceID := "bln_test123"

Callers

nothing calls this directly

Calls 1

applyTransactionFunction · 0.85

Tested by

no test coverage detected