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

Function TestApplyRate

model/model_test.go:426–459  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

424}
425
426func TestApplyRate(t *testing.T) {
427 tests := []struct {
428 name string
429 preciseAmount *big.Int
430 rate float64
431 expected *big.Int
432 }{
433 {
434 name: "regular rate",
435 preciseAmount: Int64ToBigInt(1000),
436 rate: 1.5,
437 expected: big.NewInt(1500),
438 },
439 {
440 name: "zero rate defaults to 1",
441 preciseAmount: Int64ToBigInt(1000),
442 rate: 0,
443 expected: big.NewInt(1000),
444 },
445 {
446 name: "rate less than 1",
447 preciseAmount: Int64ToBigInt(1000),
448 rate: 0.5,
449 expected: big.NewInt(500),
450 },
451 }
452
453 for _, tt := range tests {
454 t.Run(tt.name, func(t *testing.T) {
455 result := ApplyRate(tt.preciseAmount, tt.rate)
456 assert.Equal(t, tt.expected, result)
457 })
458 }
459}
460
461func TestTransaction_Validate(t *testing.T) {
462 txn := &Transaction{

Callers

nothing calls this directly

Calls 2

Int64ToBigIntFunction · 0.85
ApplyRateFunction · 0.85

Tested by

no test coverage detected