Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pinosu committed Jul 6, 2023
1 parent e01f861 commit 80fb374
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
18 changes: 2 additions & 16 deletions x/wasm/keeper/wasmtesting/mock_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ var _ types.WasmerEngine = &MockWasmer{}
// MockWasmer implements types.WasmerEngine for testing purpose. One or multiple messages can be stubbed.
// Without a stub function a panic is thrown.
type MockWasmer struct {
CreateFn func(codeID wasmvm.WasmCode) (wasmvm.Checksum, error)
StoreCodeFn func(codeID wasmvm.WasmCode) (wasmvm.Checksum, error)
StoreCodeUncheckedFn func(codeID wasmvm.WasmCode) (wasmvm.Checksum, error)
AnalyzeCodeFn func(codeID wasmvm.Checksum) (*wasmvmtypes.AnalysisReport, error)
Expand Down Expand Up @@ -82,11 +81,9 @@ func (m *MockWasmer) IBCPacketTimeout(codeID wasmvm.Checksum, env wasmvmtypes.En
return m.IBCPacketTimeoutFn(codeID, env, msg, store, goapi, querier, gasMeter, gasLimit, deserCost)
}

// Deprecated: use StoreCode instead.
func (m *MockWasmer) Create(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) {
if m.CreateFn == nil {
panic("not supposed to be called!")
}
return m.CreateFn(codeID)
panic("Deprecated: use StoreCode instead")
}

func (m *MockWasmer) StoreCode(codeID wasmvm.WasmCode) (wasmvm.Checksum, error) {
Expand Down Expand Up @@ -337,13 +334,6 @@ func NewIBCContractMockWasmer(c IBCContractCallbacks) *MockWasmer {
return m
}

func HashOnlyCreateFn(code wasmvm.WasmCode) (wasmvm.Checksum, error) {
if code == nil {
return nil, errorsmod.Wrap(types.ErrInvalid, "wasm code must not be nil")
}
return wasmvm.CreateChecksum(code)
}

func HashOnlyStoreCodeFn(code wasmvm.WasmCode) (wasmvm.Checksum, error) {
if code == nil {
return nil, errorsmod.Wrap(types.ErrInvalid, "wasm code must not be nil")
Expand All @@ -355,10 +345,6 @@ func NoOpInstantiateFn(wasmvm.Checksum, wasmvmtypes.Env, wasmvmtypes.MessageInfo
return &wasmvmtypes.Response{}, 0, nil
}

func NoOpCreateFn(_ wasmvm.WasmCode) (wasmvm.Checksum, error) {
return rand.Bytes(32), nil
}

func NoOpStoreCodeFn(_ wasmvm.WasmCode) (wasmvm.Checksum, error) {
return rand.Bytes(32), nil
}
Expand Down
8 changes: 4 additions & 4 deletions x/wasm/types/test_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

//go:embed testdata/reflect.wasm
var wasmCode []byte
var reflectWasmCode []byte

func GenesisFixture(mutators ...func(*GenesisState)) GenesisState {
const (
Expand Down Expand Up @@ -56,8 +56,8 @@ func randBytes(n int) []byte {
func CodeFixture(mutators ...func(*Code)) Code {
fixture := Code{
CodeID: 1,
CodeInfo: CodeInfoFixture(WithSHA256CodeHash(wasmCode)),
CodeBytes: wasmCode,
CodeInfo: CodeInfoFixture(WithSHA256CodeHash(reflectWasmCode)),
CodeBytes: reflectWasmCode,
}

for _, m := range mutators {
Expand All @@ -67,7 +67,7 @@ func CodeFixture(mutators ...func(*Code)) Code {
}

func CodeInfoFixture(mutators ...func(*CodeInfo)) CodeInfo {
codeHash, err := wasmvm.CreateChecksum(wasmCode)
codeHash, err := wasmvm.CreateChecksum(reflectWasmCode)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions x/wasm/types/wasmer_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ type WasmerEngine interface {
Create(code wasmvm.WasmCode) (wasmvm.Checksum, error)

// Create will compile the wasm code, and store the resulting pre-compile
// as well as the original code. Both can be referenced later via CodeID
// as well as the original code. Both can be referenced later via checksum
// This must be done one time for given code, after which it can be
// instatitated many times, and each instance called many times.
// It does the same as StoreCodeUnchecked plus the static checks.
StoreCode(code wasmvm.WasmCode) (wasmvm.Checksum, error)

// Create will compile the wasm code, and store the resulting pre-compile
// as well as the original code. Both can be referenced later via CodeID
// as well as the original code. Both can be referenced later via checksum
// This must be done one time for given code, after which it can be
// instatitated many times, and each instance called many times.
// It does the same as StoreCode but without the static checks.
Expand Down

0 comments on commit 80fb374

Please sign in to comment.