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

Function TestUpdateBalancesWithTransaction

balance_test.go:61–149  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestUpdateBalancesWithTransaction(t *testing.T) {
62 tests := []struct {
63 name string
64 sourceBalance *model.Balance
65 ExpectedError error
66 destinationBalance *model.Balance
67 transaction model.Transaction
68 want struct {
69 SourceBalance *big.Int
70 SourceCreditBalance *big.Int
71 SourceDebitBalance *big.Int
72 DestinationBalance *big.Int
73 DestinationCreditBalance *big.Int
74 DestinationDebitBalance *big.Int
75 SourceIndicator string
76 DestinationIndicator string
77 }
78 }{
79 {
80 name: "Send 1k from destination to source balance.",
81 ExpectedError: nil,
82 sourceBalance: getBalanceMock(big.NewInt(2500), big.NewInt(0), big.NewInt(2500), "source-indicator"),
83 destinationBalance: getBalanceMock(big.NewInt(0), big.NewInt(0), big.NewInt(0), "destination-indicator"),
84 transaction: getTransactionMock(1000, false),
85 want: struct {
86 SourceBalance *big.Int
87 SourceCreditBalance *big.Int
88 SourceDebitBalance *big.Int
89 DestinationBalance *big.Int
90 DestinationCreditBalance *big.Int
91 DestinationDebitBalance *big.Int
92 SourceIndicator string
93 DestinationIndicator string
94 }{
95 SourceBalance: big.NewInt(1500),
96 SourceDebitBalance: big.NewInt(1000),
97 SourceCreditBalance: big.NewInt(2500),
98 DestinationBalance: big.NewInt(1000),
99 DestinationDebitBalance: big.NewInt(0),
100 DestinationCreditBalance: big.NewInt(1000),
101 SourceIndicator: "source-indicator",
102 DestinationIndicator: "destination-indicator",
103 },
104 },
105 {
106 name: "Debit 900m from source with start balance of 2.5b and debit balance of 500m. And destination start balance of 5k",
107 ExpectedError: nil,
108 sourceBalance: getBalanceMock(big.NewInt(2500000000), big.NewInt(500000000), big.NewInt(2500000000), "source-indicator"),
109 destinationBalance: getBalanceMock(big.NewInt(5000), big.NewInt(0), big.NewInt(5000), "destination-indicator"),
110 transaction: getTransactionMock(900000000, false),
111 want: struct {
112 SourceBalance *big.Int
113 SourceCreditBalance *big.Int
114 SourceDebitBalance *big.Int
115 DestinationBalance *big.Int
116 DestinationCreditBalance *big.Int
117 DestinationDebitBalance *big.Int
118 SourceIndicator string

Callers

nothing calls this directly

Calls 3

UpdateBalancesFunction · 0.92
getBalanceMockFunction · 0.85
getTransactionMockFunction · 0.85

Tested by

no test coverage detected