github.com/iotexproject/iotex-core@v1.14.1-rc1/action/protocol/staking/ethabi/stake_composite_bucketsbyvoter_test.go (about) 1 package ethabi 2 3 import ( 4 "encoding/hex" 5 "reflect" 6 "testing" 7 8 "github.com/iotexproject/iotex-proto/golang/iotexapi" 9 "github.com/stretchr/testify/require" 10 "google.golang.org/protobuf/proto" 11 ) 12 13 func TestBuildReadStateRequestCompositeBucketsByVoter(t *testing.T) { 14 r := require.New(t) 15 16 // addr, err := address.FromString("io1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqryn4k9fw") 17 // r.NoError(err) 18 // data, err := _compositeBucketsByVoterMethod.Inputs.Pack(common.BytesToAddress(addr.Bytes()), uint32(1), uint32(2)) 19 // r.NoError(err) 20 // data = append(_compositeBucketsByVoterMethod.ID, data...) 21 // t.Logf("data: %s", hex.EncodeToString(data)) 22 23 data, _ := hex.DecodeString("80965570000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002") 24 req, err := BuildReadStateRequest(data) 25 26 r.Nil(err) 27 r.EqualValues("*ethabi.CompositeBucketsByVoterStateContext", reflect.TypeOf(req).String()) 28 29 method := &iotexapi.ReadStakingDataMethod{ 30 Method: iotexapi.ReadStakingDataMethod_COMPOSITE_BUCKETS_BY_VOTER, 31 } 32 methodBytes, _ := proto.Marshal(method) 33 r.EqualValues(methodBytes, req.Parameters().MethodName) 34 35 arguments := &iotexapi.ReadStakingDataRequest{ 36 Request: &iotexapi.ReadStakingDataRequest_BucketsByVoter{ 37 BucketsByVoter: &iotexapi.ReadStakingDataRequest_VoteBucketsByVoter{ 38 VoterAddress: "io1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqryn4k9fw", 39 Pagination: &iotexapi.PaginationParam{ 40 Offset: 1, 41 Limit: 2, 42 }, 43 }, 44 }, 45 } 46 argumentsBytes, _ := proto.Marshal(arguments) 47 r.EqualValues([][]byte{argumentsBytes}, req.Parameters().Arguments) 48 }