Skip to content

Commit

Permalink
fix(manager): cache funding account (#23)
Browse files Browse the repository at this point in the history
* fix race

* reuse funding acc
  • Loading branch information
Lazar955 authored Nov 12, 2024
1 parent a759a07 commit 760a668
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions harness/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type TestManager struct {
babylonDir string
benchConfig benchcfg.Config
fundingRequests chan sdk.AccAddress
fundingAddress sdk.AccAddress
}

// StartManager creates a test manager
Expand Down Expand Up @@ -206,6 +207,10 @@ func StartManager(ctx context.Context, outputsInWallet uint32, epochInterval uin
if err != nil {
return nil, err
}

fundingAccount := babylonClientNode0.MustGetAddr()
fundingAddress := sdk.MustAccAddressFromBech32(fundingAccount)

return &TestManager{
TestRpcClient: testRpcClient,
BabylonClientNode0: babylonClientNode0,
Expand All @@ -217,6 +222,7 @@ func StartManager(ctx context.Context, outputsInWallet uint32, epochInterval uin
babylonDir: babylonDir,
benchConfig: runCfg,
fundingRequests: make(chan sdk.AccAddress, 100),
fundingAddress: fundingAddress,
}, nil
}

Expand Down Expand Up @@ -340,17 +346,21 @@ func (tm *TestManager) fundAllParties(
ctx context.Context,
senders []*SenderWithBabylonClient,
) error {

fundingAccount := tm.BabylonClientNode0.MustGetAddr()
fundingAddress := sdk.MustAccAddressFromBech32(fundingAccount)

var msgs []sdk.Msg
msgs := make([]sdk.Msg, 0, len(senders))

for _, sender := range senders {
msg := banktypes.NewMsgSend(fundingAddress, sender.BabylonAddress, types.NewCoins(types.NewInt64Coin("ubbn", 100_000_000)))
msg := banktypes.NewMsgSend(
tm.fundingAddress,
sender.BabylonAddress,
types.NewCoins(types.NewInt64Coin("ubbn", 100_000_000)),
)
msgs = append(msgs, msg)
}

if ctx.Err() != nil {
return fmt.Errorf("context error: %w", ctx.Err())
}

resp, err := tm.BabylonClientNode0.ReliablySendMsgs(
ctx,
msgs,
Expand Down

0 comments on commit 760a668

Please sign in to comment.