Skip to content

Commit

Permalink
all: enforce simplified Golang code
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Apr 20, 2023
1 parent 602c3c4 commit cf1ce3c
Show file tree
Hide file tree
Showing 20 changed files with 191 additions and 191 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ regulated-assets-approval-server:

gxdr/xdr_generated.go: $(XDRS)
go run github.com/xdrpp/goxdr/cmd/goxdr -p gxdr -enum-comments -o $@ $(XDRS)
go fmt $@
gofmt -s -w $@

xdr/%.x:
curl -Lsf -o $@ https://raw.githubusercontent.com/stellar/stellar-core/master/src/protocol-curr/$@
Expand All @@ -46,7 +46,7 @@ xdr/xdr_generated.go: $(XDRS)
--namespace xdr \
--output xdr/ \
$(XDRS)'
go fmt $@
gofmt -s -w $@

xdr: gxdr/xdr_generated.go xdr/xdr_generated.go

Expand Down
2 changes: 1 addition & 1 deletion exp/orderbook/graph_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func BenchmarkLiquidityPoolExpectations(b *testing.B) {

func createRandomAmounts(quantity int) []xdr.Int64 {
amounts := make([]xdr.Int64, quantity)
for i, _ := range amounts {
for i := range amounts {
amounts[i] = xdr.Int64(1 + rand.Int63n(math.MaxInt64-100))
}
return amounts
Expand Down
2 changes: 1 addition & 1 deletion exp/orderbook/graph_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func assertGraphEquals(t *testing.T, a, b *OrderBookGraph) {
assert.Equalf(t, len(a.liquidityPools), len(b.liquidityPools),
"expected same # of liquidity pools but got %v %v", a, b)

for assetString, _ := range a.assetStringToID {
for assetString := range a.assetStringToID {
asset := a.assetStringToID[assetString]
otherAsset, ok := b.assetStringToID[assetString]
if !ok {
Expand Down
26 changes: 13 additions & 13 deletions exp/services/market-tracker/calc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestCalcSpread(t *testing.T) {

func TestCalcSpreadPctAtDepth(t *testing.T) {
bids := []usdOrder{
usdOrder{
{
xlmAmount: 100.0,
usdAmount: 10.0,
usdPrice: 10.0,
Expand Down Expand Up @@ -134,35 +134,35 @@ func TestCalcBestOrderAtDepth(t *testing.T) {

func TestCalcSlippageAtDepth(t *testing.T) {
bids := []usdOrder{
usdOrder{
{
xlmAmount: 1.,
usdAmount: 30.,
usdPrice: 30.,
},
usdOrder{
{
xlmAmount: 1.,
usdAmount: 25.,
usdPrice: 25.,
},
usdOrder{
{
xlmAmount: 1.,
usdAmount: 50.,
usdPrice: 20.,
},
}

asks := []usdOrder{
usdOrder{
{
xlmAmount: 5.,
usdAmount: 100.,
usdPrice: 20.,
},
usdOrder{
{
xlmAmount: 4.,
usdAmount: 100.,
usdPrice: 25.,
},
usdOrder{
{
xlmAmount: 4.,
usdAmount: 120.,
usdPrice: 30.,
Expand Down Expand Up @@ -209,35 +209,35 @@ func TestCalcAvgPriceAtDepth(t *testing.T) {

func TestCalcFairValuePct(t *testing.T) {
bids := []usdOrder{
usdOrder{
{
xlmAmount: 1.,
usdAmount: 30.,
usdPrice: 30.,
},
usdOrder{
{
xlmAmount: 1.,
usdAmount: 25.,
usdPrice: 25.,
},
usdOrder{
{
xlmAmount: 1.,
usdAmount: 50.,
usdPrice: 20.,
},
}

asks := []usdOrder{
usdOrder{
{
xlmAmount: 5.,
usdAmount: 100.,
usdPrice: 20.,
},
usdOrder{
{
xlmAmount: 4.,
usdAmount: 100.,
usdPrice: 25.,
},
usdOrder{
{
xlmAmount: 4.,
usdAmount: 120.,
usdPrice: 30.,
Expand Down
2 changes: 1 addition & 1 deletion exp/services/market-tracker/orders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert"
)

var badAmtOrders = []hProtocol.PriceLevel{hProtocol.PriceLevel{
var badAmtOrders = []hProtocol.PriceLevel{{
PriceR: hProtocol.Price{
N: 4,
D: 2,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gofmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

printf "Running gofmt checks...\n"
OUTPUT=$(gofmt -d .)
OUTPUT=$(gofmt -d -s .)

if [[ $OUTPUT ]]; then
printf "gofmt found unformatted files:\n\n"
Expand Down
4 changes: 2 additions & 2 deletions services/horizon/internal/db2/history/account_signers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ func TestMultipleAccountsForSigner(t *testing.T) {
tt.Assert.Equal(int64(1), rowsAffected)

expected := []AccountSigner{
AccountSigner{
{
Account: account,
Signer: signer,
Weight: weight,
},
AccountSigner{
{
Account: anotherAccount,
Signer: signer,
Weight: anotherWeight,
Expand Down
8 changes: 4 additions & 4 deletions services/horizon/internal/db2/history/participants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ func TestTransactionParticipantsBatch(t *testing.T) {
participants := getTransactionParticipants(tt, q)
tt.Assert.Equal(
[]transactionParticipant{
transactionParticipant{TransactionID: 1, AccountID: 100},
transactionParticipant{TransactionID: 1, AccountID: 101},
transactionParticipant{TransactionID: 1, AccountID: 102},
transactionParticipant{TransactionID: 2, AccountID: 100},
{TransactionID: 1, AccountID: 100},
{TransactionID: 1, AccountID: 101},
{TransactionID: 1, AccountID: 102},
{TransactionID: 2, AccountID: 100},
},
participants,
)
Expand Down
Loading

0 comments on commit cf1ce3c

Please sign in to comment.