(t *testing.T)
| 553 | } |
| 554 | |
| 555 | func TestApplyPrecisionWithEmptyAmount(t *testing.T) { |
| 556 | // Test case where amount is empty but precise amount is provided |
| 557 | t.Run("Convert PreciseAmount to Amount", func(t *testing.T) { |
| 558 | // Set up a big.Int with the exact value |
| 559 | preciseAmount := new(big.Int) |
| 560 | preciseAmount.SetString("922337203684775808", 10) |
| 561 | |
| 562 | // Create transaction with precise amount but no amount |
| 563 | txn := &Transaction{ |
| 564 | PreciseAmount: preciseAmount, |
| 565 | Precision: 10000000000, // 10 billion |
| 566 | // Amount is purposely left as 0 |
| 567 | } |
| 568 | |
| 569 | // Apply precision, which should calculate the amount |
| 570 | result := ApplyPrecision(txn) |
| 571 | |
| 572 | // Check that precise amount remains unchanged |
| 573 | assert.Equal(t, preciseAmount, result) |
| 574 | |
| 575 | // The expected amount should be: |
| 576 | // 922337203684775808 ÷ 10000000000 = 92233720.3684775808 |
| 577 | expectedAmount := 92233720.3684775808 |
| 578 | assert.InDelta(t, expectedAmount, txn.Amount, 0.0000000001) |
| 579 | |
| 580 | // If we've implemented AmountString, verify that too |
| 581 | if txn.AmountString != "" { |
| 582 | expectedAmountString := "92233720.3684775808" |
| 583 | assert.Equal(t, expectedAmountString, txn.AmountString) |
| 584 | } |
| 585 | }) |
| 586 | } |
| 587 | |
| 588 | func TestGenerateKey(t *testing.T) { |
| 589 | key, err := GenerateKey() |
nothing calls this directly
no test coverage detected