From 1fa0fddc02dc9e2323ebe66e1dd08286d73598f7 Mon Sep 17 00:00:00 2001 From: millken Date: Mon, 5 Dec 2022 14:46:21 +0800 Subject: [PATCH 1/5] validate candidate name in CandidateRegister action --- action/candidate_register.go | 7 +++++++ action/candidateregister_test.go | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/action/candidate_register.go b/action/candidate_register.go index 9de45207a6..2d78fec276 100644 --- a/action/candidate_register.go +++ b/action/candidate_register.go @@ -18,6 +18,7 @@ import ( "google.golang.org/protobuf/proto" "github.com/iotexproject/iotex-address/address" + "github.com/iotexproject/iotex-core/ioctl/validator" "github.com/iotexproject/iotex-core/pkg/util/byteutil" "github.com/iotexproject/iotex-core/pkg/version" "github.com/iotexproject/iotex-proto/golang/iotextypes" @@ -87,6 +88,9 @@ var ( // ErrInvalidAmount represents that amount is 0 or negative ErrInvalidAmount = errors.New("invalid amount") + + //ErrInvalidCandidateName represents that candidate name is invalid + ErrInvalidCandidateName = errors.New("invalid candidate name") ) // CandidateRegister is the action to register a candidate @@ -289,6 +293,9 @@ func (cr *CandidateRegister) SanityCheck() error { if cr.Amount().Sign() <= 0 { return errors.Wrap(ErrInvalidAmount, "negative value") } + if err := validator.ValidateCandidateNameForStake2(cr.Name()); err != nil { + return errors.Wrap(ErrInvalidCandidateName, err.Error()) + } return cr.AbstractAction.SanityCheck() } diff --git a/action/candidateregister_test.go b/action/candidateregister_test.go index c1fb35affd..74d7ba7ae3 100644 --- a/action/candidateregister_test.go +++ b/action/candidateregister_test.go @@ -50,6 +50,18 @@ var candidateRegisterTestParams = []struct { { identityset.PrivateKey(27), uint64(10), "test", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "ab-10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", ErrInvalidAmount, nil, }, + // invalid candidate name + { + identityset.PrivateKey(27), uint64(10), "F@¥", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidCandidateName, + }, + // invalid candidate name + { + identityset.PrivateKey(27), uint64(10), "", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidCandidateName, + }, + // invalid candidate name + { + identityset.PrivateKey(27), uint64(10), "aaaaaaaaaaaaa", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidCandidateName, + }, { identityset.PrivateKey(27), uint64(10), "test", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "-10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidAmount, }, From 15ae4d2efc908ced00a4e4c9d2a4e9524ab15889 Mon Sep 17 00:00:00 2001 From: millken Date: Wed, 7 Dec 2022 09:50:39 +0800 Subject: [PATCH 2/5] use local isValidCandidateName --- action/candidate_register.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/action/candidate_register.go b/action/candidate_register.go index 2d78fec276..dc5c94f1f6 100644 --- a/action/candidate_register.go +++ b/action/candidate_register.go @@ -18,7 +18,6 @@ import ( "google.golang.org/protobuf/proto" "github.com/iotexproject/iotex-address/address" - "github.com/iotexproject/iotex-core/ioctl/validator" "github.com/iotexproject/iotex-core/pkg/util/byteutil" "github.com/iotexproject/iotex-core/pkg/version" "github.com/iotexproject/iotex-proto/golang/iotextypes" @@ -293,8 +292,8 @@ func (cr *CandidateRegister) SanityCheck() error { if cr.Amount().Sign() <= 0 { return errors.Wrap(ErrInvalidAmount, "negative value") } - if err := validator.ValidateCandidateNameForStake2(cr.Name()); err != nil { - return errors.Wrap(ErrInvalidCandidateName, err.Error()) + if err := isValidCandidateName(cr.Name()); err != nil { + return err } return cr.AbstractAction.SanityCheck() @@ -366,6 +365,18 @@ func NewCandidateRegisterFromABIBinary(data []byte) (*CandidateRegister, error) return &cr, nil } +func isValidCandidateName(candidateName string) error { + if len(candidateName) == 0 || len(candidateName) > 12 { + return ErrInvalidCandidateName + } + for _, c := range candidateName { + if !(('a' <= c && c <= 'z') || ('0' <= c && c <= '9')) { + return ErrInvalidCandidateName + } + } + return nil +} + func ethAddrToNativeAddr(in interface{}) (address.Address, error) { ethAddr, ok := in.(common.Address) if !ok { From 8d7f7e6123d0195cc614219104e5bfe6e1353ef1 Mon Sep 17 00:00:00 2001 From: millken Date: Thu, 8 Dec 2022 16:54:37 +0800 Subject: [PATCH 3/5] update candidate name validate --- action/candidate_register.go | 16 ++-------------- action/candidate_update.go | 4 ++++ action/candidateregister_test.go | 6 +++--- action/candidateupdate_test.go | 6 +++++- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/action/candidate_register.go b/action/candidate_register.go index eaa35de0d9..79b110e41c 100644 --- a/action/candidate_register.go +++ b/action/candidate_register.go @@ -292,8 +292,8 @@ func (cr *CandidateRegister) SanityCheck() error { if cr.Amount().Sign() <= 0 { return errors.Wrap(ErrInvalidAmount, "negative value") } - if err := isValidCandidateName(cr.Name()); err != nil { - return err + if !IsValidCandidateName(cr.Name()) { + return ErrInvalidCanName } return cr.AbstractAction.SanityCheck() @@ -365,18 +365,6 @@ func NewCandidateRegisterFromABIBinary(data []byte) (*CandidateRegister, error) return &cr, nil } -func isValidCandidateName(candidateName string) error { - if len(candidateName) == 0 || len(candidateName) > 12 { - return ErrInvalidCandidateName - } - for _, c := range candidateName { - if !(('a' <= c && c <= 'z') || ('0' <= c && c <= '9')) { - return ErrInvalidCandidateName - } - } - return nil -} - func ethAddrToNativeAddr(in interface{}) (address.Address, error) { ethAddr, ok := in.(common.Address) if !ok { diff --git a/action/candidate_update.go b/action/candidate_update.go index 957b71b691..eee119ccfb 100644 --- a/action/candidate_update.go +++ b/action/candidate_update.go @@ -111,6 +111,10 @@ func NewCandidateUpdate( return nil, err } } + + if !IsValidCandidateName(name) { + return nil, ErrInvalidCanName + } return cu, nil } diff --git a/action/candidateregister_test.go b/action/candidateregister_test.go index 1634486c00..45fb9fd636 100644 --- a/action/candidateregister_test.go +++ b/action/candidateregister_test.go @@ -52,15 +52,15 @@ var candidateRegisterTestParams = []struct { }, // invalid candidate name { - identityset.PrivateKey(27), uint64(10), "F@¥", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidCandidateName, + identityset.PrivateKey(27), uint64(10), "F@¥", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidCanName, }, // invalid candidate name { - identityset.PrivateKey(27), uint64(10), "", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidCandidateName, + identityset.PrivateKey(27), uint64(10), "", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidCanName, }, // invalid candidate name { - identityset.PrivateKey(27), uint64(10), "aaaaaaaaaaaaa", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidCandidateName, + identityset.PrivateKey(27), uint64(10), "aaaaaaaaaaaaa", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidCanName, }, { identityset.PrivateKey(27), uint64(10), "test", "io10a298zmzvrt4guq79a9f4x7qedj59y7ery84he", "io13sj9mzpewn25ymheukte4v39hvjdtrfp00mlyv", "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "-10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidAmount, diff --git a/action/candidateupdate_test.go b/action/candidateupdate_test.go index 47c2333332..7883290d48 100644 --- a/action/candidateupdate_test.go +++ b/action/candidateupdate_test.go @@ -26,7 +26,11 @@ var ( func TestCandidateUpdate(t *testing.T) { require := require.New(t) - cu, err := NewCandidateUpdate(_cuNonce, _cuName, _cuOperatorAddrStr, _cuRewardAddrStr, _cuGasLimit, _cuGasPrice) + cu, err := NewCandidateUpdate(_cuNonce, "", _cuOperatorAddrStr, _cuRewardAddrStr, _cuGasLimit, _cuGasPrice) + require.ErrorIs(err, ErrInvalidCanName) + cu, err = NewCandidateUpdate(_cuNonce, "aaaaaaaaaaaaa", _cuOperatorAddrStr, _cuRewardAddrStr, _cuGasLimit, _cuGasPrice) + require.ErrorIs(err, ErrInvalidCanName) + cu, err = NewCandidateUpdate(_cuNonce, _cuName, _cuOperatorAddrStr, _cuRewardAddrStr, _cuGasLimit, _cuGasPrice) require.NoError(err) ser := cu.Serialize() From 37b11650df17b605ae85bdc2f209a9d9f0b8b85a Mon Sep 17 00:00:00 2001 From: millken Date: Fri, 9 Dec 2022 11:15:31 +0800 Subject: [PATCH 4/5] update candidate name validate --- action/candidate_update.go | 13 +++++++++---- action/stake_changecandidate.go | 8 ++++++++ action/stake_create.go | 4 +++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/action/candidate_update.go b/action/candidate_update.go index eee119ccfb..4df4d50e27 100644 --- a/action/candidate_update.go +++ b/action/candidate_update.go @@ -111,10 +111,6 @@ func NewCandidateUpdate( return nil, err } } - - if !IsValidCandidateName(name) { - return nil, ErrInvalidCanName - } return cu, nil } @@ -190,6 +186,15 @@ func (cu *CandidateUpdate) Cost() (*big.Int, error) { return fee, nil } +// SanityCheck validates the variables in the action +func (cu *CandidateUpdate) SanityCheck() error { + if !IsValidCandidateName(cu.Name()) { + return ErrInvalidCanName + } + + return cu.AbstractAction.SanityCheck() +} + // EncodeABIBinary encodes data in abi encoding func (cu *CandidateUpdate) EncodeABIBinary() ([]byte, error) { return cu.encodeABIBinary() diff --git a/action/stake_changecandidate.go b/action/stake_changecandidate.go index be3a239e9c..a937a86ba1 100644 --- a/action/stake_changecandidate.go +++ b/action/stake_changecandidate.go @@ -159,6 +159,14 @@ func (cc *ChangeCandidate) Cost() (*big.Int, error) { return changeCandidateFee, nil } +// SanityCheck validates the variables in the action +func (cc *ChangeCandidate) SanityCheck() error { + if !IsValidCandidateName(cc.candidateName) { + return ErrInvalidCanName + } + return cc.AbstractAction.SanityCheck() +} + // EncodeABIBinary encodes data in abi encoding func (cc *ChangeCandidate) EncodeABIBinary() ([]byte, error) { return cc.encodeABIBinary() diff --git a/action/stake_create.go b/action/stake_create.go index 870da35495..6e0716854a 100644 --- a/action/stake_create.go +++ b/action/stake_create.go @@ -211,7 +211,9 @@ func (cs *CreateStake) SanityCheck() error { if cs.Amount().Sign() <= 0 { return errors.Wrap(ErrInvalidAmount, "negative value") } - + if !IsValidCandidateName(cs.candName) { + return ErrInvalidCanName + } return cs.AbstractAction.SanityCheck() } From eabd05248b9b297f11ffa60d3e741ab8c02b4ed9 Mon Sep 17 00:00:00 2001 From: millken Date: Fri, 9 Dec 2022 16:26:15 +0800 Subject: [PATCH 5/5] update candidate name validate --- action/candidateupdate_test.go | 6 +----- action/stake_changecandidate_test.go | 20 ++++++++++---------- action/stakecreate_test.go | 10 +++++----- action/stakereclaim_test.go | 1 + 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/action/candidateupdate_test.go b/action/candidateupdate_test.go index 7883290d48..47c2333332 100644 --- a/action/candidateupdate_test.go +++ b/action/candidateupdate_test.go @@ -26,11 +26,7 @@ var ( func TestCandidateUpdate(t *testing.T) { require := require.New(t) - cu, err := NewCandidateUpdate(_cuNonce, "", _cuOperatorAddrStr, _cuRewardAddrStr, _cuGasLimit, _cuGasPrice) - require.ErrorIs(err, ErrInvalidCanName) - cu, err = NewCandidateUpdate(_cuNonce, "aaaaaaaaaaaaa", _cuOperatorAddrStr, _cuRewardAddrStr, _cuGasLimit, _cuGasPrice) - require.ErrorIs(err, ErrInvalidCanName) - cu, err = NewCandidateUpdate(_cuNonce, _cuName, _cuOperatorAddrStr, _cuRewardAddrStr, _cuGasLimit, _cuGasPrice) + cu, err := NewCandidateUpdate(_cuNonce, _cuName, _cuOperatorAddrStr, _cuRewardAddrStr, _cuGasLimit, _cuGasPrice) require.NoError(err) ser := cu.Serialize() diff --git a/action/stake_changecandidate_test.go b/action/stake_changecandidate_test.go index 8322befabe..9e1655e426 100644 --- a/action/stake_changecandidate_test.go +++ b/action/stake_changecandidate_test.go @@ -18,11 +18,11 @@ import ( func TestChangeCandidate(t *testing.T) { require := require.New(t) - stake, err := NewChangeCandidate(_nonce, _canAddress, _index, _payload, _gaslimit, _gasprice) + stake, err := NewChangeCandidate(_nonce, _canName, _index, _payload, _gaslimit, _gasprice) require.NoError(err) ser := stake.Serialize() - require.Equal("080a1229696f3178707136326177383575717a72636367397935686e727976386c64326e6b7079636333677a611a077061796c6f6164", hex.EncodeToString(ser)) + require.Equal("080a120a63616e646964617465311a077061796c6f6164", hex.EncodeToString(ser)) require.NoError(err) require.Equal(_gaslimit, stake.GasLimit()) @@ -30,7 +30,7 @@ func TestChangeCandidate(t *testing.T) { require.Equal(_nonce, stake.Nonce()) require.Equal(_payload, stake.Payload()) - require.Equal(_canAddress, stake.Candidate()) + require.Equal(_canName, stake.Candidate()) require.Equal(_index, stake.BucketIndex()) gas, err := stake.IntrinsicGas() @@ -44,11 +44,11 @@ func TestChangeCandidate(t *testing.T) { stake2 := &ChangeCandidate{} require.NoError(stake2.LoadProto(proto)) require.Equal(_payload, stake2.Payload()) - require.Equal(_canAddress, stake2.Candidate()) + require.Equal(_canName, stake2.Candidate()) require.Equal(_index, stake2.BucketIndex()) t.Run("Invalid Gas Price", func(t *testing.T) { - cc, err := NewChangeCandidate(_nonce, _canAddress, _index, _payload, _gaslimit, new(big.Int).Mul(_gasprice, big.NewInt(-1))) + cc, err := NewChangeCandidate(_nonce, _canName, _index, _payload, _gaslimit, new(big.Int).Mul(_gasprice, big.NewInt(-1))) require.NoError(err) require.Equal(ErrNegativeValue, errors.Cause(cc.SanityCheck())) }) @@ -57,7 +57,7 @@ func TestChangeCandidate(t *testing.T) { func TestChangeCandidateSignVerify(t *testing.T) { require := require.New(t) require.Equal("cfa6ef757dee2e50351620dca002d32b9c090cfda55fb81f37f1d26b273743f1", _senderKey.HexString()) - stake, err := NewChangeCandidate(_nonce, _canAddress, _index, _payload, _gaslimit, _gasprice) + stake, err := NewChangeCandidate(_nonce, _canName, _index, _payload, _gaslimit, _gasprice) require.NoError(err) bd := &EnvelopeBuilder{} @@ -70,24 +70,24 @@ func TestChangeCandidateSignVerify(t *testing.T) { require.NotNil(selp) ser, err := proto.Marshal(selp.Proto()) require.NoError(err) - require.Equal("0a43080118c0843d22023130ea0236080a1229696f3178707136326177383575717a72636367397935686e727976386c64326e6b7079636333677a611a077061796c6f6164124104755ce6d8903f6b3793bddb4ea5d3589d637de2d209ae0ea930815c82db564ee8cc448886f639e8a0c7e94e99a5c1335b583c0bc76ef30dd6a1038ed9da8daf331a41d519eb3747163b945b862989b7e82a7f8468001e9683757cb88d5ddd95f81895047429e858bd48f7d59a88bfec92de231d216293aeba1e4fbe11461d9c9fc99801", hex.EncodeToString(ser)) + require.Equal("0a24080118c0843d22023130ea0217080a120a63616e646964617465311a077061796c6f6164124104755ce6d8903f6b3793bddb4ea5d3589d637de2d209ae0ea930815c82db564ee8cc448886f639e8a0c7e94e99a5c1335b583c0bc76ef30dd6a1038ed9da8daf331a412da6cd3ba7e830f0b669661f88a5c03307bdb44cae6fb45a4432ab69719f051f6631276467977617be2d265fdb00a3acc3a493261e2363a60acd3512aa15a89301", hex.EncodeToString(ser)) hash, err := selp.Hash() require.NoError(err) - require.Equal("186526b5b9fe74e25beb52c83c41780a69108160bef2ddaf3bffb9f1f1e5e73a", hex.EncodeToString(hash[:])) + require.Equal("bc65d832237134c6a38d6ba10637af097b432d6c83d267aa6235e5b7c953d30f", hex.EncodeToString(hash[:])) // verify signature require.NoError(selp.VerifySignature()) } func TestChangeCandidateABIEncodeAndDecode(t *testing.T) { require := require.New(t) - stake, err := NewChangeCandidate(_nonce, _canAddress, _index, _payload, _gaslimit, _gasprice) + stake, err := NewChangeCandidate(_nonce, _canName, _index, _payload, _gaslimit, _gasprice) require.NoError(err) data, err := stake.EncodeABIBinary() require.NoError(err) stake, err = NewChangeCandidateFromABIBinary(data) require.NoError(err) - require.Equal(_canAddress, stake.candidateName) + require.Equal(_canName, stake.candidateName) require.Equal(_index, stake.bucketIndex) require.Equal(_payload, stake.payload) } diff --git a/action/stakecreate_test.go b/action/stakecreate_test.go index 0ee078e2bd..75ca875def 100644 --- a/action/stakecreate_test.go +++ b/action/stakecreate_test.go @@ -42,20 +42,20 @@ var stakeCreateTestParams = []struct { }{ // valid test { - identityset.PrivateKey(27), uint64(10), "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "100", uint32(10000), true, []byte("payload"), uint64(1000000), big.NewInt(10), "0a29696f313964307033616834673877773964376b63786671383779786537666e7238727074683573686a120331303018904e20012a077061796c6f6164", uint64(10700), "107100", "18d76ff9f3cfed0fe84f3fd4831f11379edc5b3d689d646187520b3fe74ab44c", "0a4b080118c0843d22023130c2023e0a29696f313964307033616834673877773964376b63786671383779786537666e7238727074683573686a120331303018904e20012a077061796c6f6164124104755ce6d8903f6b3793bddb4ea5d3589d637de2d209ae0ea930815c82db564ee8cc448886f639e8a0c7e94e99a5c1335b583c0bc76ef30dd6a1038ed9da8daf331a412e8bac421bab88dcd99c26ac8ffbf27f11ee57a41e7d2537891bfed5aed8e2e026d46e55d1b856787bc1cd7c1216a6e2534c5b5d1097c3afe8e657aa27cbbb0801", "f1785e47b4200c752bb6518bd18097a41e075438b8c18c9cb00e1ae2f38ce767", nil, nil, + identityset.PrivateKey(27), uint64(10), "test", "100", uint32(10000), true, []byte("payload"), uint64(1000000), big.NewInt(10), "0a0474657374120331303018904e20012a077061796c6f6164", uint64(10700), "107100", "18d76ff9f3cfed0fe84f3fd4831f11379edc5b3d689d646187520b3fe74ab44c", "0a26080118c0843d22023130c202190a0474657374120331303018904e20012a077061796c6f6164124104755ce6d8903f6b3793bddb4ea5d3589d637de2d209ae0ea930815c82db564ee8cc448886f639e8a0c7e94e99a5c1335b583c0bc76ef30dd6a1038ed9da8daf331a41563785be9d7e2d796a8aaca41dbe1a53a0bce3614ede09718e72c75cb40cdb48355964b69156008f2319e20db4a4023730c3a1664ac35dfc10a7ceff26be8ebe00", "ebb26b08e824e18cb6d38918411749351c065198603e4626bbdc10b900dde270", nil, nil, }, // invalid test { - identityset.PrivateKey(27), uint64(10), "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "ae-10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", ErrInvalidAmount, nil, + identityset.PrivateKey(27), uint64(10), "test", "ae-10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", ErrInvalidAmount, nil, }, { - identityset.PrivateKey(27), uint64(10), "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "-10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidAmount, + identityset.PrivateKey(27), uint64(10), "test", "-10", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidAmount, }, { - identityset.PrivateKey(27), uint64(10), "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "0", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidAmount, + identityset.PrivateKey(27), uint64(10), "test", "0", uint32(10000), false, []byte("payload"), uint64(1000000), big.NewInt(1000), "", uint64(10700), "", "", "", "", nil, ErrInvalidAmount, }, { - identityset.PrivateKey(27), uint64(10), "io19d0p3ah4g8ww9d7kcxfq87yxe7fnr8rpth5shj", "100", uint32(10000), true, []byte("payload"), uint64(1000000), big.NewInt(-unit.Qev), "0a29696f313964307033616834673877773964376b63786671383779786537666e7238727074683573686a120331303018904e20012a077061796c6f6164", uint64(10700), "107100", "18d76ff9f3cfed0fe84f3fd4831f11379edc5b3d689d646187520b3fe74ab44c", "0a4b080118c0843d22023130c2023e0a29696f313964307033616834673877773964376b63786671383779786537666e7238727074683573686a120331303018904e20012a077061796c6f6164124104755ce6d8903f6b3793bddb4ea5d3589d637de2d209ae0ea930815c82db564ee8cc448886f639e8a0c7e94e99a5c1335b583c0bc76ef30dd6a1038ed9da8daf331a412e8bac421bab88dcd99c26ac8ffbf27f11ee57a41e7d2537891bfed5aed8e2e026d46e55d1b856787bc1cd7c1216a6e2534c5b5d1097c3afe8e657aa27cbbb0801", "f1785e47b4200c752bb6518bd18097a41e075438b8c18c9cb00e1ae2f38ce767", nil, ErrNegativeValue, + identityset.PrivateKey(27), uint64(10), "test", "100", uint32(10000), true, []byte("payload"), uint64(1000000), big.NewInt(-unit.Qev), "0a0474657374120331303018904e20012a077061796c6f6164", uint64(10700), "107100", "18d76ff9f3cfed0fe84f3fd4831f11379edc5b3d689d646187520b3fe74ab44c", "0a26080118c0843d22023130c202190a0474657374120331303018904e20012a077061796c6f6164124104755ce6d8903f6b3793bddb4ea5d3589d637de2d209ae0ea930815c82db564ee8cc448886f639e8a0c7e94e99a5c1335b583c0bc76ef30dd6a1038ed9da8daf331a41563785be9d7e2d796a8aaca41dbe1a53a0bce3614ede09718e72c75cb40cdb48355964b69156008f2319e20db4a4023730c3a1664ac35dfc10a7ceff26be8ebe00", "ebb26b08e824e18cb6d38918411749351c065198603e4626bbdc10b900dde270", nil, ErrNegativeValue, }, } diff --git a/action/stakereclaim_test.go b/action/stakereclaim_test.go index 6b9451050c..c601a24d42 100644 --- a/action/stakereclaim_test.go +++ b/action/stakereclaim_test.go @@ -21,6 +21,7 @@ var ( _gaslimit = uint64(1000000) _gasprice = big.NewInt(10) _canAddress = "io1xpq62aw85uqzrccg9y5hnryv8ld2nkpycc3gza" + _canName = "candidate1" _payload = []byte("payload") _nonce = uint64(0) _index = uint64(10)