-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
74 additions
and
1 deletion.
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,28 @@ | ||
package lanes | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
blockbase "github.com/skip-mev/block-sdk/v2/block/base" | ||
|
||
"github.com/initia-labs/OPinit/x/opchild/types" | ||
) | ||
|
||
// SystemLaneMatchHandler returns the default match handler for the system lane. | ||
func SystemLaneMatchHandler() blockbase.MatchHandler { | ||
return func(ctx sdk.Context, tx sdk.Tx) bool { | ||
if len(tx.GetMsgs()) != 1 { | ||
return false | ||
} | ||
|
||
for _, msg := range tx.GetMsgs() { | ||
switch msg.(type) { | ||
case *types.MsgUpdateOracle: | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
} | ||
} |
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,44 @@ | ||
package lanes_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"cosmossdk.io/log" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
|
||
"github.com/cometbft/cometbft/proto/tendermint/types" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/initia-labs/OPinit/x/opchild/lanes" | ||
opchildtypes "github.com/initia-labs/OPinit/x/opchild/types" | ||
) | ||
|
||
func Test_SystemLaneMatchHandler(t *testing.T) { | ||
ctx := sdk.NewContext(nil, types.Header{}, false, log.NewNopLogger()) | ||
|
||
handler := lanes.SystemLaneMatchHandler() | ||
|
||
// 1 system message | ||
require.True(t, handler(ctx, MockTx{ | ||
msgs: []sdk.Msg{ | ||
&opchildtypes.MsgUpdateOracle{}, | ||
}, | ||
})) | ||
|
||
// 2 system messages | ||
require.False(t, handler(ctx, MockTx{ | ||
msgs: []sdk.Msg{ | ||
&opchildtypes.MsgUpdateOracle{}, | ||
&opchildtypes.MsgUpdateOracle{}, | ||
}, | ||
})) | ||
|
||
// 1 non-system message | ||
require.False(t, handler(ctx, MockTx{ | ||
msgs: []sdk.Msg{ | ||
&banktypes.MsgSend{}, | ||
}, | ||
})) | ||
} |