testwalletapi

package
v0.0.0-...-05bc493 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2023 License: MIT, Apache-2.0 Imports: 21 Imported by: 0

README

#Description of TestWalletAPI

It's http API. It accepts POST requests. Parameters are expected from POST body in JSON format.
Different method are divided by different locations.

#Errors If invalid JSON is received or not all parameters are given, API returns "Bad request"( http code 400 ).
If any internal error happens it will be returned in field "error". The structure of the value will be declared later.

#Minimum output

{
    "error": null,
    "traceID": "144b8072ca1d141a3e8d1b81ac8e5888"
}

#Examples

  • Create wallet
    curl "127.0.0.1:32301/wallet/create"
  • Transfer amount from one wallet to another
    curl -X POST -d '{"from":"testFROM", "to": "testTO", "amount": 100}' "127.0.0.1:32301/wallet/transfer"
  • Get balance of given wallet curl -X POST -d '{ "walletRef": "testRef" }' "127.0.0.1:32304/wallet/get_balance"
  • Add amount to given wallet curl -X POST -d '{ "to": "testRef", "amount": 10 }' "127.0.0.1:32304/wallet/add_amount"
  • Delete wallet curl -X POST -d '{ "walletRef": "testRef" }' "127.0.0.1:32304/wallet/delete"

Documentation

Index

Constants

View Source
const (
	APIRequestTimeout = 25 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddAmountParams

type AddAmountParams struct {
	To     string
	Amount uint
}

type DeleteParams

type DeleteParams struct {
	WalletRef string
}

type GetBalanceParams

type GetBalanceParams struct {
	WalletRef string
}

type TestWalletServer

type TestWalletServer struct {
	// contains filtered or unexported fields
}

func NewTestWalletServer

func NewTestWalletServer(logger log.Logger, api configuration.TestWalletAPI, feeder conveyor.EventInputer, accessor beat.History) *TestWalletServer

func (*TestWalletServer) AddAmount

func (s *TestWalletServer) AddAmount(w http.ResponseWriter, req *http.Request)

func (*TestWalletServer) Create

func (s *TestWalletServer) Create(w http.ResponseWriter, req *http.Request)

func (*TestWalletServer) Delete

func (s *TestWalletServer) Delete(w http.ResponseWriter, req *http.Request)

func (*TestWalletServer) GetBalance

func (s *TestWalletServer) GetBalance(w http.ResponseWriter, req *http.Request)

func (*TestWalletServer) GetBalanceValidated

func (s *TestWalletServer) GetBalanceValidated(w http.ResponseWriter, req *http.Request)

func (*TestWalletServer) NodeReadyMiddleware

func (s *TestWalletServer) NodeReadyMiddleware(next http.Handler) http.Handler

NodeReadyMiddleware returns 503 ServiceUnavailable until node is ready

func (*TestWalletServer) RegisterHandlers

func (s *TestWalletServer) RegisterHandlers(httpServerMux *http.ServeMux)

func (*TestWalletServer) Start

func (s *TestWalletServer) Start(ctx context.Context) error

func (*TestWalletServer) Stop

func (s *TestWalletServer) Stop(ctx context.Context) error

func (*TestWalletServer) Transfer

func (s *TestWalletServer) Transfer(w http.ResponseWriter, req *http.Request)

type TestWalletServerAddAmountResult

type TestWalletServerAddAmountResult struct {
	TraceID string `json:"traceID"`
	Error   string `json:"error"`
}

type TestWalletServerCreateResult

type TestWalletServerCreateResult struct {
	Reference string `json:"reference"`
	TraceID   string `json:"traceID"`
	Error     string `json:"error"`
}

type TestWalletServerDeleteResult

type TestWalletServerDeleteResult struct {
	TraceID string `json:"traceID"`
	Error   string `json:"error"`
}

type TestWalletServerGetBalanceResult

type TestWalletServerGetBalanceResult struct {
	Amount  uint   `json:"amount"`
	TraceID string `json:"traceID"`
	Error   string `json:"error"`
}

type TestWalletServerTransferResult

type TestWalletServerTransferResult struct {
	TraceID string `json:"traceID"`
	Error   string `json:"error"`
}

type TransferParams

type TransferParams struct {
	From   string
	To     string
	Amount uint
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL