Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

[Issue #2] export test service #3

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ import (
)

type testEnv struct {
v4Server *server
v4Server *TestServer
conn *grpc.ClientConn
internal *InternalClient
client *client
}

func setup(t *testing.T, opts ...ClientOption) (*testEnv, func()) {
env := &testEnv{
v4Server: newServer(),
v4Server: NewTestServer(),
}

conn, serv, err := agoratestutil.NewServer(
Expand Down Expand Up @@ -900,7 +900,7 @@ func TestInternal_ResolveTokenAccounts_WithInfo(t *testing.T) {
}
}

func setServiceConfigResp(t *testing.T, server *server, includeSubsidizer bool) (token, tokenProgram, subsidizer ed25519.PublicKey) {
func setServiceConfigResp(t *testing.T, server *TestServer, includeSubsidizer bool) (token, tokenProgram, subsidizer ed25519.PublicKey) {
var err error
token, _, err = ed25519.GenerateKey(nil)
require.NoError(t, err)
Expand Down
36 changes: 18 additions & 18 deletions client/test_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var RecentBlockhash = bytes.Repeat([]byte{1}, 32)
var MinBalanceForRentException = uint64(1234567)
var MaxAirdrop = uint64(100000)

type server struct {
type TestServer struct {
Mux sync.Mutex
Errors []error

Expand All @@ -47,15 +47,15 @@ type server struct {
EventsResponses []*accountpbv4.Events
}

func newServer() *server {
return &server{
func NewTestServer() *TestServer {
return &TestServer{
Accounts: make(map[string]*accountpbv4.AccountInfo),
TokenAccounts: make(map[string][]*commonpbv4.SolanaAccountId),
Gets: make(map[string]transactionpbv4.GetTransactionResponse),
}
}

func (t *server) CreateAccount(ctx context.Context, req *accountpbv4.CreateAccountRequest) (*accountpbv4.CreateAccountResponse, error) {
func (t *TestServer) CreateAccount(ctx context.Context, req *accountpbv4.CreateAccountRequest) (*accountpbv4.CreateAccountResponse, error) {
t.Mux.Lock()
defer t.Mux.Unlock()

Expand Down Expand Up @@ -125,7 +125,7 @@ func (t *server) CreateAccount(ctx context.Context, req *accountpbv4.CreateAccou
}, nil
}

func (t *server) GetAccountInfo(ctx context.Context, req *accountpbv4.GetAccountInfoRequest) (*accountpbv4.GetAccountInfoResponse, error) {
func (t *TestServer) GetAccountInfo(ctx context.Context, req *accountpbv4.GetAccountInfoRequest) (*accountpbv4.GetAccountInfoResponse, error) {
t.Mux.Lock()
defer t.Mux.Unlock()

Expand All @@ -145,7 +145,7 @@ func (t *server) GetAccountInfo(ctx context.Context, req *accountpbv4.GetAccount
}, nil
}

func (t *server) ResolveTokenAccounts(ctx context.Context, req *accountpbv4.ResolveTokenAccountsRequest) (*accountpbv4.ResolveTokenAccountsResponse, error) {
func (t *TestServer) ResolveTokenAccounts(ctx context.Context, req *accountpbv4.ResolveTokenAccountsRequest) (*accountpbv4.ResolveTokenAccountsResponse, error) {
t.Mux.Lock()
defer t.Mux.Unlock()

Expand Down Expand Up @@ -186,7 +186,7 @@ func (t *server) ResolveTokenAccounts(ctx context.Context, req *accountpbv4.Reso
return resp, nil
}

func (t *server) GetEvents(req *accountpbv4.GetEventsRequest, stream accountpbv4.Account_GetEventsServer) error {
func (t *TestServer) GetEvents(req *accountpbv4.GetEventsRequest, stream accountpbv4.Account_GetEventsServer) error {
t.Mux.Lock()
defer t.Mux.Unlock()

Expand All @@ -210,7 +210,7 @@ func (t *server) GetEvents(req *accountpbv4.GetEventsRequest, stream accountpbv4
return nil
}

func (t *server) GetServiceConfig(ctx context.Context, req *transactionpbv4.GetServiceConfigRequest) (*transactionpbv4.GetServiceConfigResponse, error) {
func (t *TestServer) GetServiceConfig(ctx context.Context, req *transactionpbv4.GetServiceConfigRequest) (*transactionpbv4.GetServiceConfigResponse, error) {
t.Mux.Lock()
defer t.Mux.Unlock()

Expand All @@ -222,35 +222,35 @@ func (t *server) GetServiceConfig(ctx context.Context, req *transactionpbv4.GetS
return t.ServiceConfig, nil
}

func (t *server) GetMinimumKinVersion(ctx context.Context, req *transactionpbv4.GetMinimumKinVersionRequest) (*transactionpbv4.GetMinimumKinVersionResponse, error) {
func (t *TestServer) GetMinimumKinVersion(ctx context.Context, req *transactionpbv4.GetMinimumKinVersionRequest) (*transactionpbv4.GetMinimumKinVersionResponse, error) {
if err := validateV4Headers(ctx); err != nil {
return nil, err
}

return &transactionpbv4.GetMinimumKinVersionResponse{Version: 4}, nil
}

func (t *server) GetRecentBlockhash(ctx context.Context, req *transactionpbv4.GetRecentBlockhashRequest) (*transactionpbv4.GetRecentBlockhashResponse, error) {
func (t *TestServer) GetRecentBlockhash(ctx context.Context, req *transactionpbv4.GetRecentBlockhashRequest) (*transactionpbv4.GetRecentBlockhashResponse, error) {
if err := validateV4Headers(ctx); err != nil {
return nil, err
}

return &transactionpbv4.GetRecentBlockhashResponse{Blockhash: &commonpbv4.Blockhash{Value: RecentBlockhash}}, nil
}

func (t *server) GetMinimumBalanceForRentExemption(ctx context.Context, req *transactionpbv4.GetMinimumBalanceForRentExemptionRequest) (*transactionpbv4.GetMinimumBalanceForRentExemptionResponse, error) {
func (t *TestServer) GetMinimumBalanceForRentExemption(ctx context.Context, req *transactionpbv4.GetMinimumBalanceForRentExemptionRequest) (*transactionpbv4.GetMinimumBalanceForRentExemptionResponse, error) {
if err := validateV4Headers(ctx); err != nil {
return nil, err
}

return &transactionpbv4.GetMinimumBalanceForRentExemptionResponse{Lamports: MinBalanceForRentException}, nil
}

func (t *server) GetHistory(context.Context, *transactionpbv4.GetHistoryRequest) (*transactionpbv4.GetHistoryResponse, error) {
func (t *TestServer) GetHistory(context.Context, *transactionpbv4.GetHistoryRequest) (*transactionpbv4.GetHistoryResponse, error) {
return nil, status.Error(codes.Unimplemented, "")
}

func (t *server) SignTransaction(ctx context.Context, req *transactionpbv4.SignTransactionRequest) (*transactionpbv4.SignTransactionResponse, error) {
func (t *TestServer) SignTransaction(ctx context.Context, req *transactionpbv4.SignTransactionRequest) (*transactionpbv4.SignTransactionResponse, error) {
t.Mux.Lock()
defer t.Mux.Unlock()

Expand Down Expand Up @@ -293,7 +293,7 @@ func (t *server) SignTransaction(ctx context.Context, req *transactionpbv4.SignT
}, nil
}

func (t *server) SubmitTransaction(ctx context.Context, req *transactionpbv4.SubmitTransactionRequest) (*transactionpbv4.SubmitTransactionResponse, error) {
func (t *TestServer) SubmitTransaction(ctx context.Context, req *transactionpbv4.SubmitTransactionRequest) (*transactionpbv4.SubmitTransactionResponse, error) {
t.Mux.Lock()
defer t.Mux.Unlock()

Expand Down Expand Up @@ -336,7 +336,7 @@ func (t *server) SubmitTransaction(ctx context.Context, req *transactionpbv4.Sub
}, nil
}

func (t *server) GetTransaction(ctx context.Context, req *transactionpbv4.GetTransactionRequest) (*transactionpbv4.GetTransactionResponse, error) {
func (t *TestServer) GetTransaction(ctx context.Context, req *transactionpbv4.GetTransactionRequest) (*transactionpbv4.GetTransactionResponse, error) {
t.Mux.Lock()
defer t.Mux.Unlock()

Expand All @@ -357,7 +357,7 @@ func (t *server) GetTransaction(ctx context.Context, req *transactionpbv4.GetTra
}, nil
}

func (t *server) RequestAirdrop(ctx context.Context, req *airdrop.RequestAirdropRequest) (*airdrop.RequestAirdropResponse, error) {
func (t *TestServer) RequestAirdrop(ctx context.Context, req *airdrop.RequestAirdropRequest) (*airdrop.RequestAirdropResponse, error) {
t.Mux.Lock()
defer t.Mux.Unlock()

Expand Down Expand Up @@ -385,7 +385,7 @@ func (t *server) RequestAirdrop(ctx context.Context, req *airdrop.RequestAirdrop
}, nil
}

func (t *server) SetError(err error, n int) {
func (t *TestServer) SetError(err error, n int) {
t.Mux.Lock()
defer t.Mux.Unlock()

Expand All @@ -395,7 +395,7 @@ func (t *server) SetError(err error, n int) {
}
}

func (t *server) GetError() error {
func (t *TestServer) GetError() error {
if len(t.Errors) == 0 {
return nil
}
Expand Down