Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(manager): cache funding account #23

Merged
merged 2 commits into from
Nov 12, 2024
Merged
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
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