Skip to content

Commit 2e47eea

Browse files
authored
formatting (#2)
1 parent 68be225 commit 2e47eea

11 files changed

Lines changed: 68 additions & 66 deletions

File tree

workload/bin/cmds/anytime_version_upgrade/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func main() {
3434
panic(err)
3535
}
3636

37-
gvr := schema.GroupVersionResource {
37+
gvr := schema.GroupVersionResource{
3838
Group: "formance.com",
3939
Version: "v1beta1",
4040
Resource: "ledgers",
@@ -53,6 +53,6 @@ func main() {
5353

5454
assert.Sometimes(err == nil, "stack0-ledger should successfully be updated", internal.Details{
5555
"ledger": res,
56-
"error": err,
56+
"error": err,
5757
})
5858
}

workload/bin/cmds/eventually_correct/main.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"sync"
99

1010
"github.com/antithesishq/antithesis-sdk-go/assert"
11+
"github.com/formancehq/dst/workload/internal"
1112
client "github.com/formancehq/formance-sdk-go/v3"
1213
"github.com/formancehq/formance-sdk-go/v3/pkg/models/operations"
13-
"github.com/formancehq/dst/workload/internal"
1414
)
1515

1616
func main() {
@@ -20,7 +20,7 @@ func main() {
2020

2121
ledgers, err := client.Ledger.V2.ListLedgers(ctx, operations.V2ListLedgersRequest{})
2222

23-
assert.Sometimes(err == nil, "error listing ledgers", internal.Details {
23+
assert.Sometimes(err == nil, "error listing ledgers", internal.Details{
2424
"error": err,
2525
})
2626
if err != nil {
@@ -49,7 +49,7 @@ func checkBalanced(ctx context.Context, client *client.Formance, ledger string)
4949
"Client can aggregate balances",
5050
internal.Details{
5151
"ledger": ledger,
52-
"error": err,
52+
"error": err,
5353
},
5454
)
5555
if err != nil {
@@ -62,7 +62,7 @@ func checkBalanced(ctx context.Context, client *client.Formance, ledger string)
6262
fmt.Sprintf("aggregated volumes for asset %s should be 0",
6363
asset,
6464
), internal.Details{
65-
"asset": asset,
65+
"asset": asset,
6666
"volumes": volumes,
6767
})
6868
}
@@ -74,19 +74,19 @@ func checkAccountBalances(ctx context.Context, client *client.Formance, ledger s
7474
for i := range internal.USER_ACCOUNT_COUNT {
7575
address := fmt.Sprintf("users:%d", i)
7676
account, err := client.Ledger.V2.GetAccount(ctx, operations.V2GetAccountRequest{
77-
Ledger: ledger,
77+
Ledger: ledger,
7878
Address: address,
7979
})
8080
assert.Sometimes(err == nil, "Client can aggregate account balances", internal.Details{
81-
"ledger": ledger,
81+
"ledger": ledger,
8282
"address": address,
83-
"error": err,
83+
"error": err,
8484
})
8585
if err != nil {
8686
continue
8787
}
8888
internal.CheckVolumes(account.V2AccountResponse.Data.Volumes, nil, internal.Details{
89-
"ledger": ledger,
89+
"ledger": ledger,
9090
"address": address,
9191
})
9292
}
@@ -96,22 +96,22 @@ func checkAccountBalances(ctx context.Context, client *client.Formance, ledger s
9696

9797
func checkNeverAccounts(ctx context.Context, client *client.Formance, ledger string) {
9898
txs, err := client.Ledger.V2.ListTransactions(ctx, operations.V2ListTransactionsRequest{
99-
Ledger: ledger,
99+
Ledger: ledger,
100100
RequestBody: map[string]interface{}{
101101
"$match": map[string]any{
102102
"address": "never:",
103103
},
104104
},
105105
})
106-
assert.Sometimes(err == nil, "should be able to get the latest transaction", internal.Details {
106+
assert.Sometimes(err == nil, "should be able to get the latest transaction", internal.Details{
107107
"error": err,
108108
})
109109
if err != nil {
110110
return
111111
}
112112

113-
assert.Always(len(txs.V2TransactionsCursorResponse.Cursor.Data) == 0, "no transaction should involve never:* accounts", internal.Details {
114-
"ledger": ledger,
113+
assert.Always(len(txs.V2TransactionsCursorResponse.Cursor.Data) == 0, "no transaction should involve never:* accounts", internal.Details{
114+
"ledger": ledger,
115115
"transactions": txs.V2TransactionsCursorResponse.Cursor.Data,
116116
})
117117
}

workload/bin/cmds/parallel_driver_bulk/atomicity.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"github.com/formancehq/go-libs/v2/pointer"
1717
)
1818

19-
2019
// Submit a bulk of transactions containing an invalid one, and check that no transaction was commited.
2120
// We send the correct transactions to `never:*` accounts which will get later checked.
2221
func SubmitInvalidAtomicBulk(
@@ -25,18 +24,18 @@ func SubmitInvalidAtomicBulk(
2524
ledger string,
2625
timestamp time.Time,
2726
) {
28-
txCount := random.GetRandom()%20
29-
27+
txCount := random.GetRandom() % 20
28+
3029
// insert valid transactions
3130
elements := []shared.V2BulkElement{}
3231
for range txCount {
3332
destination := random.RandomChoice([]string{"world", fmt.Sprintf("never:bulk_atomicity:%d", random.GetRandom()%internal.USER_ACCOUNT_COUNT)})
3433
elements = append(elements, shared.CreateV2BulkElementCreateTransaction(
3534
shared.V2BulkElementCreateTransaction{
36-
Ik: nil,
37-
Data: &shared.V2PostTransaction{
38-
Timestamp: internal.RandomTimestamp(timestamp),
39-
Postings: []shared.V2Posting{
35+
Ik: nil,
36+
Data: &shared.V2PostTransaction{
37+
Timestamp: internal.RandomTimestamp(timestamp),
38+
Postings: []shared.V2Posting{
4039
{
4140
Amount: big.NewInt(100),
4241
Asset: "COIN",
@@ -48,14 +47,14 @@ func SubmitInvalidAtomicBulk(
4847
},
4948
))
5049
}
51-
50+
5251
// insert an invalid transaction
5352
elements = slices.Insert(elements, int(random.GetRandom()%(txCount+1)), shared.CreateV2BulkElementCreateTransaction(
5453
shared.V2BulkElementCreateTransaction{
55-
Ik: nil,
56-
Data: &shared.V2PostTransaction{
57-
Timestamp: internal.RandomTimestamp(timestamp),
58-
Postings: []shared.V2Posting{
54+
Ik: nil,
55+
Data: &shared.V2PostTransaction{
56+
Timestamp: internal.RandomTimestamp(timestamp),
57+
Postings: []shared.V2Posting{
5958
{
6059
Amount: big.NewInt(100),
6160
Asset: "COIN",
@@ -74,9 +73,9 @@ func SubmitInvalidAtomicBulk(
7473
RequestBody: elements,
7574
})
7675
assert.Sometimes(err == nil, "bulk should be committed successfully", internal.Details{
77-
"ledger": ledger,
76+
"ledger": ledger,
7877
"elements": elements,
79-
"error": err,
78+
"error": err,
8079
})
8180
if err != nil {
8281
return

workload/bin/cmds/parallel_driver_bulk/main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func main() {
3232
const count = 100
3333

3434
pool := pond.New(10, 10e3)
35-
35+
3636
presentTime, err := internal.GetPresentTime(ctx, client, ledger)
3737
if err != nil {
3838
return
@@ -56,7 +56,7 @@ func SubmitBulk(
5656
ledger string,
5757
timestamp time.Time,
5858
) {
59-
txCount := random.GetRandom()%5
59+
txCount := random.GetRandom() % 5
6060

6161
elements := make([]shared.V2BulkElement, 0)
6262
for range txCount {
@@ -71,9 +71,9 @@ func SubmitBulk(
7171
})
7272

7373
assert.Sometimes(err == nil, "bulk should be committed successfully", internal.Details{
74-
"ledger": ledger,
74+
"ledger": ledger,
7575
"elements": elements,
76-
"error": err,
76+
"error": err,
7777
})
7878
if err != nil {
7979
return
@@ -85,10 +85,10 @@ func RandomBulkElement(time time.Time) shared.V2BulkElement {
8585
case 0:
8686
return shared.CreateV2BulkElementCreateTransaction(
8787
shared.V2BulkElementCreateTransaction{
88-
Ik: nil,
89-
Data: &shared.V2PostTransaction{
90-
Timestamp: internal.RandomTimestamp(time),
91-
Postings: internal.RandomPostings(),
88+
Ik: nil,
89+
Data: &shared.V2PostTransaction{
90+
Timestamp: internal.RandomTimestamp(time),
91+
Postings: internal.RandomPostings(),
9292
},
9393
},
9494
)

workload/bin/cmds/parallel_driver_ledger_create/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func main() {
1414
log.Println("composer: parallel_driver_ledger_create")
1515
ctx := context.Background()
1616
client := internal.NewClient()
17-
id := random.GetRandom()%1e6
17+
id := random.GetRandom() % 1e6
1818
ledger := fmt.Sprintf("ledger-%d", id)
1919

2020
_, err := internal.CreateLedger(

workload/bin/cmds/parallel_driver_transactions/main.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func main() {
2323

2424
ctx := context.Background()
2525
client := internal.NewClient()
26-
26+
2727
ledger, err := internal.GetRandomLedger(ctx, client)
2828
assert.Sometimes(err == nil, "should be able to get a random ledger", internal.Details{
2929
"error": err,
@@ -35,7 +35,7 @@ func main() {
3535
const count = 100
3636

3737
pool := pond.New(10, 10e3)
38-
38+
3939
presentTime, err := internal.GetPresentTime(ctx, client, ledger)
4040
if err != nil {
4141
return
@@ -58,12 +58,12 @@ func CreateTransaction(
5858
ledger string,
5959
presentTime *time.Time,
6060
) {
61-
offsetTime := presentTime.Add(time.Duration(-int64(random.GetRandom()%10)))
61+
offsetTime := presentTime.Add(time.Duration(-int64(random.GetRandom() % 10)))
6262
txTime := random.RandomChoice([]*time.Time{
6363
nil,
6464
&offsetTime,
6565
})
66-
66+
6767
switch random.RandomChoice([]uint8{0, 1}) {
6868
case 0:
6969
CreateRandomPostingsTransaction(ctx, client, ledger, txTime)
@@ -84,18 +84,18 @@ func CreateRandomPostingsTransaction(
8484
res, err := client.Ledger.V2.CreateTransaction(ctx, operations.V2CreateTransactionRequest{
8585
Ledger: ledger,
8686
V2PostTransaction: shared.V2PostTransaction{
87-
Postings: postings,
87+
Postings: postings,
8888
Timestamp: timestamp,
89-
Metadata: metadata,
89+
Metadata: metadata,
9090
},
9191
})
9292
if internal.AssertSometimesErrNil(
9393
err,
9494
"should be able to create a postings transaction",
9595
internal.Details{
96-
"ledger": ledger,
96+
"ledger": ledger,
9797
"postings": postings,
98-
"error": err,
98+
"error": err,
9999
},
100100
) {
101101
return
@@ -110,7 +110,7 @@ func CreateRandomPostingsTransaction(
110110
if errors.As(err, &getTxError) {
111111
assert.Always(getTxError.ErrorCode != shared.V2ErrorsEnumNotFound, "should always be able to read previous writes", internal.Details{
112112
"ledger": ledger,
113-
"txId": res.V2CreateTransactionResponse.Data.ID,
113+
"txId": res.V2CreateTransactionResponse.Data.ID,
114114
})
115115
}
116116

@@ -126,7 +126,7 @@ func CreateRandomPostingsTransaction(
126126

127127
for account, volumes := range res.V2CreateTransactionResponse.Data.PostCommitVolumes {
128128
internal.CheckVolumes(volumes, initialOverdrafts[account], internal.Details{
129-
"ledger": ledger,
129+
"ledger": ledger,
130130
"account": account,
131131
})
132132
}
@@ -155,9 +155,9 @@ func CreateRandomNumscriptTransaction(
155155
destination = $to
156156
}
157157
`,
158-
Vars: map[string]string{
159-
"from": internal.GetRandomAddress(),
160-
"to": internal.GetRandomAddress(),
158+
Vars: map[string]string{
159+
"from": internal.GetRandomAddress(),
160+
"to": internal.GetRandomAddress(),
161161
"amount": internal.RandomBigInt().String(),
162162
},
163163
},
@@ -169,7 +169,7 @@ func CreateRandomNumscriptTransaction(
169169
"should be able to create a numscript transaction",
170170
internal.Details{
171171
"ledger": ledger,
172-
"error": err,
172+
"error": err,
173173
},
174174
) {
175175
return
@@ -184,21 +184,21 @@ func CreateRandomNumscriptTransaction(
184184
if errors.As(err, &getTxError) {
185185
assert.Always(getTxError.ErrorCode != shared.V2ErrorsEnumNotFound, "should always be able to read previous writes", internal.Details{
186186
"ledger": ledger,
187-
"txId": res.V2CreateTransactionResponse.Data.ID,
187+
"txId": res.V2CreateTransactionResponse.Data.ID,
188188
})
189189
}
190190

191191
for account, volumes := range res.V2CreateTransactionResponse.Data.PostCommitVolumes {
192192
internal.CheckVolumes(volumes, nil, internal.Details{
193-
"ledger": ledger,
193+
"ledger": ledger,
194194
"account": account,
195195
})
196196
}
197197
}
198198

199199
func RandomTransactionMetadata() map[string]string {
200200
metadata := make(map[string]string)
201-
for range random.GetRandom()%3 {
201+
for range random.GetRandom() % 3 {
202202
key := fmt.Sprintf("%v", random.GetRandom()%999)
203203
metadata[key] = fmt.Sprintf("%v", random.GetRandom()%999)
204204
}

workload/bin/init/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package main
22

33
import (
44
"context"
5+
"fmt"
56
"os"
67
"os/signal"
78
"syscall"
89
"time"
9-
"fmt"
1010

1111
"github.com/antithesishq/antithesis-sdk-go/lifecycle"
1212
"github.com/formancehq/dst/workload/internal"

workload/internal/assert.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ type Details map[string]any
1010

1111
func (d *Details) with(Details) Details {
1212
out := make(map[string]any)
13-
for k, v := range *d { out[k] = v }
14-
for k, v := range *d { out[k] = v }
13+
for k, v := range *d {
14+
out[k] = v
15+
}
16+
for k, v := range *d {
17+
out[k] = v
18+
}
1519
return out
1620
}
1721

@@ -28,7 +32,7 @@ func AssertAlwaysErrNil(err error, message string, details Details) bool {
2832
}
2933

3034
func AssertSometimesErrNil(err error, message string, details Details) bool {
31-
assert.Sometimes(err == nil, message, details.with(Details {
35+
assert.Sometimes(err == nil, message, details.with(Details{
3236
"error": err,
3337
}))
3438
return err != nil

0 commit comments

Comments
 (0)