Skip to content

Commit 2e9f44a

Browse files
Pass existing tests
1 parent a989b53 commit 2e9f44a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

storage/balance_storage_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -565,16 +565,13 @@ func TestBalance(t *testing.T) {
565565
})
566566

567567
t.Run("prune negative index (no-op)", func(t *testing.T) {
568-
txn := storage.db.NewDatabaseTransaction(ctx, true)
569568
err := storage.PruneBalances(
570569
ctx,
571-
txn,
572570
account,
573571
largeDeduction.Currency,
574572
-1,
575573
)
576574
assert.NoError(t, err)
577-
assert.NoError(t, txn.Commit(ctx))
578575

579576
retrievedAmount, err := storage.GetBalance(ctx, account, largeDeduction.Currency, newBlock3)
580577
assert.NoError(t, err)
@@ -596,7 +593,7 @@ func TestBalance(t *testing.T) {
596593
}, retrievedAmount)
597594
})
598595

599-
t.Run("attempt orphan balance with update balance", func(t *testing.T) {
596+
t.Run("update existing balance", func(t *testing.T) {
600597
txn := storage.db.NewDatabaseTransaction(ctx, true)
601598
orphanValue, _ := new(big.Int).SetString(largeDeduction.Value, 10)
602599
err := storage.UpdateBalance(
@@ -610,10 +607,16 @@ func TestBalance(t *testing.T) {
610607
},
611608
nil,
612609
)
613-
assert.Error(t, err)
610+
assert.NoError(t, err)
611+
retrievedAmount, err := storage.GetBalanceTransactional(ctx, txn, account, largeDeduction.Currency, newBlock3)
612+
assert.NoError(t, err)
613+
assert.Equal(t, &types.Amount{
614+
Value: "1200",
615+
Currency: largeDeduction.Currency,
616+
}, retrievedAmount)
614617
txn.Discard(ctx)
615618

616-
retrievedAmount, err := storage.GetBalance(ctx, account, largeDeduction.Currency, newBlock3)
619+
retrievedAmount, err = storage.GetBalance(ctx, account, largeDeduction.Currency, newBlock3)
617620
assert.NoError(t, err)
618621
assert.Equal(t, &types.Amount{
619622
Value: "200",
@@ -649,16 +652,13 @@ func TestBalance(t *testing.T) {
649652
})
650653

651654
t.Run("prune index", func(t *testing.T) {
652-
txn := storage.db.NewDatabaseTransaction(ctx, true)
653655
err := storage.PruneBalances(
654656
ctx,
655-
txn,
656657
account,
657658
largeDeduction.Currency,
658659
newBlock.Index,
659660
)
660661
assert.NoError(t, err)
661-
assert.NoError(t, txn.Commit(ctx))
662662

663663
retrievedAmount, err := storage.GetBalance(ctx, account, largeDeduction.Currency, newBlock3)
664664
assert.NoError(t, err)

0 commit comments

Comments
 (0)