forked from evmos/ethermint
-
Notifications
You must be signed in to change notification settings - Fork 52
feat: support create_access_list #768
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
Open
thomas-nguy
wants to merge
5
commits into
crypto-org-chain:develop
Choose a base branch
from
thomas-nguy:thomas/access-list-support
base: develop
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
5 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -35,57 +35,67 @@ var _ tmrpcclient.Client = &mocks.Client{} | |
| func RegisterTxSearch(client *mocks.Client, query string, txBz []byte) { | ||
| resulTxs := []*tmrpctypes.ResultTx{{Tx: txBz}} | ||
| client.On("TxSearch", rpc.ContextWithHeight(1), query, false, (*int)(nil), (*int)(nil), ""). | ||
| Return(&tmrpctypes.ResultTxSearch{Txs: resulTxs, TotalCount: 1}, nil) | ||
| Return(&tmrpctypes.ResultTxSearch{Txs: resulTxs, TotalCount: 1}, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterTxSearchEmpty(client *mocks.Client, query string) { | ||
| client.On("TxSearch", rpc.ContextWithHeight(1), query, false, (*int)(nil), (*int)(nil), ""). | ||
| Return(&tmrpctypes.ResultTxSearch{}, nil) | ||
| Return(&tmrpctypes.ResultTxSearch{}, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterTxSearchError(client *mocks.Client, query string) { | ||
| client.On("TxSearch", rpc.ContextWithHeight(1), query, false, (*int)(nil), (*int)(nil), ""). | ||
| Return(nil, errortypes.ErrInvalidRequest) | ||
| Return(nil, errortypes.ErrInvalidRequest). | ||
| Maybe() | ||
| } | ||
|
|
||
| // Broadcast Tx | ||
| func RegisterBroadcastTx(client *mocks.Client, tx types.Tx) { | ||
| client.On("BroadcastTxSync", context.Background(), tx). | ||
| Return(&tmrpctypes.ResultBroadcastTx{}, nil) | ||
| Return(&tmrpctypes.ResultBroadcastTx{}, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterBroadcastTxError(client *mocks.Client, tx types.Tx) { | ||
| client.On("BroadcastTxSync", context.Background(), tx). | ||
| Return(nil, errortypes.ErrInvalidRequest) | ||
| Return(nil, errortypes.ErrInvalidRequest). | ||
| Maybe() | ||
| } | ||
|
|
||
| // Unconfirmed Transactions | ||
| func RegisterUnconfirmedTxs(client *mocks.Client, limit *int, txs []types.Tx) { | ||
| client.On("UnconfirmedTxs", rpc.ContextWithHeight(1), limit). | ||
| Return(&tmrpctypes.ResultUnconfirmedTxs{Txs: txs}, nil) | ||
| Return(&tmrpctypes.ResultUnconfirmedTxs{Txs: txs}, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterUnconfirmedTxsEmpty(client *mocks.Client, limit *int) { | ||
| client.On("UnconfirmedTxs", rpc.ContextWithHeight(1), limit). | ||
| Return(&tmrpctypes.ResultUnconfirmedTxs{ | ||
| Txs: make([]types.Tx, 2), | ||
| }, nil) | ||
| }, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterUnconfirmedTxsError(client *mocks.Client, limit *int) { | ||
| client.On("UnconfirmedTxs", rpc.ContextWithHeight(1), limit). | ||
| Return(nil, errortypes.ErrInvalidRequest) | ||
| Return(nil, errortypes.ErrInvalidRequest). | ||
| Maybe() | ||
| } | ||
|
|
||
| // Status | ||
| func RegisterStatus(client *mocks.Client) { | ||
| client.On("Status", rpc.ContextWithHeight(1)). | ||
| Return(&tmrpctypes.ResultStatus{}, nil) | ||
| Return(&tmrpctypes.ResultStatus{}, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterStatusError(client *mocks.Client) { | ||
| client.On("Status", rpc.ContextWithHeight(1)). | ||
| Return(nil, errortypes.ErrInvalidRequest) | ||
| Return(nil, errortypes.ErrInvalidRequest). | ||
| Maybe() | ||
| } | ||
|
|
||
| // Block | ||
|
|
@@ -97,7 +107,8 @@ func RegisterBlockMultipleTxs( | |
| block := types.MakeBlock(height, txs, nil, nil) | ||
| block.ChainID = ChainID | ||
| resBlock := &tmrpctypes.ResultBlock{Block: block} | ||
| client.On("Block", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")).Return(resBlock, nil) | ||
| client.On("Block", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")).Return(resBlock, nil). | ||
| Maybe() | ||
| return resBlock, nil | ||
| } | ||
|
|
||
|
|
@@ -111,22 +122,25 @@ func RegisterBlock( | |
| emptyBlock := types.MakeBlock(height, []types.Tx{}, nil, nil) | ||
| emptyBlock.ChainID = ChainID | ||
| resBlock := &tmrpctypes.ResultBlock{Block: emptyBlock} | ||
| client.On("Block", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")).Return(resBlock, nil) | ||
| client.On("Block", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")).Return(resBlock, nil). | ||
| Maybe() | ||
| return resBlock, nil | ||
| } | ||
|
|
||
| // with tx | ||
| block := types.MakeBlock(height, []types.Tx{tx}, nil, nil) | ||
| block.ChainID = ChainID | ||
| resBlock := &tmrpctypes.ResultBlock{Block: block} | ||
| client.On("Block", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")).Return(resBlock, nil) | ||
| client.On("Block", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")).Return(resBlock, nil). | ||
| Maybe() | ||
| return resBlock, nil | ||
| } | ||
|
|
||
| // Block returns error | ||
| func RegisterBlockError(client *mocks.Client, height int64) { | ||
| client.On("Block", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")). | ||
| Return(nil, errortypes.ErrInvalidRequest) | ||
| Return(nil, errortypes.ErrInvalidRequest). | ||
| Maybe() | ||
| } | ||
|
|
||
| // Block not found | ||
|
|
@@ -135,7 +149,8 @@ func RegisterBlockNotFound( | |
| height int64, | ||
| ) (*tmrpctypes.ResultBlock, error) { | ||
| client.On("Block", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")). | ||
| Return(&tmrpctypes.ResultBlock{Block: nil}, nil) | ||
| Return(&tmrpctypes.ResultBlock{Block: nil}, nil). | ||
| Maybe() | ||
|
|
||
| return &tmrpctypes.ResultBlock{Block: nil}, nil | ||
| } | ||
|
|
@@ -145,7 +160,8 @@ func RegisterBlockPanic(client *mocks.Client, height int64) { | |
| client.On("Block", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")). | ||
| Return(func(context.Context, *int64) *tmrpctypes.ResultBlock { | ||
| panic("Block call panic") | ||
| }, nil) | ||
| }, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| func TestRegisterBlock(t *testing.T) { | ||
|
|
@@ -166,12 +182,14 @@ func TestRegisterBlock(t *testing.T) { | |
| func RegisterConsensusParams(client *mocks.Client, height int64) { | ||
| consensusParams := types.DefaultConsensusParams() | ||
| client.On("ConsensusParams", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")). | ||
| Return(&tmrpctypes.ResultConsensusParams{ConsensusParams: *consensusParams}, nil) | ||
| Return(&tmrpctypes.ResultConsensusParams{ConsensusParams: *consensusParams}, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterConsensusParamsError(client *mocks.Client, height int64) { | ||
| client.On("ConsensusParams", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")). | ||
| Return(nil, errortypes.ErrInvalidRequest) | ||
| Return(nil, errortypes.ErrInvalidRequest). | ||
| Maybe() | ||
| } | ||
|
|
||
| func TestRegisterConsensusParams(t *testing.T) { | ||
|
|
@@ -209,7 +227,8 @@ func RegisterBlockResultsWithEventLog(client *mocks.Client, height int64) (*tmrp | |
| } | ||
|
|
||
| client.On("BlockResults", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")). | ||
| Return(res, nil) | ||
| Return(res, nil). | ||
| Maybe() | ||
| return res, nil | ||
| } | ||
|
|
||
|
|
@@ -223,13 +242,15 @@ func RegisterBlockResults( | |
| } | ||
|
|
||
| client.On("BlockResults", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")). | ||
| Return(res, nil) | ||
| Return(res, nil). | ||
| Maybe() | ||
| return res, nil | ||
| } | ||
|
|
||
| func RegisterBlockResultsError(client *mocks.Client, height int64) { | ||
| client.On("BlockResults", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")). | ||
| Return(nil, errortypes.ErrInvalidRequest) | ||
| Return(nil, errortypes.ErrInvalidRequest). | ||
| Maybe() | ||
| } | ||
|
|
||
| func TestRegisterBlockResults(t *testing.T) { | ||
|
|
@@ -256,18 +277,21 @@ func RegisterBlockByHash( | |
| resBlock := &tmrpctypes.ResultBlock{Block: block} | ||
|
|
||
| client.On("BlockByHash", rpc.ContextWithHeight(1), []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}). | ||
| Return(resBlock, nil) | ||
| Return(resBlock, nil). | ||
| Maybe() | ||
| return resBlock, nil | ||
| } | ||
|
|
||
| func RegisterBlockByHashError(client *mocks.Client, hash common.Hash, tx []byte) { | ||
| client.On("BlockByHash", rpc.ContextWithHeight(1), []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}). | ||
| Return(nil, errortypes.ErrInvalidRequest) | ||
| Return(nil, errortypes.ErrInvalidRequest). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterBlockByHashNotFound(client *mocks.Client, hash common.Hash, tx []byte) { | ||
| client.On("BlockByHash", rpc.ContextWithHeight(1), []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}). | ||
| Return(nil, nil) | ||
| Return(nil, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| // HeaderByHash | ||
|
|
@@ -280,36 +304,47 @@ func RegisterHeaderByHash( | |
| resHeader := &tmrpctypes.ResultHeader{Header: &block.Header} | ||
|
|
||
| client.On("HeaderByHash", rpc.ContextWithHeight(1), bytes.HexBytes(hash.Bytes())). | ||
| Return(resHeader, nil) | ||
| Return(resHeader, nil). | ||
| Maybe() | ||
| return resHeader, nil | ||
| } | ||
|
|
||
| func RegisterHeaderByHashError(client *mocks.Client, hash common.Hash, tx []byte) { | ||
| client.On("HeaderByHash", rpc.ContextWithHeight(1), bytes.HexBytes(hash.Bytes())). | ||
| Return(nil, errortypes.ErrInvalidRequest) | ||
| Return(nil, errortypes.ErrInvalidRequest). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterHeaderByHashNotFound(client *mocks.Client, hash common.Hash, tx []byte) { | ||
| client.On("HeaderByHash", rpc.ContextWithHeight(1), bytes.HexBytes(hash.Bytes())). | ||
| Return(&tmrpctypes.ResultHeader{Header: nil}, nil) | ||
| Return(&tmrpctypes.ResultHeader{Header: nil}, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterHeaderByHashAny(client *mocks.Client) { | ||
| client.On("HeaderByHash", mock.Anything, mock.Anything). | ||
| Return(&tmrpctypes.ResultHeader{Header: &types.Header{Height: 1}}, nil).Maybe() | ||
| } | ||
|
|
||
| // Header | ||
| func RegisterHeader(client *mocks.Client, height *int64, tx []byte) (*tmrpctypes.ResultHeader, error) { | ||
| block := types.MakeBlock(*height, []types.Tx{tx}, nil, nil) | ||
| resHeader := &tmrpctypes.ResultHeader{Header: &block.Header} | ||
| client.On("Header", rpc.ContextWithHeight(*height), height).Return(resHeader, nil) | ||
| client.On("Header", rpc.ContextWithHeight(*height), height).Return(resHeader, nil). | ||
| Maybe() | ||
| return resHeader, nil | ||
| } | ||
|
|
||
| func RegisterHeaderError(client *mocks.Client, height *int64) { | ||
| client.On("Header", rpc.ContextWithHeight(*height), height).Return(nil, errortypes.ErrInvalidRequest) | ||
| client.On("Header", rpc.ContextWithHeight(*height), height).Return(nil, errortypes.ErrInvalidRequest). | ||
| Maybe() | ||
| } | ||
|
|
||
| // Header not found | ||
| func RegisterHeaderNotFound(client *mocks.Client, height int64) { | ||
| client.On("Header", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")). | ||
| Return(&tmrpctypes.ResultHeader{Header: nil}, nil) | ||
| Return(&tmrpctypes.ResultHeader{Header: nil}, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterABCIQueryWithOptions(client *mocks.Client, height int64, path string, data bytes.HexBytes, opts tmrpcclient.ABCIQueryOptions) { | ||
|
|
@@ -319,12 +354,26 @@ func RegisterABCIQueryWithOptions(client *mocks.Client, height int64, path strin | |
| Value: []byte{2}, // TODO replace with data.Bytes(), | ||
| Height: height, | ||
| }, | ||
| }, nil) | ||
| }, nil). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterABCIQueryWithOptionsError(clients *mocks.Client, path string, data bytes.HexBytes, opts tmrpcclient.ABCIQueryOptions) { | ||
| clients.On("ABCIQueryWithOptions", context.Background(), path, data, opts). | ||
| Return(nil, errortypes.ErrInvalidRequest) | ||
| Return(nil, errortypes.ErrInvalidRequest). | ||
| Maybe() | ||
| } | ||
|
|
||
| func RegisterABCIQueryAny(client *mocks.Client, height int64) { | ||
| client.On("ABCIQueryWithOptions", context.Background(), mock.Anything, mock.Anything, mock.Anything). | ||
| Return(&tmrpctypes.ResultABCIQuery{ | ||
| Response: abci.ResponseQuery{ | ||
| Value: []byte{2}, // TODO replace with data.Bytes(), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. todo not done? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah not sure, just copying from above |
||
| Height: height, | ||
| }, | ||
| }, nil). | ||
| Maybe() | ||
|
|
||
| } | ||
|
|
||
| func RegisterABCIQueryAccount(clients *mocks.Client, data bytes.HexBytes, opts tmrpcclient.ABCIQueryOptions, acc client.Account) { | ||
|
|
@@ -338,5 +387,6 @@ func RegisterABCIQueryAccount(clients *mocks.Client, data bytes.HexBytes, opts t | |
| Value: respBz, | ||
| Height: 1, | ||
| }, | ||
| }, nil) | ||
| }, nil). | ||
| Maybe() | ||
| } | ||
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.
why is this check here within the nonce check?
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.
line below requires non null