Skip to content

Commit

Permalink
fix nexus-gateway req
Browse files Browse the repository at this point in the history
  • Loading branch information
fish-sammy committed Nov 9, 2023
1 parent 9b05768 commit 405455a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion x/nexus/keeper/wasm_message_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
types "github.com/axelarnetwork/axelar-core/x/nexus/types"
)

type req struct {
RouteMessages []exported.WasmMessage `json:"route_messages"`
}

// NewMessageRoute creates a new message route
func NewMessageRoute(nexus types.Nexus, account types.AccountKeeper, wasm types.WasmKeeper) exported.MessageRoute {
return func(ctx sdk.Context, _ exported.RoutingContext, msg exported.GeneralMessage) error {
Expand All @@ -22,7 +26,7 @@ func NewMessageRoute(nexus types.Nexus, account types.AccountKeeper, wasm types.
return fmt.Errorf("gateway is not set")
}

bz, err := json.Marshal(exported.FromGeneralMessage(msg))
bz, err := json.Marshal(req{RouteMessages: []exported.WasmMessage{exported.FromGeneralMessage(msg)}})
if err != nil {
return nil
}
Expand Down
9 changes: 7 additions & 2 deletions x/nexus/keeper/wasm_message_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,14 @@ func TestNewMessageRoute(t *testing.T) {
assert.Equal(t, wasmK.ExecuteCalls()[0].Caller, moduleAddr)
assert.Empty(t, wasmK.ExecuteCalls()[0].Coins)

var actual nexus.WasmMessage
type req struct {
RouteMessages []nexus.WasmMessage `json:"route_messages"`
}

var actual req
assert.NoError(t, json.Unmarshal(wasmK.ExecuteCalls()[0].Msg, &actual))
assert.Equal(t, nexus.FromGeneralMessage(msg), actual)
assert.Len(t, actual.RouteMessages, 1)
assert.Equal(t, nexus.FromGeneralMessage(msg), actual.RouteMessages[0])
}),
).
Run(t)
Expand Down

0 comments on commit 405455a

Please sign in to comment.