generated from dymensionxyz/rollapp
-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat: added MsgUpsertSequencer to the admission handler #352
Open
keruch
wants to merge
10
commits into
main
Choose a base branch
from
kirill/1248-sequencer-reward-addr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4413d83
this is working now, admission handler basic.
bd42e72
first attempt to make test pass
5aa752a
add begin blocker test
44b4400
fix pr
2662ced
goimports
5a6db76
comment admission handler example
9e43f29
goimports
36fe674
Merge remote-tracking branch 'origin/main' into feat/consensus-messages
e0210af
feat: added MsgUpsertSequencer to the admission handler
keruch e97d844
rebase plus go.mod
keruch 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,100 @@ | ||
package app | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
"github.com/gogo/protobuf/proto" | ||
prototypes "github.com/gogo/protobuf/types" | ||
"github.com/stretchr/testify/require" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
"github.com/tendermint/tendermint/proto/tendermint/types" | ||
) | ||
|
||
func TestBeginBlocker(t *testing.T) { | ||
app, valAccount := SetupWithOneValidator(t) | ||
ctx := app.NewUncachedContext(true, types.Header{ | ||
Height: 1, | ||
ChainID: "testchain_9000-1", | ||
}) | ||
|
||
bankSend := &banktypes.MsgSend{ | ||
FromAddress: valAccount.GetAddress().String(), | ||
ToAddress: valAccount.GetAddress().String(), | ||
Amount: sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(100))), | ||
} | ||
msgBz, err := proto.Marshal(bankSend) | ||
require.NoError(t, err) | ||
|
||
goodMessage := &prototypes.Any{ | ||
TypeUrl: proto.MessageName(&banktypes.MsgSend{}), | ||
Value: msgBz, | ||
} | ||
|
||
testCases := []struct { | ||
name string | ||
consensusMsgs []*prototypes.Any | ||
expectError bool | ||
}{ | ||
{ | ||
name: "ValidConsensusMessage", | ||
consensusMsgs: []*prototypes.Any{ | ||
goodMessage, | ||
}, | ||
expectError: false, | ||
}, | ||
{ | ||
name: "InvalidUnpackMessage", | ||
consensusMsgs: []*prototypes.Any{ | ||
{ | ||
TypeUrl: "/path.to.InvalidMsg", | ||
Value: []byte("invalid unpack data"), | ||
}, | ||
}, | ||
expectError: true, | ||
}, | ||
{ | ||
name: "InvalidExecutionMessage", | ||
consensusMsgs: []*prototypes.Any{ | ||
{ | ||
TypeUrl: "/path.to.ExecErrorMsg", | ||
Value: []byte("execution error data"), | ||
}, | ||
}, | ||
expectError: true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
req := abci.RequestBeginBlock{ | ||
Header: types.Header{ | ||
Height: 1, | ||
Time: ctx.BlockTime(), | ||
ChainID: "testchain_9000-1", | ||
}, | ||
LastCommitInfo: abci.LastCommitInfo{}, | ||
ByzantineValidators: []abci.Evidence{}, | ||
ConsensusMessages: tc.consensusMsgs, | ||
} | ||
|
||
res := app.BeginBlocker(ctx, req) | ||
require.NotNil(t, res) | ||
|
||
if tc.expectError { | ||
require.NotEmpty(t, res.ConsensusMessagesResponses) | ||
for _, response := range res.ConsensusMessagesResponses { | ||
_, isError := response.Response.(*abci.ConsensusMessageResponse_Error) | ||
require.True(t, isError, "Expected an error response but got a success") | ||
} | ||
} else { | ||
require.NotEmpty(t, res.ConsensusMessagesResponses) | ||
for _, response := range res.ConsensusMessagesResponses { | ||
_, isOk := response.Response.(*abci.ConsensusMessageResponse_Ok) | ||
require.True(t, isOk, "Expected a success response but got an error") | ||
} | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
you can probably remove this comment