Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Dec 29, 2023
1 parent ff3b08d commit e0ac2b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions x/dex/contract/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func EndBlockerAtomic(ctx sdk.Context, keeper *keeper.Keeper, validContractsInfo
handleDeposits(spanCtx, cachedCtx, env, keeper, tracer)

runner := NewParallelRunner(func(contract types.ContractInfoV2) {
orderMatchingRunnable(spanCtx, cachedCtx, env, keeper, contract, tracer)
OrderMatchingRunnable(spanCtx, cachedCtx, env, keeper, contract, tracer)

Check warning on line 61 in x/dex/contract/abci.go

View check run for this annotation

Codecov / codecov/patch

x/dex/contract/abci.go#L61

Added line #L61 was not covered by tests
}, validContractsInfo, cachedCtx)

_, err := logging.LogIfNotDoneAfter(ctx.Logger(), func() (struct{}, error) {
Expand Down Expand Up @@ -227,7 +227,7 @@ func handleUnfulfilledMarketOrders(ctx context.Context, sdkCtx sdk.Context, env
}
}

func orderMatchingRunnable(ctx context.Context, sdkContext sdk.Context, env *environment, keeper *keeper.Keeper, contractInfo types.ContractInfoV2, tracer *otrace.Tracer) {
func OrderMatchingRunnable(ctx context.Context, sdkContext sdk.Context, env *environment, keeper *keeper.Keeper, contractInfo types.ContractInfoV2, tracer *otrace.Tracer) {
defer func() {
if err := recover(); err != nil {
msg := fmt.Sprintf("PANIC RECOVERED during order matching: %s", err)
Expand All @@ -237,7 +237,7 @@ func orderMatchingRunnable(ctx context.Context, sdkContext sdk.Context, env *env
}

Check warning on line 237 in x/dex/contract/abci.go

View check run for this annotation

Codecov / codecov/patch

x/dex/contract/abci.go#L236-L237

Added lines #L236 - L237 were not covered by tests
}
}()
_, span := (*tracer).Start(ctx, "orderMatchingRunnable")
_, span := (*tracer).Start(ctx, "OrderMatchingRunnable")
defer span.End()
defer telemetry.MeasureSince(time.Now(), "dex", "order_matching_runnable")
defer func() {
Expand Down
9 changes: 9 additions & 0 deletions x/dex/contract/abci_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package contract_test

import (
"context"
"testing"
"time"

Expand Down Expand Up @@ -32,3 +33,11 @@ func TestTransferRentFromDexToCollector(t *testing.T) {
collectorBalance := bankkeeper.GetBalance(ctx, testApp.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName), "usei")
require.Equal(t, int64(80), collectorBalance.Amount.Int64())
}

func TestOrderMatchingRunnablePanicHandler(t *testing.T) {
testApp := keepertest.TestApp()
ctx := testApp.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})
require.NotPanics(t, func() {
contract.OrderMatchingRunnable(context.Background(), ctx, nil, nil, types.ContractInfoV2{}, nil)
})
}

0 comments on commit e0ac2b4

Please sign in to comment.