fix: String representation of escrow address (#238)

* greedy approach to lane verification

* docs

* base lane testing

* mev lane testing nits

* abci top level testing done

* network spamming in E2E

* string rep of escrow address

* nit

* removing logs from testing

* query test
This commit is contained in:
David Terpay 2023-11-27 17:10:43 -05:00 committed by GitHub
parent f7dfbda2b1
commit 736b2d3997
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 108 additions and 24 deletions

View File

@ -22,6 +22,9 @@ message QueryParamsRequest {}
// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
// Params defines the parameters of the module.
Params params = 1 [ (gogoproto.nullable) = false ];
// EscrowAddressString is the string representation of the escrow address stored
// in params.
string escrow_address_string = 2;
}

View File

@ -29,5 +29,6 @@ func (q QueryServer) Params(c context.Context, _ *types.QueryParamsRequest) (*ty
return nil, err
}
return &types.QueryParamsResponse{Params: params}, nil
escrowAddress := sdk.AccAddress(params.EscrowAccountAddress)
return &types.QueryParamsResponse{Params: params, EscrowAddressString: escrowAddress.String()}, nil
}

View File

@ -0,0 +1,21 @@
package keeper_test
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/skip-mev/block-sdk/x/auction/types"
)
func (s *KeeperTestSuite) TestQueryParams() {
s.Run("can query module params", func() {
params, err := s.auctionkeeper.GetParams(s.ctx)
s.Require().NoError(err)
escrowAddress := sdk.AccAddress(params.EscrowAccountAddress)
res, err := s.queryServer.Params(s.ctx, &types.QueryParamsRequest{})
s.Require().NoError(err)
s.Require().Equal(params, res.Params)
s.Require().Equal(escrowAddress.String(), res.EscrowAddressString)
})
}

View File

@ -25,9 +25,11 @@ type KeeperTestSuite struct {
stakingKeeper *mocks.StakingKeeper
encCfg testutils.EncodingConfig
ctx sdk.Context
msgServer types.MsgServer
key *storetypes.KVStoreKey
authorityAccount sdk.AccAddress
msgServer types.MsgServer
queryServer types.QueryServer
}
func TestKeeperTestSuite(t *testing.T) {
@ -61,4 +63,5 @@ func (s *KeeperTestSuite) SetupTest() {
s.Require().NoError(err)
s.msgServer = keeper.NewMsgServerImpl(s.auctionkeeper)
s.queryServer = keeper.NewQueryServer(s.auctionkeeper)
}

View File

@ -69,8 +69,11 @@ var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo
// QueryParamsResponse is the response type for the Query/Params RPC method.
type QueryParamsResponse struct {
// params defines the parameters of the module.
// Params defines the parameters of the module.
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
// EscrowAddressString is the string representation of the escrow address stored
// in params.
EscrowAddressString string `protobuf:"bytes,2,opt,name=escrow_address_string,json=escrowAddressString,proto3" json:"escrow_address_string,omitempty"`
}
func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} }
@ -113,6 +116,13 @@ func (m *QueryParamsResponse) GetParams() Params {
return Params{}
}
func (m *QueryParamsResponse) GetEscrowAddressString() string {
if m != nil {
return m.EscrowAddressString
}
return ""
}
func init() {
proto.RegisterType((*QueryParamsRequest)(nil), "sdk.auction.v1.QueryParamsRequest")
proto.RegisterType((*QueryParamsResponse)(nil), "sdk.auction.v1.QueryParamsResponse")
@ -121,26 +131,29 @@ func init() {
func init() { proto.RegisterFile("sdk/auction/v1/query.proto", fileDescriptor_47f76418be29a6d6) }
var fileDescriptor_47f76418be29a6d6 = []byte{
// 303 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2a, 0x4e, 0xc9, 0xd6,
0x4f, 0x2c, 0x4d, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, 0x2f, 0x33, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa,
0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x2b, 0x4e, 0xc9, 0xd6, 0x83, 0xca, 0xe9, 0x95,
0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xa5, 0xf4, 0x41, 0x2c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, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x6e, 0x7a,
0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x71, 0x76, 0x66, 0x81, 0x6e, 0x6e,
0x6a, 0x19, 0x92, 0x51, 0x15, 0x70, 0xc3, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x41,
0x67, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x23, 0x86, 0x8c, 0xe6, 0xd7, 0x01, 0x00, 0x00,
// 341 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xc1, 0x4a, 0xc3, 0x40,
0x10, 0x86, 0xb3, 0x45, 0x0b, 0x46, 0xf0, 0x90, 0x56, 0x29, 0xb1, 0xc4, 0x12, 0x2f, 0x55, 0x68,
0x96, 0x56, 0x5f, 0xc0, 0x5e, 0xbc, 0x6a, 0xbd, 0x79, 0x29, 0xdb, 0x64, 0x59, 0x43, 0x9a, 0x4c,
0x9a, 0xd9, 0x54, 0x0b, 0x82, 0x20, 0x08, 0x1e, 0x05, 0x5f, 0xc4, 0xc7, 0xe8, 0xb1, 0xe0, 0xc5,
0x93, 0x48, 0x2b, 0xf8, 0x1a, 0xd2, 0x6c, 0x10, 0x1b, 0xc1, 0x5b, 0x98, 0xef, 0xcb, 0x3f, 0xff,
0x8e, 0x6e, 0xa2, 0x17, 0x50, 0x96, 0xba, 0xd2, 0x87, 0x88, 0x8e, 0xdb, 0x74, 0x94, 0xf2, 0x64,
0xe2, 0xc4, 0x09, 0x48, 0x30, 0xb6, 0xd0, 0x0b, 0x9c, 0x9c, 0x39, 0xe3, 0xb6, 0x59, 0x15, 0x20,
0x20, 0x43, 0x74, 0xf9, 0xa5, 0x2c, 0xb3, 0x2e, 0x00, 0xc4, 0x90, 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 0x21, 0xa4, 0x18, 0xf8, 0x71, 0x2b, 0xe4, 0xe3, 0x5f, 0x51, 0x37, 0x3f, 0x61, 0x72,
0x12, 0x73, 0x1c, 0x94, 0xb3, 0x73, 0x1f, 0x7d, 0x07, 0x00, 0x00, 0xff, 0xff, 0x1f, 0x3e, 0x57,
0xb0, 0x0b, 0x02, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -268,6 +281,13 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.EscrowAddressString) > 0 {
i -= len(m.EscrowAddressString)
copy(dAtA[i:], m.EscrowAddressString)
i = encodeVarintQuery(dAtA, i, uint64(len(m.EscrowAddressString)))
i--
dAtA[i] = 0x12
}
{
size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
@ -309,6 +329,10 @@ func (m *QueryParamsResponse) Size() (n int) {
_ = l
l = m.Params.Size()
n += 1 + l + sovQuery(uint64(l))
l = len(m.EscrowAddressString)
if l > 0 {
n += 1 + l + sovQuery(uint64(l))
}
return n
}
@ -430,6 +454,38 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field EscrowAddressString", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthQuery
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.EscrowAddressString = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipQuery(dAtA[iNdEx:])