github.com/iotexproject/iotex-core@v1.14.1-rc1/action/protocol/staking/ethabi/stake_composite_bucketsbyindices_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 TestBuildReadStateRequestCompositeBucketsByIndexes(t *testing.T) { 14 r := require.New(t) 15 16 // data, err := _compositeBucketsByIndexesMethod.Inputs.Pack([]uint64{1, 2}) 17 // r.NoError(err) 18 // data = append(_compositeBucketsByIndexesMethod.ID, data...) 19 // t.Logf("data: %s", hex.EncodeToString(data)) 20 21 data, _ := hex.DecodeString("347cdbd50000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002") 22 req, err := BuildReadStateRequest(data) 23 24 r.Nil(err) 25 r.EqualValues("*ethabi.CompositeBucketsByIndexesStateContext", reflect.TypeOf(req).String()) 26 27 method := &iotexapi.ReadStakingDataMethod{ 28 Method: iotexapi.ReadStakingDataMethod_COMPOSITE_BUCKETS_BY_INDEXES, 29 } 30 methodBytes, _ := proto.Marshal(method) 31 r.EqualValues(methodBytes, req.Parameters().MethodName) 32 33 arguments := &iotexapi.ReadStakingDataRequest{ 34 Request: &iotexapi.ReadStakingDataRequest_BucketsByIndexes{ 35 BucketsByIndexes: &iotexapi.ReadStakingDataRequest_VoteBucketsByIndexes{ 36 Index: []uint64{1, 2}, 37 }, 38 }, 39 } 40 argumentsBytes, _ := proto.Marshal(arguments) 41 r.EqualValues([][]byte{argumentsBytes}, req.Parameters().Arguments) 42 }