Some checks failed
CodeQL / Analyze (push) Waiting to run
Docker Build & Push Simapp (main) / docker-build (push) Waiting to run
golangci-lint / lint (push) Waiting to run
Tests / Code Coverage / build (amd64) (push) Waiting to run
Tests / Code Coverage / build (arm64) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[additional-args:-tags="test_e2e" name:e2e path:./e2e]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:08-wasm path:./modules/light-clients/08-wasm]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:ibc-go path:.]) (push) Waiting to run
Deploy to GitHub Pages / Deploy to GitHub Pages (push) Has been cancelled
Buf-Push / push (push) Has been cancelled
84 lines
2.1 KiB
Go
84 lines
2.1 KiB
Go
package solomachine_test
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/cosmos/ibc-go/v10/modules/core/exported"
|
|
solomachine "github.com/cosmos/ibc-go/v10/modules/light-clients/06-solomachine"
|
|
ibctesting "github.com/cosmos/ibc-go/v10/testing"
|
|
)
|
|
|
|
func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() {
|
|
// test singlesig and multisig public keys
|
|
for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} {
|
|
|
|
header := sm.CreateHeader(sm.Diversifier)
|
|
|
|
cases := []struct {
|
|
name string
|
|
header *solomachine.Header
|
|
expErr error
|
|
}{
|
|
{
|
|
"valid header",
|
|
header,
|
|
nil,
|
|
},
|
|
{
|
|
"timestamp is zero",
|
|
&solomachine.Header{
|
|
Timestamp: 0,
|
|
Signature: header.Signature,
|
|
NewPublicKey: header.NewPublicKey,
|
|
NewDiversifier: header.NewDiversifier,
|
|
},
|
|
errors.New("timestamp cannot be zero: invalid client header"),
|
|
},
|
|
{
|
|
"signature is empty",
|
|
&solomachine.Header{
|
|
Timestamp: header.Timestamp,
|
|
Signature: []byte{},
|
|
NewPublicKey: header.NewPublicKey,
|
|
NewDiversifier: header.NewDiversifier,
|
|
},
|
|
errors.New("signature cannot be empty: invalid client header"),
|
|
},
|
|
{
|
|
"diversifier contains only spaces",
|
|
&solomachine.Header{
|
|
Timestamp: header.Timestamp,
|
|
Signature: header.Signature,
|
|
NewPublicKey: header.NewPublicKey,
|
|
NewDiversifier: " ",
|
|
},
|
|
errors.New("diversifier cannot contain only spaces: invalid client header"),
|
|
},
|
|
{
|
|
"public key is nil",
|
|
&solomachine.Header{
|
|
Timestamp: header.Timestamp,
|
|
Signature: header.Signature,
|
|
NewPublicKey: nil,
|
|
NewDiversifier: header.NewDiversifier,
|
|
},
|
|
errors.New("new public key cannot be empty: invalid client header"),
|
|
},
|
|
}
|
|
|
|
suite.Require().Equal(exported.Solomachine, header.ClientType())
|
|
|
|
for _, tc := range cases {
|
|
suite.Run(tc.name, func() {
|
|
err := tc.header.ValidateBasic()
|
|
|
|
if tc.expErr == nil {
|
|
suite.Require().NoError(err)
|
|
} else {
|
|
suite.Require().Error(err)
|
|
suite.Require().ErrorContains(err, tc.expErr.Error())
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|