diff --git a/clients/stellarcore/client_test.go b/clients/stellarcore/client_test.go index 6cfd01b210..5bea23bd65 100644 --- a/clients/stellarcore/client_test.go +++ b/clients/stellarcore/client_test.go @@ -6,9 +6,12 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/stellar/go/keypair" proto "github.com/stellar/go/protocols/stellarcore" "github.com/stellar/go/support/http/httptest" + "github.com/stellar/go/xdr" ) func TestSubmitTransaction(t *testing.T) { @@ -75,3 +78,28 @@ func TestManualClose_NotAvailable(t *testing.T) { assert.EqualError(t, err, "exception in response: Set MANUAL_CLOSE=true") } + +func TestGetLedgerEntries(t *testing.T) { + hmock := httptest.NewClient() + c := &Client{HTTP: hmock, URL: "http://localhost:11626"} + + // happy path - new transaction + hmock.On("GET", "http://localhost:11626/getledgerentry"). + ReturnString(http.StatusOK, + `{"ledger": 1234, "entries": [ {"e": "pretend it's xdr lol", "state": "Dead" }]}`, + ) + + var key xdr.LedgerKey + acc, err := xdr.AddressToAccountId(keypair.MustRandom().Address()) + require.NoError(t, err) + key.SetAccount(acc) + + resp, err := c.GetLedgerEntries(context.Background(), 1234, key) + require.NoError(t, err) + + require.EqualValues(t, 1234, resp.Ledger) + require.Len(t, resp.Entries, 1) + require.Equal(t, resp.Entries[0].State, proto.DeadState) + + require.EqualError(t, err, "exception in response: Set MANUAL_CLOSE=true") +}