mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-23 23:05:18 +00:00
Choose simulation seed that runs without unbonding (#447)
* fix: ci failing due to memory consumption * feat: choose seed that doesn't immediately exit * fix: don't attempt to draw too much debt * fix: remove comment
This commit is contained in:
parent
89bad17d96
commit
0949a912cf
23
Makefile
23
Makefile
@ -112,28 +112,27 @@ link-check:
|
||||
test-all: build
|
||||
# basic app tests
|
||||
@go test ./app -v
|
||||
# basic simulation (seed "2" happens to not unbond all validators before reaching 100 blocks)
|
||||
@go test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 2 -v -timeout 24h
|
||||
# basic simulation (seed "4" happens to not unbond all validators before reaching 100 blocks)
|
||||
@go test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
|
||||
# other sim tests
|
||||
@go test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 2 -v -timeout 24h
|
||||
@go test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 2 -v -timeout 24h
|
||||
@go test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
|
||||
@go test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
|
||||
@# AppStateDeterminism does not use Seed flag
|
||||
@go test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 2 -v -timeout 24h
|
||||
@go test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=100 -BlockSize=200 -Seed 4 -v -timeout 24h
|
||||
|
||||
# run module tests and short simulations
|
||||
test-basic: test
|
||||
# basic simulation (seed "2" happens to not unbond all validators before reaching 100 blocks)
|
||||
@go test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 2 -v -timeout 2m
|
||||
@go test ./app -run TestFullAppSimulation -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
|
||||
# other sim tests
|
||||
@go test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 2 -v -timeout 2m
|
||||
@go test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 2 -v -timeout 2m
|
||||
@go test ./app -run TestAppImportExport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
|
||||
@go test ./app -run TestAppSimulationAfterImport -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
|
||||
@# AppStateDeterminism does not use Seed flag
|
||||
@go test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 2 -v -timeout 2m
|
||||
@go test ./app -run TestAppStateDeterminism -Enabled -Commit -NumBlocks=5 -BlockSize=200 -Seed 4 -v -timeout 2m
|
||||
|
||||
test:
|
||||
@go test ./...
|
||||
|
||||
test_dredd:
|
||||
test-rest:
|
||||
rest_test/./run_all_tests_from_make.sh
|
||||
|
||||
test-cli:
|
||||
@ -154,4 +153,4 @@ start-remote-sims:
|
||||
-—job-definition kava-sim-master \
|
||||
-—container-override environment=[{SIM_NAME=master-$(VERSION)}]
|
||||
|
||||
.PHONY: all build-linux install clean build test test-cli test-all test_dredd test-basic start-remote-sims
|
||||
.PHONY: all build-linux install clean build test test-cli test-all test-rest test-basic start-remote-sims
|
||||
|
@ -127,7 +127,7 @@ func SimulateMsgCdp(ak auth.AccountKeeper, k cdp.Keeper, pfk pricefeed.Keeper) s
|
||||
// given the current collateral value, calculate how much debt we could add while maintaining a valid liquidation ratio
|
||||
debt := existingCDP.Principal.AmountOf(randDebtParam.Denom).Add(totalFees)
|
||||
maxTotalDebt := collateralValue.Quo(randCollateralParam.LiquidationRatio)
|
||||
maxDebt := maxTotalDebt.Sub(sdk.NewDecFromInt(debt)).TruncateInt()
|
||||
maxDebt := (maxTotalDebt.Sub(sdk.NewDecFromInt(debt))).Mul(sdk.MustNewDecFromStr("0.95")).TruncateInt()
|
||||
if maxDebt.LTE(sdk.OneInt()) {
|
||||
// debt in cdp is maxed out
|
||||
return simulation.NewOperationMsgBasic(cdp.ModuleName, "no-operation", "cdp debt maxed out, cannot draw more debt", false, nil), nil, nil
|
||||
|
Loading…
Reference in New Issue
Block a user