Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fish-sammy committed Sep 5, 2024
1 parent 2df1f54 commit 1d2a9fb
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 56 deletions.
2 changes: 1 addition & 1 deletion app/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func TestQueryPlugins(t *testing.T) {
Then("it should return an error", func(t *testing.T) {
txHash := [32]byte(rand.Bytes(32))
index := uint64(rand.PosI64())
txIDGenerator.CurrFunc = func(ctx sdk.Context) ([32]byte, uint64) {
txIDGenerator.CurrIDFunc = func(ctx sdk.Context) ([32]byte, uint64) {
return txHash, index
}

Expand Down
2 changes: 1 addition & 1 deletion x/nexus/keeper/general_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func getProcessingMessageKey(destinationChain exported.ChainName, id string) key
// GenerateMessageID generates a unique general message ID, and returns the message ID, current transacation ID and a unique integer nonce
// The message ID is just a concatenation of the transaction ID and the nonce
func (k Keeper) GenerateMessageID(ctx sdk.Context) (string, []byte, uint64) {
hash, nonce := k.Next(ctx)
hash, nonce := k.NextID(ctx)

return fmt.Sprintf("0x%s-%d", hex.EncodeToString(hash[:]), nonce), hash[:], nonce
}
Expand Down
8 changes: 4 additions & 4 deletions x/nexus/keeper/tx_id_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ func getTxHash(ctx sdk.Context) [32]byte {
return sha256.Sum256(ctx.TxBytes())
}

// Next returns the next transaction hash and index, and increments the index
func (k Keeper) Next(ctx sdk.Context) ([32]byte, uint64) {
// NextID returns the next transaction hash and index, and increments the index
func (k Keeper) NextID(ctx sdk.Context) ([32]byte, uint64) {
return getTxHash(ctx), utils.NewCounter[uint64](messageNonceKey, k.getStore(ctx)).Incr(ctx)
}

// Curr returns the current transaction hash and index
func (k Keeper) Curr(ctx sdk.Context) ([32]byte, uint64) {
// CurrID returns the current transaction hash and index
func (k Keeper) CurrID(ctx sdk.Context) ([32]byte, uint64) {
return getTxHash(ctx), utils.NewCounter[uint64](messageNonceKey, k.getStore(ctx)).Curr(ctx)

Check warning on line 25 in x/nexus/keeper/tx_id_generator.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/tx_id_generator.go#L24-L25

Added lines #L24 - L25 were not covered by tests
}
2 changes: 1 addition & 1 deletion x/nexus/keeper/wasm_querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewWasmQuerier(txIDGenerator types.TxIDGenerator) *WasmQuerier {
// Query handles the wasm queries for the nexus module
func (q WasmQuerier) Query(ctx sdk.Context, req exported.WasmQueryRequest) ([]byte, error) {
if req.TxID != nil {
txHash, index := q.txIDGenerator.Curr(ctx)
txHash, index := q.txIDGenerator.CurrID(ctx)

Check warning on line 27 in x/nexus/keeper/wasm_querier.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/wasm_querier.go#L25-L27

Added lines #L25 - L27 were not covered by tests

return funcs.Must(json.Marshal(exported.WasmQueryTxIDResponse{
TxHash: txHash,
Expand Down
10 changes: 5 additions & 5 deletions x/nexus/keeper/wasmer_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (w *WasmerEngine) Instantiate(
gasLimit uint64,
deserCost wasmvmtypes.UFraction,
) (*wasmvmtypes.Response, uint64, error) {
defer w.txIDGenerator.Next(getCtx(querier))
defer w.txIDGenerator.NextID(getCtx(querier))

Check warning on line 41 in x/nexus/keeper/wasmer_engine.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/wasmer_engine.go#L40-L41

Added lines #L40 - L41 were not covered by tests

return w.WasmerEngine.Instantiate(checksum, env, info, initMsg, store, goapi, querier, gasMeter, gasLimit, deserCost)

Check warning on line 43 in x/nexus/keeper/wasmer_engine.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/wasmer_engine.go#L43

Added line #L43 was not covered by tests
}
Expand All @@ -56,7 +56,7 @@ func (w *WasmerEngine) Execute(
gasLimit uint64,
deserCost wasmvmtypes.UFraction,
) (*wasmvmtypes.Response, uint64, error) {
defer w.txIDGenerator.Next(getCtx(querier))
defer w.txIDGenerator.NextID(getCtx(querier))

Check warning on line 59 in x/nexus/keeper/wasmer_engine.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/wasmer_engine.go#L58-L59

Added lines #L58 - L59 were not covered by tests

return w.WasmerEngine.Execute(code, env, info, executeMsg, store, goapi, querier, gasMeter, gasLimit, deserCost)

Check warning on line 61 in x/nexus/keeper/wasmer_engine.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/wasmer_engine.go#L61

Added line #L61 was not covered by tests
}
Expand All @@ -73,7 +73,7 @@ func (w *WasmerEngine) Migrate(
gasLimit uint64,
deserCost wasmvmtypes.UFraction,
) (*wasmvmtypes.Response, uint64, error) {
defer w.txIDGenerator.Next(getCtx(querier))
defer w.txIDGenerator.NextID(getCtx(querier))

Check warning on line 76 in x/nexus/keeper/wasmer_engine.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/wasmer_engine.go#L75-L76

Added lines #L75 - L76 were not covered by tests

return w.WasmerEngine.Migrate(checksum, env, migrateMsg, store, goapi, querier, gasMeter, gasLimit, deserCost)

Check warning on line 78 in x/nexus/keeper/wasmer_engine.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/wasmer_engine.go#L78

Added line #L78 was not covered by tests
}
Expand All @@ -90,7 +90,7 @@ func (w *WasmerEngine) Sudo(
gasLimit uint64,
deserCost wasmvmtypes.UFraction,
) (*wasmvmtypes.Response, uint64, error) {
defer w.txIDGenerator.Next(getCtx(querier))
defer w.txIDGenerator.NextID(getCtx(querier))

Check warning on line 93 in x/nexus/keeper/wasmer_engine.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/wasmer_engine.go#L92-L93

Added lines #L92 - L93 were not covered by tests

return w.WasmerEngine.Sudo(checksum, env, sudoMsg, store, goapi, querier, gasMeter, gasLimit, deserCost)

Check warning on line 95 in x/nexus/keeper/wasmer_engine.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/wasmer_engine.go#L95

Added line #L95 was not covered by tests
}
Expand All @@ -107,7 +107,7 @@ func (w *WasmerEngine) Reply(
gasLimit uint64,
deserCost wasmvmtypes.UFraction,
) (*wasmvmtypes.Response, uint64, error) {
defer w.txIDGenerator.Next(getCtx(querier))
defer w.txIDGenerator.NextID(getCtx(querier))

Check warning on line 110 in x/nexus/keeper/wasmer_engine.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/wasmer_engine.go#L109-L110

Added lines #L109 - L110 were not covered by tests

return w.WasmerEngine.Reply(checksum, env, reply, store, goapi, querier, gasMeter, gasLimit, deserCost)

Check warning on line 112 in x/nexus/keeper/wasmer_engine.go

View check run for this annotation

Codecov / codecov/patch

x/nexus/keeper/wasmer_engine.go#L112

Added line #L112 was not covered by tests
}
4 changes: 2 additions & 2 deletions x/nexus/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ type Nexus interface {

// TxIDGenerator provides functionality to generate transaction IDs
type TxIDGenerator interface {
Next(ctx sdk.Context) ([32]byte, uint64)
Curr(ctx sdk.Context) ([32]byte, uint64)
NextID(ctx sdk.Context) ([32]byte, uint64)
CurrID(ctx sdk.Context) ([32]byte, uint64)
}

// Snapshotter provides functionality to the snapshot module
Expand Down
84 changes: 42 additions & 42 deletions x/nexus/types/mock/expected_keepers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1d2a9fb

Please sign in to comment.