-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into foundation_pruning
- Loading branch information
Showing
8 changed files
with
132 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"github.com/line/lbm-sdk/x/staking/keeper" | ||
"github.com/line/lbm-sdk/x/staking/types" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestUnbondingToUnbondedPanic(t *testing.T) { | ||
app, ctx, _, _, validators := initValidators(t, 100, 2, []int64{0, 100}) | ||
|
||
for i, validator := range validators { | ||
validators[i] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, false) | ||
} | ||
|
||
assert.Equal(t, validators[0].Status, types.Unbonded) | ||
assert.Equal(t, validators[1].Status, types.Bonded) | ||
|
||
// unbond validator which is in unbonded status | ||
require.Panics(t, func() { | ||
app.StakingKeeper.UnbondingToUnbonded(ctx, validators[0]) | ||
}) | ||
|
||
// unbond validator which is in bonded status | ||
require.Panics(t, func() { | ||
app.StakingKeeper.UnbondingToUnbonded(ctx, validators[1]) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package testdata | ||
|
||
import ( | ||
_ "embed" | ||
) | ||
|
||
//go:embed reflect.wasm | ||
var reflectContract []byte | ||
|
||
func ReflectContractWasm() []byte { | ||
return reflectContract | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package simulation | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
simappparams "github.com/line/lbm-sdk/simapp/params" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/line/lbm-sdk/types/module" | ||
"github.com/line/lbm-sdk/x/simulation" | ||
"github.com/line/lbm-sdk/x/wasm/keeper" | ||
"github.com/line/lbm-sdk/x/wasm/types" | ||
) | ||
|
||
func TestWeightedOperations(t *testing.T) { | ||
type args struct { | ||
simstate *module.SimulationState | ||
ak types.AccountKeeper | ||
bk simulation.BankKeeper | ||
wasmKeeper WasmKeeper | ||
wasmBz []byte | ||
} | ||
|
||
params := args{ | ||
simstate: &module.SimulationState{}, | ||
wasmKeeper: makeKeeper(t).WasmKeeper, | ||
} | ||
|
||
tests := []struct { | ||
name string | ||
args args | ||
want simulation.WeightedOperations | ||
}{ | ||
{ | ||
name: "execute success", | ||
args: args{ | ||
simstate: &module.SimulationState{}, | ||
}, | ||
want: simulation.WeightedOperations{ | ||
simulation.NewWeightedOperation( | ||
simappparams.DefaultWeightMsgStoreCode, | ||
SimulateMsgStoreCode(params.ak, params.bk, params.wasmKeeper, params.wasmBz)), | ||
simulation.NewWeightedOperation( | ||
simappparams.DefaultWeightMsgInstantiateContract, | ||
SimulateMsgInstantiateContract(params.ak, params.bk, params.wasmKeeper)), | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := WeightedOperations(tt.args.simstate, tt.args.ak, tt.args.bk, tt.args.wasmKeeper) | ||
for i := range got { | ||
require.Equal(t, tt.want[i].Weight(), got[i].Weight(), "WeightedOperations().Weight()") | ||
|
||
expected := reflect.TypeOf(tt.want[i].Op()).String() | ||
actual := reflect.TypeOf(got[i].Op()).String() | ||
|
||
require.Equal(t, expected, actual, "return value type should be the same") | ||
} | ||
}) | ||
} | ||
} | ||
|
||
// Copy from keeper_test.go | ||
const SupportedFeatures = "iterator,staking,stargate" | ||
|
||
// Copy from keeper_test.go | ||
func makeKeeper(t *testing.T) keeper.TestKeepers { | ||
_, keepers := keeper.CreateTestInput(t, false, SupportedFeatures, nil, nil) | ||
return keepers | ||
} |