-
Notifications
You must be signed in to change notification settings - Fork 31
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: fix to prevent external filesystem dependency of simulations #695
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1b836ec
fix: use go:embed
da1suk8 f1ab3c0
Merge branch 'main' into fix/use_go_embed
da1suk8 a2a0a92
fix: remove unnecessary part
da1suk8 630094d
docs: update CHANGELOG.md
da1suk8 d57b37d
test: add test of WeightedOperations
da1suk8 9cd704e
fix: fix format
da1suk8 50c9f8f
fix: delete wasmContractPath
da1suk8 7f4f887
Merge branch 'main' into fix/use_go_embed
da1suk8 2e49dba
Merge branch 'main' into fix/use_go_embed
da1suk8 e6f6c74
Merge branch 'main' into fix/use_go_embed
da1suk8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding the unittest of this lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is dead code, so I deleted it.