-
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_updateparams
- Loading branch information
Showing
6 changed files
with
100 additions
and
12 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
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 | ||
} |