github.com/iotexproject/iotex-core@v1.14.1-rc1/action/protocol/rewarding/ethabi/base_test.go (about) 1 package ethabi 2 3 import ( 4 "encoding/hex" 5 "testing" 6 7 "github.com/stretchr/testify/require" 8 ) 9 10 func TestBuildReadStateRequest(t *testing.T) { 11 r := require.New(t) 12 13 data, _ := hex.DecodeString("1234") 14 ctx, err := BuildReadStateRequest(data) 15 r.Nil(ctx) 16 r.EqualError(errInvalidCallData, err.Error()) 17 18 data, _ = hex.DecodeString("12345678") 19 ctx, err = BuildReadStateRequest(data) 20 r.Nil(ctx) 21 r.EqualError(errInvalidCallSig, err.Error()) 22 23 data, _ = hex.DecodeString("ad7a672f") 24 ctx, err = BuildReadStateRequest(data) 25 r.Nil(err) 26 r.IsType(&TotalBalanceStateContext{}, ctx) 27 28 data, _ = hex.DecodeString("ab2f0e51") 29 ctx, err = BuildReadStateRequest(data) 30 r.Nil(err) 31 r.IsType(&AvailableBalanceStateContext{}, ctx) 32 33 data, _ = hex.DecodeString("01cbf5fb0000000000000000000000000000000000000000000000000000000000000001") 34 ctx, err = BuildReadStateRequest(data) 35 r.Nil(err) 36 r.IsType(&UnclaimedBalanceStateContext{}, ctx) 37 }