Skip to content

Commit

Permalink
test: asserting requested balances
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandone committed Aug 30, 2024
1 parent d18e6b5 commit f9a9d93
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion components/ledger/internal/machine/vm/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,8 +1010,11 @@ func TestNeededBalances(t *testing.T) {
require.Equalf(t, []string{"c"}, readLockAccounts, "readlock")
require.Equalf(t, []string{"a", "b", "bounded"}, writeLockAccounts, "writelock")

err = m.ResolveBalances(context.Background(), EmptyStore)
store := mockStore{}
err = m.ResolveBalances(context.Background(), &store)
require.NoError(t, err)

require.Equal(t, []string{"a", "b", "bounded"}, store.RequestedAccounts)
}

func TestNeededBalances2(t *testing.T) {
Expand Down Expand Up @@ -1062,6 +1065,11 @@ send $balance (
require.NoError(t, err)
require.Equal(t, []string{"a"}, wlAccounts)
require.Equal(t, []string{"acc", "b"}, rlAccounts)

store := mockStore{}
err = m.ResolveBalances(context.Background(), &store)
require.NoError(t, err)
require.Equal(t, []string{"acc", "a"}, store.RequestedAccounts)
}

func TestSetTxMeta(t *testing.T) {
Expand Down Expand Up @@ -2295,3 +2303,16 @@ send [COIN 100] (
}
test(t, tc)
}

type mockStore struct {
RequestedAccounts []string
}

func (s *mockStore) GetBalance(ctx context.Context, address, asset string) (*big.Int, error) {
s.RequestedAccounts = append(s.RequestedAccounts, address)
return big.NewInt(0), nil
}

func (s *mockStore) GetAccount(ctx context.Context, address string) (*ledger.Account, error) {
panic("not implemented")
}

0 comments on commit f9a9d93

Please sign in to comment.